Skip to main content

Feature Events

FeatureDrawingStarted

The FeatureDrawingStarted event is triggered when a user begins drawing a feature on the Record level map ONLY. This event provides information about the feature being drawn, including its name, and starting latitude and longitude coordinates as well as its parent shape.

Parameters:

  • featureType (string): The type of feature (e.g., polygon, line).
  • startLat (number): Latitude where drawing started.
  • startLng (number): Longitude where drawing started.

Usage:

control.on("FeatureDrawingStarted", (shapeName,featureType, startLat, startLng) => {
console.log(shapeName, featureType, startLat, startLng);
});
Response
{
"featureType": "Point",
"startLat": 22.41527184314326,
"startLng": 22.41527184314326
}

Removing Event Listeners:

control.off("FeatureDrawingStarted");

FeatureDrawingCompleted

The FeatureDrawingCompleted event is triggered when a user completes a drawing a feature on the Record level map ONLY. This event provides information about the feature being drawn, including its name, and starting latitude and longitude coordinates as well as its parent shape.

Parameters:

  • shapeName (string): The name of the shape drawn.
  • featureType (string): The type of feature.
  • startLat (number): Latitude where drawing started.
  • startLng (number): Longitude where drawing started.
  • geometry (object): The geometry of the completed feature.

Usage:

control.on("FeatureDrawingCompleted", (shapeName, featureType, startLat, startLng, geometry) => {
console.log(shapeName, featureType, startLat, startLng, geometry);
});
Response
{
"shapeName":"",
"featureType": "Polygon",
"startLat": 22.401619852159655,
"startLng": -80.00280908892854,
"geometry": {"type":"Polygon","coordinates":[[[-80.00280908892854,22.401619852159655],[-80.00043013120279,22.403645151909174],[-79.99813507772488,22.40416241203937],[-79.9979841354755,22.399316722219154],[-80.00280908892854,22.401619852159655]]]}
}

Removing Event Listeners:

control.off("FeatureDrawingCompleted");

FeatureDrawingCancelled

The FeatureDrawingCancelled event is triggered when a user cancels the drawing of a feature on the Record level map ONLY. This event provides information about the cancelled feature, including its name.

Parameters:

  • shapeName (string): The name of the shape whose drawing was cancelled.

Usage:

control.on("FeatureDrawingCancelled", (shapeName) => {
console.log(shapeName);
});

Removing Event Listeners:

control.off("FeatureDrawingCancelled");

FeatureDrawingDeleted

The FeatureDrawingDeleted event is triggered when a user deletes a previously drawn feature on the Record level map ONLY. This event provides information about the deleted feature, including its name.

Parameters:

  • shapeName (string): The name of the deleted shape.
  • type (string): The type of the deleted feature.

Usage:

const control = globalThis.MaptaskrControlManager.getControl(controlId);
control.on("FeatureDrawingDeleted", (shapeName, type) => {
console.log(shapeName, type);
});

Removing Event Listeners:

control.off("FeatureDrawingDeleted");

FeaturesSelected

The FeaturesSelected event is triggered when a user selects a feature on the Dashboard or Record level map. This event provides information about the selected feature(s).

Parameters:

  • features (array): The array of selected features.

Usage:

control.on("FeaturesSelected", (features) => {
console.log(features);
});
Response
[
{
"id": "1752550418322",
"geometry": {
"type": "Point",
"coordinates": [
-79.96525709,
22.4120034
]
},
"properties": {},
"centroid": {
"x": -79.96525709,
"y": 22.4120034,
"z": 0
},
"extent": {
"xmin": -79.96525709,
"ymin": 22.4120034,
"xmax": -79.96525709,
"ymax": 22.4120034,
"zmin": 0,
"zmax": 0,
"spatialReference": {
"wkid": 4326
}
},
"totalCoordinateCount": 1,
"levelOfDetail": 0,
"layerInstanceId": "1ee3fe6a-8d3e-4227-97aa-fc5b3f51f01b"
}
]

Removing Event Listeners:

control.off("FeaturesSelected");