Layer List Events
LayerSearchCompleted
Description
The LayerSearchCompleted
event is triggered when a user completes a search for layers on a Dashboard
or Record Level
Maptaskr Map. This event provides information about the search polygon, search term, and the resulting layers in JSON format.
Usage
To listen for the LayerSearchCompleted
event, you can use the on
method of the window.top['maptaskrCORE']
object. This allows you to register an event listener that executes a call-back function when the event is triggered.
Example
window.top['maptaskrCORE'][controlId].on("LayerSearchCompleted", function(searchPolygon, searchTerm, resultingLayersJson) {
console.log("searchPolygon: " + searchPolygon);
console.log("searchTerm: " + searchTerm);
console.log("resultingLayersJson: " + resultingLayersJson);
});
In the example above, we've registered an event listener for the LayerSearchCompleted
event. When the event occurs, the provided call-back function is executed, logging the search polygon, search term, and the resulting layers in JSON format to the console.
Parameters
searchPolygon
(string): The search polygon or area used for layer searching.searchTerm
(string): The search term or criteria used for layer searching.resultingLayersJson
(string): The resulting layers in JSON format that match the search criteria.
Response Example
The resultingLayersJson
returned will be a JavaScript Object in the format provided below (with some properties excluded for brevity)
[
{
"layers": [],
"groups": [],
"isFiltered": true,
"LayerId": "acb612f0-bea7-eb11-9442-000d3acb7dc6-2",
"LayerName": "MapServer RoadAssets_DataPortal",
"LayerHiddenName": "https://mrgis.mainroads.wa.gov.au/arcgis/rest/services/OpenData/RoadAssets_DataPortal/MapServer",
"IsCorporate": true,
"layerGroupId": "819aafa8-2a8e-ec11-8d20-002248159630",
"SecurityGroupId": [
"all"
],
"LayerType": 5,
"LayerUrl": "https://mrgis.mainroads.wa.gov.au/arcgis/rest/services/OpenData/RoadAssets_DataPortal/MapServer",
"isService": true,
"IsVisible": true,
"IsSelected": false,
"sharedUserIds": [],
"hasAuthentication": false,
"layerUserName": "",
"layerPassword": "",
"metadataStyle": "Table",
"arcGisAuthApplication": "",
"securityLayerKey": "",
"securityLayerValue": "",
"securityLayerType": 0,
"arcGisLayerToken": "",
"isForPortal": true,
"LayerUniqueIdentifier": "acb612f0-bea7-eb11-9442-000d3acb7dc6-2",
"IsCollapsed": true,
"IsLayerFunctionality": false,
"filteredSubLayersId": [
0,
6,
27
]
}
]
Removing Event Listeners
To remove the event listener for the LayerSearchCompleted
event, you can use the off
method of the window.top['maptaskrCORE']
object. This is useful when you no longer want to listen to this specific event.
Example
window.top['maptaskrCORE'][controlId].off("LayerSearchCompleted");
In the example above, the event listener for LayerSearchCompleted
is removed, ensuring that the associated call-back function no longer executes when the event is triggered.
LayerSelected
Description
The LayerSelected
event is triggered when a user selects a layer or layer group on a Dashboard
or Record Level
Maptaskr Map. This event provides information about the selected layer group ID and layer ID.
Usage
To listen for the LayerSelected
event, you can use the on
method of the window.top['maptaskrCORE']
object. This allows you to register an event listener that executes a call-back function when the event is triggered.
Example
window.top['maptaskrCORE'][controlId].on("LayerSelected", function(layerGroupID, layerID, checked) {
console.log("layerGroupID: " + layerGroupID);
console.log("layerID: " + layerID);
console.log("checked: " + checked);
});
In the example above, we've registered an event listener for the LayerSelected
event. The provided call-back function is executed when the event occurs, logging the layer group ID and layer ID to the console.
Parameters
layerGroupID
(string): The ID of the selected layer group.layerID
(string): The ID of the selected layer within the group.checked
(boolean): If the layer is checked or unchecked.
Removing Event Listeners
To remove the event listener for the LayerSelected
event, you can use the off
method of the window.top['maptaskrCORE']
object. This is useful when you no longer want to listen to this specific event.
Example
window.top['maptaskrCORE'][controlId].off("LayerSelected");
In the example above, the event listener for LayerSelected
is removed, ensuring that the associated call-back function no longer executes when the event is triggered.
LayerFilterApplied
Description
The LayerFilterApplied
event is triggered when a user applies a filter to a layer on a Dashboard
or Record Level
Maptaskr Map. This event provides information about the filter parameters.
Usage
To listen for the LayerFilterApplied
event, you can use the on
method of the window.top['maptaskrCORE']
object. This allows you to register an event listener that executes a call-back function when the event is triggered.
Example
window.top['maptaskrCORE'][controlId].on("LayerFilterApplied", function(filterparams) {
console.log("filterparams: " + filterparams);
});
In the example above, we've registered an event listener for the LayerFilterApplied
event. The provided call-back function is executed when the event occurs, logging the filter parameters to the console.
Parameters
filterparams
(string): The filter parameters applied to the layer.
Response Example
The filterparams
returned will be a JavaScript Object in the format provided below (with some properties excluded for brevity)
{
"LayerName": "Bike Count Sites",
"LayerUniqueIdentifier": "acb612f0-bea7-eb11-9442-000d3acb7dc6-2_670badf1-7131-4068-9437-a9f254cf2607",
"expressionItems": [
{
"operators": [
{
"name": "Equals",
"value": "eq",
"fetchOp": "eq",
"fetchVal": "",
"types": [
6,
1,
3,
7
],
"isCommon": false
},
{
"name": "Does Not Equal",
"value": "ne",
"fetchOp": "ne",
"fetchVal": "",
"types": [
6,
1,
3,
7
],
"isCommon": false
}
],
"fields": [
{
"displayName": "OBJECTID",
"internalName": "OBJECTID",
"fieldTypeName": "decimal",
"fieldType": 6
},
...
],
"valueList": [],
"dataType": 6,
"displayName": "OBJECTID",
"operator": "eq",
"value": "1",
"fieldInfo": "{\"displayName\":\"OBJECTID\",\"internalName\":\"OBJECTID\",\"fieldTypeName\":\"decimal\",\"fieldType\":6}"
}
],
"FilterLayerOperator": "Match All"
}
Removing Event Listeners
To remove the event listener for the LayerFilterApplied
event, you can use the off
method of the window.top['maptaskrCORE']
object. This is useful when you no longer want to listen to this specific event.
Example
window.top['maptaskrCORE'][controlId].off("LayerFilterApplied");
In the example above, the event listener for LayerFilterApplied
is removed, ensuring that the associated call-back function no longer executes when the event is triggered.
LayerAttributeRequested
Description
The LayerAttributeRequested
event is triggered when a user requests attributes for a layer on a Dashboard
or Record Level
Maptaskr Map. This event provides information about the layer group ID, layer ID, and resulting attributes.
Usage
To listen for the LayerAttributeRequested
event, you can use the on
method of the window.top['maptaskrCORE']
object. This allows you to register an event listener that executes a call-back function when the event is triggered.
Example
window.top['maptaskrCORE'][controlId].on("LayerAttributeRequested", function(layerGroupdID, layerID, resultingAttributes) {
console.log("layerGroupdID: " + layerGroupdID);
console.log("layerID: " + layerID);
console.log("resultingAttributes: " + resultingAttributes);
});
In the example above, we've registered an event listener for the LayerAttributeRequested
event. When the event occurs, the provided call-back function is executed, logging the layer group ID, layer ID, and resulting attributes to the console.
Parameters
layerGroupdID
(string): The ID of the layer group for which attributes were requested.layerID
(string): The ID of the layer for which attributes were requested.resultingAttributes
(string): The resulting attributes for the requested layer.
Response Example
The resultingAttributes
returned will be a JavaScript Object in the format provided below (with some properties excluded for brevity)
[
{
"OBJECTID": 88315,
"SITE_NO": "6737",
"ROAD_NAME": "Kwinana Fwy PSP",
"LOCATION_DESC": "North Abutment of Narrows Bridge",
"DATE_COMMISSIONED": "2008-11-01 09:00:00",
"TRAFFIC_YEAR": "2023/24",
"PRIMARY_DIRECTION": "To Perth",
"PRIMARY_DIRECTION_MON_SUN": 234,
"PRIMARY_DIRECTION_MON_FRI": 207,
"SECONDARY_DIRECTION": "To Fremantle",
"SECONDARY_DIRECTION_MON_SUN": 257,
"SECONDARY_DIRECTION_MON_FRI": 213,
"COMBINED_DIRECTION_MON_SUN": 491,
"COMBINED_DIRECTION_MON_FRI": 420,
"LG_NO": "124",
"LG_NAME": "Perth (C)",
"RA_NO": 7,
"RA_NAME": "Metropolitan",
"PRIMARY_DIRECTION_SAT_SUN": 300,
"SECONDARY_DIRECTION_SAT_SUN": 368,
"COMBINED_DIRECTION_SAT_SUN": 668,
"geom": {
"x": 115.8481209999099,
"y": -31.96117500052617
},
"projection": "4326",
"isSelected": false
},
...
]
Removing Event Listeners
To remove the event listener for the LayerAttributeRequested
event, you can use the off
method of the window.top['maptaskrCORE']
object. This is useful when you no longer want to listen to this specific event.
Example
window.top['maptaskrCORE'][controlId].off("LayerAttributeRequested");
In the example above, the event listener for LayerAttributeRequested
is removed, ensuring that the associated call-back function no longer executes when the event is triggered.