Skip to main content

Map Interaction Events

FeaturesSelected

Description

The FeaturesSelected event is triggered when one or more features are selected on the map using the Maptaskr for Power Pages App. 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['maptaskrPCF'] object. This allows you to register an event listener that executes a call-back function when the event is triggered.

Example

window['maptaskrPCF'].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['maptaskrPCF'] object. This is useful when you no longer want to listen to this specific event.

Example

window['maptaskrPCF'].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 map using the Maptaskr for Power Pages App. 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['maptaskrPCF'] object. This allows you to register an event listener that executes a call-back function when the event is triggered.

Example

window['maptaskrPCF'].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['maptaskrPCF'] object. This is useful when you no longer want to listen to this specific event.

Example

window['maptaskrPCF'].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 map is changed using the Maptaskr for Power Pages App. 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['maptaskrPCF'] object. This allows you to register an event listener that executes a call-back function when the event is triggered.

Example

window['maptaskrPCF'].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.

Parameters

  • 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['maptaskrPCF'] object. This is useful when you no longer want to listen to this specific event.

Example

window['maptaskrPCF'].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 map is changed using the Maptaskr for Power Pages App. 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['maptaskrPCF'] object. This allows you to register an event listener that executes a call-back function when the event is triggered.

Example

window['maptaskrPCF'].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 Example

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['maptaskrPCF'] object. This is useful when you no longer want to listen to this specific event.

Example

window['maptaskrPCF'].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 map is downloaded or exported using the Maptaskr for Power Pages App. 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['maptaskrPCF'] object. This allows you to register an event listener that executes a call-back function when the event is triggered.

Example

window['maptaskrPCF'].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.

IMPORTANT

Registering this event will prevent the standard file download and will require you to handle 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['maptaskrPCF'] object. This is useful when you no longer want to listen to this specific event.

Example

window['maptaskrPCF'].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 map application using the Maptaskr for Power Pages App. 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['maptaskrPCF'] object. This allows you to register an event listener that executes a callback function when the event is triggered.

Example

window['maptaskrPCF'].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['maptaskrPCF'] object. This is useful when you no longer want to listen to this specific event.

Example

window['maptaskrPCF'].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.