-
Notifications
You must be signed in to change notification settings - Fork 19
Event Handlers
Objects in the ESRI Javascript API use Dojo on
events to indicate when important things happen. As we do not want the Dojo library to be exposed outside of geoApi
, we provide a mechanism for a user to register event handlers that will get triggered when the Dojo events happen.
Event handlers are assigned to a handler definition object (examples below) and passed into the geoApi
to be registered against the Dojo events. All handlers are optional. Some event arguments are modified from the original dojo event arguments to either abstract specific API implementations or to make code more readable.
TODO link to function that perform the handler registration (events.wrapEvents).
If more events are required, contact your friendly developer.
Native click event. The same event argument will be passed to the handler function.
Occurs when the user clicks the mouse on the map. Clicking a feature on a feature layer will not trigger the map click event.
Native extent-change event. The same event argument will be passed to the handler function.
Occurs when the map extent changes.
Native pan-start event. The same event argument will be passed to the handler function.
Occurs when the map pan begins.
Native pan-end event. The same event argument will be passed to the handler function.
Occurs when the map pan ends.
Native update-start event. Has no event argument
Occurs when the map begins to update its data.
Native update-end event. The same event argument will be passed to the handler function.
Occurs when the map finishes updating its data.
Native zoom-start event. The same event argument will be passed to the handler function.
Occurs when the map zoom begins.
Native zoom-end event. The same event argument will be passed to the handler function.
Occurs when the map zoom ends.
Native click event. The same event argument will be passed to the handler function.
Occurs when the user clicks the mouse on a feature of a feature layer. This event will not trigger on other layer types (a map click event will happen).
Native error event. Property layer
will be added to the event argument pointing to the layer that errored.
Occurs when an error happens during layer processes.
Native load event. The same event argument will be passed to the handler function.
Occurs when an error happens during layer processes.
Native mouse-out event. The same event argument will be passed to the handler function.
Occurs when the the mouse leaves a feature of a feature layer. This event will not trigger on other layer types.
Native mouse-over event. The same event argument will be passed to the handler function.
Occurs when the the mouse goes onto a feature of a feature layer. This event will not trigger on other layer types.
Native update-end event. Property layer
will be added to the event argument pointing to the layer that finished updating.
Occurs when a layer finishes updating its data.
Native update-start event. Property layer
will be added to the event argument pointing to the layer that started updating.
Occurs when a layer starts updating its data.
The <fn>
placeholders denote where a caller would assign the custom handler functions to be called when the native dojo events occur. All handlers are optional.
{
map: {
click: <fn>,
extentChange: <fn>,
panEnd: <fn>,
panStart: <fn>,
updateEnd: <fn>,
updateStart: <fn>,
zoomEnd: <fn>,
zoomStart: <fn>
},
layer: {
click: <fn>,
error: <fn>,
load: <fn>,
mouseOut: <fn>,
mouseOver: <fn>,
updateEnd: <fn>,
updateStart: <fn>
}
}
//log the map point that was clicked
function mapClickHandler(evt) {
console.log('Map clicked at screen co-ords');
console.log(evt.screenPoint.x.toString() + ', ' + evt.screenPoint.y.toString());
}
//make object that defines handler to trigger on the on the map.click event
let eventHandlers = {
map: {
click: mapClickHandler
}
};
//make the geoApi register our handlers for the map
geoApi.events.wrapEvents(myMap, eventHandlers.map);