Handler to respond to mouse events related to a drawn feature. Callbacks with the following keys will be notified of the following events associated with features: click, clickout, over, out, and dblclick.
This handler stops event propagation for mousedown and mouseup if those browser events target features that can be selected.
ALKMaps. | Handler to respond to mouse events related to a drawn feature. |
Properties | |
EVENTMAP | {Object} A object mapping the browser events to objects with callback keys for in and out. |
feature | {ALKMaps.Feature.Vector} The last feature that was hovered. |
lastFeature | {ALKMaps.Feature.Vector} The last feature that was handled. |
down | {ALKMaps.Pixel} The location of the last mousedown. |
up | {ALKMaps.Pixel} The location of the last mouseup. |
touch | {Boolean} When a touchstart event is fired, touch will be true and all mouse related listeners will do nothing. |
clickTolerance | {Number} The number of pixels the mouse can move between mousedown and mouseup for the event to still be considered a click. |
geometryTypes | To restrict dragging to a limited set of geometry types, send a list of strings corresponding to the geometry class names. |
featureAttributesFilter | {Object} To restrict matching feature by comparing feature attributes. |
stopClick | {Boolean} If stopClick is set to true, handled clicks do not propagate to other click listeners. |
stopDown | {Boolean} If stopDown is set to true, handled mousedowns do not propagate to other mousedown listeners. |
stopUp | {Boolean} If stopUp is set to true, handled mouseups do not propagate to other mouseup listeners. |
alwaysTrigger | {Boolean} If alwaysTrigger is set to true, event listener callbacks will always be triggered even after event propagation is stopped by an outside listener. |
Constructor | |
ALKMaps. | |
Functions | |
touchstart | Handle touchstart events |
touchmove | Handle touchmove events. |
mousedown | Handle mouse down. |
mouseup | Handle mouse up. |
click | Handle click. |
mousemove | Handle mouse moves. |
dblclick | Handle dblclick. |
rightclick | Handle rightclick. |
geometryTypeMatches | Return true if the geometry type of the passed feature matches one of the geometry types in the geometryTypes array. |
handle | |
triggerCallback | Call the callback keyed in the event map with the supplied arguments. |
activate | Turn on the handler. |
deactivate | Turn off the handler. |
handleMapEvents | |
moveLayerToTop | Moves the layer for this handler to the top, so mouse events can reach it. |
moveLayerBack | Moves the layer back to the position determined by the map’s layers array. |
register | override handler’s prototype register function to allow for “always” priority to be set. |
{ALKMaps.Feature.Vector} The last feature that was hovered.
{ALKMaps.Feature.Vector} The last feature that was handled.
{ALKMaps.Pixel} The location of the last mousedown.
{ALKMaps.Pixel} The location of the last mouseup.
control | {ALKMaps.Control} |
layer | {ALKMaps.Layer.Vector} |
callbacks | {Object} An object with a ‘over’ property whos value is a function to be called when the mouse is over a feature. The callback should expect to receive a single argument, the feature. |
options | {Object} |
geometryTypeMatches: function( feature )
Return true if the geometry type of the passed feature matches one of the geometry types in the geometryTypes array. If featureAttributesFilter is provided, it will be used to narrow down the match.
feature | {<ALKMaps.Vector.Feature>} |
{Boolean}
triggerCallback: function( type, mode, args )
Call the callback keyed in the event map with the supplied arguments. For click and clickout, the clickTolerance is checked first.
type | {String} |
Handle touchstart events
touchstart: function( evt )
Handle touchmove events.
touchmove: function( evt )
Handle mouse down.
mousedown: function( evt )
Handle mouse up.
mouseup: function( evt )
Handle click.
click: function( evt )
Handle mouse moves.
mousemove: function( evt )
Handle dblclick.
dblclick: function( evt )
Handle rightclick.
rightclick: function ( evt )
Return true if the geometry type of the passed feature matches one of the geometry types in the geometryTypes array.
geometryTypeMatches: function( feature )
handle: function( evt )
Call the callback keyed in the event map with the supplied arguments.
triggerCallback: function( type, mode, args )
Turn on the handler.
activate: function()
Turn off the handler.
deactivate: function()
handleMapEvents: function( evt )
Moves the layer for this handler to the top, so mouse events can reach it.
moveLayerToTop: function()
Moves the layer back to the position determined by the map’s layers array.
moveLayerBack: function()
override handler’s prototype register function to allow for “always” priority to be set.
register: function ( name, method )