Skip to main content

Measurement Events

MeasurementStarted

Description

The MeasurementStarted event is triggered when a user initiates a measurement on a Dashboard or Record Level Maptaskr Map. This event provides information about the measurement type and the starting latitude and longitude coordinates.

Usage

To listen for the MeasurementStarted event, you can use the on method of the window.top['maptaskrCORE'] object. This allows you to register an event listener that executes a call-back function when the event is triggered.

Example

window.top['maptaskrCORE'][controlId].on("MeasurementStarted", function(measurementType, startLat, startLng) {
console.log("measurementType: " + measurementType);
console.log("startLat: " + startLat);
console.log("startLng: " + startLng);
});

In the example above, we've registered an event listener for the MeasurementStarted event. When the event occurs, the provided call-back function is executed, logging the measurement type, starting latitude, and starting longitude to the console.

Parameters

  • measurementType (string): The type or category of the measurement being initiated.
  • startLat (number): The latitude coordinate where the measurement started.
  • startLng (number): The longitude coordinate where the measurement started.

Removing Event Listeners

To remove the event listener for the MeasurementStarted event, you can use the off method of the window.top['maptaskrCORE'] object. This is useful when you no longer want to listen to this specific event.

Example

window.top['maptaskrCORE'][controlId].off("MeasurementStarted");

In the example above, the event listener for MeasurementStarted is removed, ensuring that the associated call-back function no longer executes when the event is triggered.

MeasurementCompleted

Description

The MeasurementCompleted event is triggered when a user completes a measurement on a Dashboard or Record Level Maptaskr Map. This event provides information about the measurement type, finishing latitude, finishing longitude, a polygon representation (if applicable), and any associated measurement text.

Usage

To listen for the MeasurementCompleted event, you can use the on method of the window.top['maptaskrCORE'] object. This allows you to register an event listener that executes a call-back function when the event is triggered.

Example

window.top['maptaskrCORE'][controlId].on("MeasurementCompleted", function(measurementType, finishLat, finishLong, polygon, measurementText) {
console.log("measurementType: " + measurementType);
console.log("finishLat: " + finishLat);
console.log("finishLong: " + finishLong);
console.log("polygon: " + polygon);
console.log("measurementText: " + measurementText);
});

In the example above, we've registered an event listener for the MeasurementCompleted event. When the event occurs, the provided call-back function is executed, logging the measurement type, finishing latitude, finishing longitude, polygon representation (if available), and measurement text to the console.

Parameters

  • measurementType (string): The type or category of the completed measurement.
  • finishLat (number): The latitude coordinate where the measurement was completed.
  • finishLong (number): The longitude coordinate where the measurement was completed.
  • polygon (string): A polygon representation of the completed measurement area, if applicable.
  • measurementText (string): The size of the shape associated with the measurement.

Response Example

The polygon returned will be a JavaScript Object in the format provided below (with some properties excluded for brevity)

{
"extent": "10609400.86028076,-2857630.8013220704,11559380.547374066,-2036576.928905712",
"geometry": {
"geometry": "10616186.429474283,-2321570.835033704,10609400.86028076,-2857630.8013220704,11186174.241730267,-2769418.4018062633,11559380.547374066,-2036576.928905712,10616186.429474283,-2321570.835033704",
"type": "Polygon"
},
"shapeSize": "Area: 383738727653.13 m²",
"attributes": {
"ShapeSize": "Area: 383738727653.13 m²"
}
}

Removing Event Listeners

To remove the event listener for the MeasurementCompleted event, you can use the off method of the window.top['maptaskrCORE'] object. This is useful when you no longer want to listen to this specific event.

Example

window.top['maptaskrCORE'][controlId].off("MeasurementCompleted");

In the example above, the event listener for MeasurementCompleted is removed, ensuring that the associated call-back function no longer executes when the event is triggered.

MeasurementCancelled

Description

The MeasurementCancelled event is triggered when a user cancels a measurement on a Dashboard or Record Level Maptaskr Map. This event provides information about the measurement type that was cancelled.

Usage

To listen for the MeasurementCancelled event, you can use the on method of the window.top['maptaskrCORE'] object. This allows you to register an event listener that executes a call-back function when the event is triggered.

Example

window.top['maptaskrCORE'][controlId].on("MeasurementCancelled", function(measurementType) {
console.log("measurementType: " + measurementType);
});

In the example above, we've registered an event listener for the MeasurementCancelled event. When the event occurs, the provided call-back function is executed, logging the type of the cancelled measurement to the console.

Parameters

  • measurementType (string): The type or category of the cancelled measurement.

Removing Event Listeners

To remove the event listener for the MeasurementCancelled event, you can use the off method of the window.top['maptaskrCORE'] object. This is useful when you no longer want to listen to this specific event.

Example

window.top['maptaskrCORE'][controlId].off("MeasurementCancelled");

In the example above, the event listener for MeasurementCancelled is removed, ensuring that the associated call-back function no longer executes when the event is triggered.

MeasurementsCleared

Description

The MeasurementsCleared event is triggered when a user clears all measurements on a Dashboard or Record Level Maptaskr Map. This event indicates the completion of measurement deletion.

Usage

To listen for the MeasurementsCleared event, you can use the on method of the window.top['maptaskrCORE'] object. This allows you to register an event listener that executes a call-back function when the event is triggered.

Example

window.top['maptaskrCORE'][controlId].on("MeasurementsCleared", function() {
console.log("Measurement Deletion Completed");
});

In the example above, we've registered an event listener for the MeasurementsCleared event. When the event occurs, the provided call-back function is executed, indicating the completion of measurement deletion by logging a message to the console.

Parameters

None

Removing Event Listeners

To remove the event listener for the MeasurementsCleared event, you can use the off method of the window.top['maptaskrCORE'] object. This is useful when you no longer want to listen for this specific event.

Example

window.top['maptaskrCORE'][controlId].off("MeasurementsCleared");

In the example above, the event listener for MeasurementsCleared is removed, ensuring that the associated call-back function no longer executes when the event is triggered.