Methods
-
addListenerForLayer(layerId, eventType, listener) → {function}
-
Add a listener to the map concerning the layer
layerId. The listener should test whether the specific event is for the layer or not.Events will be fired from top to bottom (following pseudo-z-index) and only if the
originalEvent.cancelBubbleis falsy.Parameters:
Name Type Description layerIdstring the layer id.
eventTypestring the event type.
listenerfunction the listener which will be called with a mapbox event.
Returns:
function -a wrapped listener, original listener could be found in the
originalListenerproperty. -
fire(event) → {Map}
-
Fires an event of the specified type.
Respect the bubble effect.
Parameters:
Name Type Description eventobject event data
Returns:
Map -this
- See:
-
getListenersForLayer(layerId) → {object}
-
Get all (wrapped) listeners for the specified layer id.
Parameters:
Name Type Description layerIdstring the layer id
Returns:
object -object with all listeners as property.
Evented._listenersor empty object.- See:
-
off(type, layerIdOrListeneropt, layerListeneropt) → {Map}
-
Removes an event listener (eventually for layer-specific events) previously added with on method.
Parameters:
Name Type Attributes Default Description typestring one of the available types.
layerIdOrListenerstring | function <optional>
null A style layer id from which you want to remove the listener.
Otherwise, the listener to remove.
layerListenerfunction <optional>
null The listener to remove if not defined in the previous parameter.
Returns:
Map -this
-
on(type, layerIdOrListeneropt, layerListeneropt) → {Map}
-
Enhance
onmethod for registering an event.The following special map event
typecould be registerd:- mousedown
- mouseup
- click
- dblclick
- mousemove
- mouseenter / mouseover: the cursor enters a visible portion of the specified layer from outside that layer or outside the map canvas.
- mouseleave: the cursor leaves a visible portion of the specified layer or leaves the map canvas.
- mouseout: the cursor leaves the map canvas.
- contextmenu
- touchstart
- touchend
- touchcancel
Events will be fired from top to bottom (following the bubble effect) and only if the
originalEventcan propagate (bubblesgetter is falsy orstopPropagationhas not been called on it).Parameters:
Name Type Attributes Default Description typestring one of the available types.
layerIdOrListenerstring | function <optional>
null A style layer id if you want to restrict events to the visible features of a layer.
Otherwise, a listener which takes a mapboxgl event as argument.
The event object has three more properties:
originalEvent: the DOM eventtarget: the DOM targettype: the event type
layerListenerfunction <optional>
null The listener if not defined in the previous parameter.
Returns:
Map -this
-
removeListenerFromLayer(layerId, eventType, listener)
-
Remove a listener from a layer. The listener could be a real or a wrapper listener.
Parameters:
Name Type Description layerIdstring the layer id corresponding to the listener.
eventTypestring the event type.
listenerfunction the listener to remove.