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
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.
▶ Properties inherited from 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.
▶ Properties inherited from 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.
▶ Properties inherited from Event
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).
▶ Properties inherited from Event
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.
▶ Properties inherited from Event
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.
▶ Properties inherited from Event
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.
▶ Properties inherited from Event
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.
▶ Properties inherited from Event
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.
▶ Properties inherited from 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).
▶ Properties inherited from Event
Property
Type
Description
type
String
The event type (e.g. 'click'
).
target
Object
The object that fired the event.
Property
Type
Description
▶ Properties inherited from Event
Property
Type
Description
Property
Type
Description
tooltip
Tooltip
The tooltip that was opened or closed.
▶ Properties inherited from Event
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.
▶ Properties inherited from Event
Property
Type
Description
type
String
The event type (e.g. 'click'
).
target
Object
The object that fired the event.