Skip to main content

Event Listeners

Below are the main event handlers available for extending Maptaskr Power Maps functionality. You can listen for map and control events using the on method of the Maptaskr Control Manager. For detailed usage and parameter information, refer to the documentation below.

Example usage:

// Listen for when feature drawing starts
const control = globalThis.MaptaskrControlManager.getControl(controlId);
control.on("FeatureDrawingStarted", (shapeName, featureType, startLat, startLng) => {
console.log(shapeName, featureType, startLat, startLng);
});

About events in Maptaskr Power Maps

In previous versions, event listeners were wrapped in a window.maptaskrReady function, typically in a Dynamics JS file or Power Pages template. This approach worked when only one map was present on the page.

With Maptaskr Power Maps, you can now have multiple maps on a single page. Extension methods should be defined as standalone functions (the function name can remain mapReady or be customized). Remove the window wrapper, and add your function name to the your Config Manger profile (Custom code → Custom JS). The new Custom JS control will automatically run your functions once the target control has loaded.

Supported Events

CategoryEvent NameCallback Signature / ParametersDescription
Feature DrawingFeatureDrawingStarted(shapeName, featureType, startLat, startLng)User begins drawing a feature (point/line/polygon).
Feature DrawingFeatureDrawingCompleted(shapeName, featureType, startLat, startLng, geometry)Feature drawing finishes and GeoJSON is emitted.
Feature DrawingFeatureDrawingCancelled(shapeName)Feature drawing was cancelled before completion.
Feature DrawingFeatureDrawingDeleted(shapeName, type)Previously drawn feature deleted.
Feature DrawingFeaturesSelected(features)One or more features selected in UI.
Shape DrawingShapeDrawingStarted(shapeName, shapeType, shapeId)User begins drawing a shape (record-level context).
Shape DrawingShapeDrawingCompleted(shapeName, geojson, shapeId)Shape drawing finishes; GeoJSON + id available.
Shape DrawingShapeDrawingCancelled(shapeName, shapeId)Shape drawing cancelled.
Shape DrawingShapeDrawingCleared(shapeName, shapeId)Transient drawing state cleared (context reset).
Shape DrawingShapeDrawingDeleted(shapeName, shapeId)Saved / working shape deleted.
Shape DrawingShapeDrawingFileSelected(shapeName, file, shapeId)User selected/imported a shape file.
LayerLayerAdded(layerId)Layer added to map UI.
LayerLayerFilterApplied(layerId, subLayerId, filterGroup, instanceId)Filter applied to layer/sublayer.
SearchSearchExecuted(term)A search term submitted.
SearchSearchResultsFound(groupName, results)Results returned for a search group.
SearchRecordAddressSet(searchResult)Record-level address fields populated.
MeasurementMeasurementStarted(measurementType, startLat, startLng)User begins a measurement session.
MeasurementMeasurementCompleted(measurementType, finishLat, finishLong, polygon, measurementText)Measurement finalized; geometry + text summary available.
MeasurementMeasurementCancelled(measurementType)Measurement aborted.
MeasurementMeasurementsCleared()All measurement overlays cleared.
MapMapDownloaded(fileName, base64Image)Map export generated (intercepts default download).
MapBasemapChanged(measurementType, url)Basemap style changed.
MapZoomChanged(zoomLevel)Zoom level changed.
MapMapClicked(lat, lng)User clicked map canvas.
MapExtentChanged(extent)Map viewport extent changed.
MapSavingCompleted()User confirmed & saved shape(s); retrieve ids via callback.