Skip to main content

Shape Events

ShapeDrawingStarted

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

Parameters:

  • shapeName (string): The name of the shape being drawn.
  • shapeType (string): The type of the shape.
  • shapeId (string): The id of the shape.

Usage:

control.on("ShapeDrawingStarted", (shapeName, shapeType, shapeId) => {
console.log(shapeName, shapeType, shapeId);
});
Response
{
"shapeName": "New Shape 2",
"shapeType": "LineString",
"shapeId": "e4933789-fb67-406a-8bf5-6ec58e5233df"
}

Removing Event Listeners:

control.off("ShapeDrawingStarted");

ShapeDrawingCompleted

The ShapeDrawingCompleted event is triggered when a user finishes drawing a shape on the Record level map ONLY. This event provides information about the completed shape, including its name, finishing latitude, finishing longitude, and a polygon representation if applicable.

Parameters:

  • shapeName (string): The name of the completed shape.
  • geojson (string): The type of the shape.
  • shapeId (string): The id of the shape.

Usage:

control.on("ShapeDrawingCompleted", (shapeName, geojson, shapeId) => {
console.log(shapeName, geojson, shapeId);
});
Response
{
"shapeName":"New Shape 2 ",
"geojson":{"type":"FeatureCollection","features":[{"id":"1752550418256","type":"Feature","geometry":{"type":"Point","coordinates":[-79.97880649801083,22.41356546814434]},"properties":{"shapeName":"New Shape 2"}},{"id":"1752550418260","type":"Feature","geometry":{"type":"LineString","coordinates":[[-79.9719031429871,22.414774145932824],[-79.97051724216807,22.413106167827777]]},"properties":{"shapeName":"New Shape 2"}}]},
"shapeId":""
}

Removing Event Listeners:

control.off("ShapeDrawingCompleted");

ShapeDrawingCancelled

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

Parameters:

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

Usage:

control.on("ShapeDrawingCancelled", (shapeName, shapeId) => {
console.log(shapeName, shapeId);
});
Response
{
"shapeName":"New Shape 3",
"shapeId": "e4933789-fb67-406a-8bf5-6ec58e5233df"
}

Removing Event Listeners:

control.off("ShapeDrawingCancelled");

ShapeDrawingCleared

The ShapeDrawingCleared event is triggered when any transient drawing state (in-progress vertices or preview geometry) is cleared from the Record level map without completing or cancelling a specific shape. It fires after the control resets the drawing context (e.g. user presses a clear button or exits drawing mode). Returns the last working shape context if available.

Parameters:

  • shapeName (string): The name previously assigned during drawing (may be empty if none set yet).
  • shapeId (string): The temporary or assigned id for the shape context that was cleared.

Usage:

control.on("ShapeDrawingCleared", (shapeName, shapeId) => {
console.log('Cleared drawing context:', shapeName, shapeId);
});
Response
{
"shapeName": "New Shape 3",
"shapeId": "e4933789-fb67-406a-8bf5-6ec58e5233df"
}

Removing Event Listeners:

control.off("ShapeDrawingCleared");

ShapeDrawingDeleted

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

Parameters:

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

Usage:

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

Removing Event Listeners:

control.off("ShapeDrawingDeleted");

ShapeDrawingFileSelected

The ShapeDrawingFileSelected event is triggered when a user selects a file for shape drawing on the Record level map ONLY. This event provides information about the selected shape"s name and the name of the selected file.

Parameters:

  • shapeName (string): The name of the shape.
  • file (object): The results of the file selection/import.
  • shapeId (object): The results of the shape id.

Usage:

const control = globalThis.MaptaskrControlManager.getControl(controlId);
control.on("ShapeDrawingFileSelected", (shapeName, file, shapeId) => {
console.log(shapeName, file, shapeId);
});
Response
{
"shapeName": "New Shape 3 File ",
"file": {"lastModified": 1745895716423,
"lastModifiedDate":
"Tue Apr 29 2025 11:01:56 GMT+0800 (Australian Western Standard Time)",
"name": "shape-file.zip",
"size": 1146,
"type": "application/x-zip-compressed",
"webkitRelativePath": ""} ,
"shapeId": "e4933789-fb67-406a-8bf5-6ec58e5233df"
}

Removing Event Listeners:

control.off("ShapeDrawingFileSelected");