Event objects

Whenever a class inheriting from Evented fires an event, a listener function will be called with an event argument, which is a plain object containing information about the event. For example:

map.on('click', function(ev) {
    alert(ev.latlng); // ev is an event object (MouseEvent in this case)
});

The information available depends on the event type:

Event

The base event object. All other event objects contain these properties too.
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event.

KeyboardEvent

Property Type Description
originalEvent DOMEvent The original DOM KeyboardEvent that triggered this Leaflet event.
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event.

MouseEvent

Property Type Description
latlng LatLng The geographical point where the mouse event occured.
layerPoint Point Pixel coordinates of the point where the mouse event occured relative to the map layer.
containerPoint Point Pixel coordinates of the point where the mouse event occured relative to the map сontainer.
originalEvent DOMEvent The original DOM MouseEvent or DOM TouchEvent that triggered this Leaflet event.
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event.

LocationEvent

Property Type Description
latlng LatLng Detected geographical location of the user.
bounds LatLngBounds Geographical bounds of the area user is located in (with respect to the accuracy of location).
accuracy Number Accuracy of location in meters.
altitude Number Height of the position above the WGS84 ellipsoid in meters.
altitudeAccuracy Number Accuracy of altitude in meters.
heading Number The direction of travel in degrees counting clockwise from true North.
speed Number Current velocity in meters per second.
timestamp Number The time when the position was acquired.
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event.

ErrorEvent

Property Type Description
message String Error message.
code Number Error code (if applicable).
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event.

LayerEvent

Property Type Description
layer Layer The layer that was added or removed.
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event.

LayersControlEvent

Property Type Description
layer Layer The layer that was added or removed.
name String The name of the layer that was added or removed.
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event.

TileEvent

Property Type Description
tile HTMLElement The tile element (image).
coords Point Point object with the tile's x, y, and z (zoom level) coordinates.
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event.

TileErrorEvent

Property Type Description
tile HTMLElement The tile element (image).
coords Point Point object with the tile's x, y, and z (zoom level) coordinates.
error * Error passed to the tile's done() callback.
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event.

ResizeEvent

Property Type Description
oldSize Point The old size before resize event.
newSize Point The new size after the resize event.
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event.

GeoJSONEvent

Property Type Description
layer Layer The layer for the GeoJSON feature that is being added to the map.
properties Object GeoJSON properties of the feature.
geometryType String GeoJSON geometry type of the feature.
id String GeoJSON ID of the feature (if present).
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event.

PopupEvent

Property Type Description
popup Popup The popup that was opened or closed.
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event.

TooltipEvent

Property Type Description
tooltip Tooltip The tooltip that was opened or closed.
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event.

DragEndEvent

Property Type Description
distance Number The distance in pixels the draggable element was moved by.
Property Type Description
type String The event type (e.g. 'click').
target Object The object that fired the event.
v1.1.0
Props Wrld.Prop
Themes Wrld.themes
Heatmaps Wrld.Heatmap
Events Event objects
Services (Optional) WrldPoiApi