Skip to main content

Map Events

MapDownloaded

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 in PNG format.

Parameters:

  • fileName (string): The name of the downloaded file.
  • base64Image (object): The content of the downloaded map.

Usage:

control.on("MapDownloaded", (fileName, base64Image) => {
console.log(fileName, content);
});
caution

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 before presenting it to the user.

Response
{
"fileName": "MaptaskrMap",
"base64Image": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABP8AAAOBCAYAAACOEQVkAAAAAX..."
}

Removing Event Listeners:

control.off("MapDownloaded");

BasemapChanged

The BaseMapChanged event is triggered when a user changes the base map type on a Dashboard or Record Level Maptaskr Map. This event provides information about the new base map type and its associated URL.

Parameters:

  • measurementType (string): The type of measurement or context for the basemap change.
  • url (string): The URL of the new basemap.

Usage:

control.on("BasemapChanged", (measurementType, url) => {
console.log(measurementType, url);
});
Response
{
"measurementType":"MapLibreStyleBasemap",
"url": "https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/styles/arcgis/navigation"
}

Removing Event Listeners:

control.off("BasemapChanged");

ZoomChanged

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.

Parameters:

  • zoomLevel (number): The new zoom level.

Usage:

const control = globalThis.MaptaskrControlManager.getControl(controlId);
control.on("ZoomChanged", (zoomLevel) => {
console.log(zoomLevel);
});
Response
{
"zoomLevel": 3.1320229755361475
}

Removing Event Listeners:

control.off("ZoomChanged");

MapClicked

The MapClicked 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.

Parameters:

  • lat (number): Latitude of the click.
  • lng (number): Longitude of the click.

Usage:

const control = globalThis.MaptaskrControlManager.getControl(controlId);
control.on("MapClicked", (lat, lng) => {
console.log(lat, lng);
});

example

const control = globalThis.MaptaskrControlManager.getControl(controlId);
control.on("MapClicked", async (lat, lng) => {
const locations = await control.searchAddressesByLocation(lat, lng);
console.log(locations[0]);
await control.setRecordAddress(locations[0]);
console.log(lat, lng);
});
Response
{
"Latitude": -27.637177571946367,
"Longitude" : 138.77076511586245
}

Removing Event Listeners:

control.off("MapClicked");

ExtentChanged

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.

Parameters:

  • extent (object): The new map extent.

Usage:

const control = globalThis.MaptaskrControlManager.getControl(controlId);
control.on("ExtentChanged", (extent) => {
console.log(extent);
});
Response
{
"extent": {
"xmin": -80.23176244729467,
"xmax": 82.29656890150363,
"ymin": -29.978012659811707,
"ymax": 72.47308212791474,
"zmax": 0,
"zmin": 0,
"spatialReference": {
"wkid": 4326
}
}
}

Removing Event Listeners:

control.off("ExtentChanged");

SavingCompleted

The SavingCompleted event fires when the user confirms and saves a shape (new or edited). It indicates the shape has been persisted and normal post-save logic (e.g. refresh lists, toast messages) can run.

Parameters:

  • shapeIdArray (string)

Usage:

const control = globalThis.MaptaskrControlManager.getControl(controlId);
control.on("SavingCompleted", (shapeIdArray) => {
console.log('Saved:' shapeIdArray);
});

Removing Event Listeners:

control.off("SavingCompleted");