Annotation Drawing Events
AnnotationDrawingStarted
Description
The AnnotationDrawingStarted
event is triggered when a user begins drawing an annotation on a map using the Maptaskr for Power Pages App. This event provides information about the annotation's shape name and starting latitude and longitude coordinates.
Usage
To listen for the AnnotationDrawingStarted
event, you can use the on
method of the window['maptaskrPCF']
object. This allows you to register an event listener that executes a call-back function when the event is triggered.
Example
window['maptaskrPCF'].on("AnnotationDrawingStarted", function(shapeName, startLat, startLng) {
console.log("shapeName: " + shapeName);
console.log("startLat: " + startLat);
console.log("startLng: " + startLng);
});
In the example above, we've registered an event listener for the AnnotationDrawingStarted
event. When the event occurs, the provided call-back function is executed, logging the annotation's shape name, starting latitude, and starting longitude to the console.
Parameters
shapeName
(string): The name or identifier of the annotation being drawn.startLat
(number): The latitude coordinate where the annotation drawing started.startLng
(number): The longitude coordinate where the annotation drawing started.
Removing Event Listeners
To remove the event listener for the AnnotationDrawingStarted
event, you can use the off
method of the window['maptaskrPCF']
object. This is useful when you no longer want to listen to this specific event.
Example
window['maptaskrPCF'].off("AnnotationDrawingStarted");
In the example above, the event listener for AnnotationDrawingStarted
is removed, ensuring that the associated call-back function no longer executes when the event is triggered.
AnnotationDrawingCompleted
Description
The AnnotationDrawingCompleted
event is triggered when a user completes the drawing of an annotation on a map using the Maptaskr for Power Pages App. This event provides information about the annotation's shape name, finishing latitude, finishing longitude, polygon representation (if applicable) and text (if applicable).
Usage
To listen for the AnnotationDrawingCompleted
event, you can use the on
method of the window['maptaskrPCF']
object. This allows you to register an event listener that executes a call-back function when the event is triggered.
Example
window['maptaskrPCF'].on("AnnotationDrawingCompleted", function(shapeName, finishLat, finishLong, polygon, text) {
console.log("shapeName: " + shapeName);
console.log("finishLat: " + finishLat);
console.log("finishLong: " + finishLong);
console.log("polygon: " + polygon);
console.log("text: " + text);
});
In the example above, we've registered an event listener for the AnnotationDrawingCompleted
event. When the event occurs, the provided call-back function is executed, logging the annotation's shape name, finishing latitude, finishing longitude, the polygon representation (if available) and text (if available) to the console.
Parameters
shapeName
(string): The name or identifier of the completed annotation.finishLat
(number): The latitude coordinate where the annotation drawing was completed.finishLong
(number): The longitude coordinate where the annotation drawing was completed.Polygon
(string): A polygon representation of the completed annotation area, if applicable.Text
(string): The text content of the completed annotation if it was a text annotation. If the annotation wasn't a text annotation, this will return as undefined.
Response Example
The polygon
returned will be a JavaScript Object in the format provided below (with some properties excluded for brevity)
{
"extent": "10833324.643667039,-5422575.956473999,12041155.960114244,-3916179.5955117554",
"geometry": {
"geometry":
"10962250.458343988,-4377598.300671361,10833324.643667039,-5422575.956473999,11864731.16108263,-5388648.110506381,12041155.960114244,-4771161.313895731,11844374.453502059,-3916179.5955117554",
"type": "LineString"
},
"shapeSize": "Length: 2735.42 km",
"attributes": {
"ShapeSize": "Length: 2735.42 km"
}
}
Removing Event Listeners
To remove the event listener for the AnnotationDrawingCompleted
event, you can use the off
method of the window['maptaskrPCF']
object. This is useful when you no longer want to listen to this specific event.
Example
window['maptaskrPCF'].off("AnnotationDrawingCompleted");
In the example above, the event listener for AnnotationDrawingCompleted
is removed, ensuring that the associated call-back function no longer executes when the event is triggered.
AnnotationDrawingCancelled
Description
The AnnotationDrawingCancelled
event is triggered when a user cancels the drawing of an annotation on a map using the Maptaskr for Power Pages App. This event provides information about the annotation's shape name.
Usage
To listen for the AnnotationDrawingCancelled
event, you can use the on
method of the window['maptaskrPCF']
object. This allows you to register an event listener that executes a call-back function when the event is triggered.
Example
window['maptaskrPCF'].on("AnnotationDrawingCancelled", function(shapeName) {
console.log("shapeName: " + shapeName);
});
In the example above, we've registered an event listener for the AnnotationDrawingCancelled
event. When the event occurs, the provided call-back function is executed, logging the name of the cancelled annotation to the console.
Parameters
shapeName
(string): The name or identifier of the cancelled annotation.
Removing Event Listeners
To remove the event listener for the AnnotationDrawingCancelled
event, you can use the off
method of the window['maptaskrPCF']
object. This is useful when you no longer want to listen to this specific event.
Example
window['maptaskrPCF'].off("AnnotationDrawingCancelled");
In the example above, the event listener for AnnotationDrawingCancelled
is removed, ensuring that the associated call-back function no longer executes when the event is triggered.
AnnotationDrawingModified
Description
The AnnotationDrawingModified
event is triggered when a previously drawn annotation is modified within the map application using the Maptaskr for Power Pages App. This event provides information about the modified annotation's name and its updated polygon geometry.
Usage
To listen for the AnnotationDrawingModified
event, you can use the on
method of the window['maptaskrPCF']
object. This allows you to register an event listener that executes a call-back function when the event is triggered.
Example
window['maptaskrPCF'].on("AnnotationDrawingModified", function(shapeName, polygon, oldText, newText) {
console.log("shapeName: " + shapeName);
console.log("polygon: " + polygon);
console.log("oldText: " + oldText);
console.log("newText: " + newText);
});
In the example above, we've registered an event listener for the AnnotationDrawingModified
event. When the event occurs, the provided call-back function is executed, logging the name of the modified annotation and its updated polygon geometry to the console.
Parameters
shapeName
(string): The name of the modified annotation.polygon
(string): The updated polygon geometry of the modified annotation.oldText
(string): The old text value of the modified annotation if it was a text annotation. If the annotation wasn't an annotation text or the text wasn't modified, this will return as undefined.newText
(string): The new text value of the modified annotation if it was a text annotation. If the annotation wasn't an annotation text or the text wasn't modified, this will return as undefined.
Response Example
The polygon
returned will be a JavaScript Object in the format provided below (with some properties excluded for brevity)
{
"extent": "10833324.643667039,-5565072.909537995,13167560.446239164,-4377598.300671361",
"geometry": {
"geometry":
"10962250.458343988,-4377598.300671361,10833324.643667039,-5422575.956473999,11864731.16108263,-5388648.110506381,12041155.960114244,-4771161.313895731,13167560.446239164,-5565072.909537995",
"type": "LineString"
},
"shapeSize": "Length: 3050.95 km",
"attributes": {
"ShapeSize": "Length: 3050.95 km",
"OldGeometry": [
[
10962250.458343988,
-4377598.300671361
],
[
10833324.643667039,
-5422575.956473999
],
[
11864731.16108263,
-5388648.110506381
],
[
12041155.960114244,
-4771161.313895731
],
[
11844374.453502059,
-3916179.5955117554
]
],
"ExclusionIntersecting": false
}
}
Removing Event Listeners
To remove the event listener for the AnnotationDrawingModified
event, you can use the off
method of the window['maptaskrPCF']
object. This is useful when you no longer want to listen to this specific event.
Example
window['maptaskrPCF'].off("AnnotationDrawingModified");
In the example above, the event listener for AnnotationDrawingModified
is removed, ensuring that the associated call-back function no longer executes when the event is triggered.
AnnotationDrawingDeleted
Description
The AnnotationDrawingDeleted
event is triggered when a user deletes a previously drawn annotation on a map using the Maptaskr for Power Pages App. This event provides information about the deleted annotation's shape name.
Usage
To listen for the AnnotationDrawingDeleted
event, you can use the on
method of the window['maptaskrPCF']
object. This allows you to register an event listener that executes a call-back function when the event is triggered.
Example
window['maptaskrPCF'].on("AnnotationDrawingDeleted", function(shapeName) {
console.log("shapeName: " + shapeName);
});
In the example above, we've registered an event listener for the AnnotationDrawingDeleted
event. When the event occurs, the provided call-back function is executed, logging the name of the deleted annotation to the console.
Parameters
shapeName
(string): The name or identifier of the deleted annotation.
Removing Event Listeners
To remove the event listener for the AnnotationDrawingDeleted
event, you can use the off
method of the window['maptaskrPCF']
object. This is useful when you no longer want to listen for this specific event.
Example
window['maptaskrPCF'].off("AnnotationDrawingDeleted");
In the example above, the event listener for AnnotationDrawingDeleted
is removed, ensuring that the associated call-back function no longer executes when the event is triggered.