Map Interaction Events
FeaturesSelected
Description
The FeaturesSelected
event is triggered when one or more features are selected on a Dashboard
or Record Level
Maptaskr Map. This event provides information about the selected features in an array.
Usage
To listen for the FeaturesSelected
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("FeaturesSelected", function(featureArray) {
console.log("featureArray: " + featureArray);
});
In the example above, we've registered an event listener for the FeaturesSelected
event. The provided call-back function is executed when the event occurs, logging the selected features in an array to the console.
Parameters
featureArray
(array): An array containing information about the selected features.
Response Example
The featureArray
returned will be a JavaScript Object in the format provided below (with some properties excluded for brevity)
[
{
"extent": "16604577.824962063,-4208878.32517417,16877565.654802185,-4017740.3699756954",
"geometry": {
"geometry": "16604577.824962063,-4193191.11802936,16798639.64578343,-4017740.3699756954,16877565.654802185,-4208878.32517417,16604577.824962063,-4193191.11802936",
"type": "Polygon"
},
"attributes": {
"FID": 433,
"ST_PLY_PID": null,
"DT_CREATE": null,
"DT_RETIRE": null,
"STATE_PID": null,
"STATE_NAME": null,
"ST_ABBREV": null,
"Shape__Area": 25470103468.5586,
"Shape__Length": 741846.481025205,
"LayerName": "new_gis_sa_test"
}
}
]
Removing Event Listeners
To remove the event listener for the FeaturesSelected
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("FeaturesSelected");
In the example above, the event listener for FeaturesSelected
is removed, ensuring that the associated call-back function no longer executes when the event is triggered.
OnMapClicked
Description
The OnMapClicked
event is triggered when a user clicks on the Dashboard
or Record Level
Maptaskr Map. This event provides information about the clicked coordinates on the map.
Usage
To listen for the OnMapClicked
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("OnMapClicked", function(coordinates) {
console.log("coordinates: " + coordinates);
});
In the example above, we've registered an event listener for the OnMapClicked
event. The provided call-back function is executed when the event occurs, logging the clicked coordinates on the map to the console.
Parameters
coordinates
(object): An object containing information about the clicked coordinates on the map.
Removing Event Listeners
To remove the event listener for the OnMapClicked
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("OnMapClicked");
In the example above, the event listener for OnMapClicked
is removed, ensuring that the associated call-back function no longer executes when the event is triggered.
ZoomChanged
Description
The ZoomChanged
event is triggered when the zoom level of the Dashboard
or Record Level
Maptaskr Map is changed. This event provides information about the previous and new zoom levels.
Usage
To listen for the ZoomChanged
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("ZoomChanged", function(previousZoom, newZoom) {
console.log("previousZoom: " + previousZoom);
console.log("newZoom: " + newZoom);
});
In the example above, we've registered an event listener for the ZoomChanged
event. The provided call-back function is executed when the event occurs, logging the previous and new zoom levels to the console.
Parameter
previousZoom
(number): The previous zoom level.newZoom
(number): The new zoom level.
Removing Event Listeners
To remove the event listener for the ZoomChanged
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("ZoomChanged");
In the example above, the event listener for ZoomChanged
is removed, ensuring that the associated call-back function no longer executes when the event is triggered.
ExtentChanged
Description
The ExtentChanged
event is triggered when the extent (viewable area) of the Dashboard
or Record Level
Maptaskr Map is changed. This event provides information about the previous and new extents.
Usage
To listen for the ExtentChanged
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("ExtentChanged", function(previousExtent, newExtent) {
console.log("previousExtent: " + previousExtent);
console.log("newExtent: " + newExtent);
});
In the example above, we've registered an event listener for the ExtentChanged
event. The provided call-back function is executed when the event occurs, logging the previous and new extents to the console.
Parameters
previousExtent
(string): An object representing the previous extent.newExtent
(string): An object representing the new extent.
Response
The previousExtent
returned will be a JavaScript Object in the format provided below (with some properties excluded for brevity)
[16829447.323061984,-4008072.879304091,16835786.819095384,-4003663.41823489]
The newExtent
returned will be a JavaScript Object in the format provided below (with some properties excluded for brevity)
[17020622.764176447,-3197224.0595355905,17032536.673651483,-3188937.293563126]
Removing Event Listeners
To remove the event listener for the ExtentChanged
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("ExtentChanged");
In the example above, the event listener for ExtentChanged
is removed, ensuring that the associated call-back function no longer executes when the event is triggered.
MapDownloaded
Description
The MapDownloaded
event is triggered when a Dashboard
or Record Level
Maptaskr Map is downloaded or exported. This event provides the base64 encoded file rendered. This event also provides the filetype of the Base64 file either in PDF
or PNG
format (based on configured properties)
Usage
To listen for the MapDownloaded
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("MapDownloaded", function(filetype, base64File) {
console.log("filetype: " + filetype);
console.log("base64File: " + base64File);
});
In the example above, we've registered an event listener for the MapDownloaded
event. When the event occurs, the provided call-back function is executed, logging information file type and the base64 file itself to the console.
Registering this event will prevent the standard file download
and will require you to handler the process after the base64 file is generated. This is to prevent duplicate downloads should you wish to modify the image / pdf before presenting it to the user.
Parameters
filetype
(string): The file type of the downloaded map (e.g., "PDF", "PNG").base64File
(string): The base64-encoded content of the downloaded map.
Removing Event Listeners
To remove the event listener for the MapDownloaded
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("MapDownloaded");
In the example above, the event listener for MapDownloaded
is removed, ensuring that the associated call-back function no longer executes when the event is triggered.
ShapeIntersectionsDetected
Description
The ShapeIntersectionsDetected
event is triggered when intersections are detected between shapes within the Dashboard
or Record Level
Maptaskr Map. This event provides information about the shapes that intersect.
Usage
To listen for the ShapeIntersectionsDetected
event, you can use the on
method of the window.top['maptaskrCORE']
object. This allows you to register an event listener that executes a callback function when the event is triggered.
Example
window.top['maptaskrCORE'][controlId].on("ShapeIntersectionsDetected", function(intersectedShapes) {
console.log("intersectedShapes: " + intersectedShapes);
});
In the example above, we have registered an event listener for the ShapeIntersectionsDetected
event. The provided callback function is executed when the event occurs and logs the intersected shapes to the console.
Parameters
intersectedShapes
(string): Information about the shapes that intersect.
Removing Event Listeners
To remove the event listener for the ShapeIntersectionsDetected
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("ShapeIntersectionsDetected");
In the example above, the event listener for ShapeIntersectionsDetected
is removed, ensuring that the associated callback function no longer executes when the event is triggered.