Event objects
Event object is an object that you receive as an argument in a listener function when some event is fired, containing useful information about that event. For example:
map.on('click', function(e) {
alert(e.latlng); // e is an event object (MouseEvent in this case)
});
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. |
MouseEvent
property |
type |
description |
latlng |
LatLng |
The geographical point where the mouse event occurred. |
layerPoint |
Point |
Pixel coordinates of the point where the mouse event occurred relative to the map layer. |
containerPoint |
Point |
Pixel coordinates of the point where the mouse event occurred relative to the map сontainer. |
originalEvent |
DOMMouseEvent |
The original DOM mouse event fired by the browser. |
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. |
ErrorEvent
property |
type |
description |
message |
String |
Error message. |
code |
Number |
Error code (if applicable). |
LayerEvent
property |
type |
description |
layer |
ILayer |
The layer that was added or removed. |
LayersControlEvent
property |
type |
description |
layer |
ILayer |
The layer that was added or removed. |
name |
String |
The name of the layer that was added or removed. |
TileEvent
property |
type |
description |
tile |
HTMLElement |
The tile element (image). |
url |
String |
The source URL of the tile. |
TileErrorEvent
property |
type |
description |
tile |
HTMLElement |
The tile element (image). |
url |
String |
The src attribute of the tile element. |
ResizeEvent
property |
type |
description |
oldSize |
Point |
The old size before resize event. |
newSize |
Point |
The new size after the resize event. |
GeoJSON event
property |
type |
description |
layer |
ILayer |
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 |
popup |
Popup |
The popup that was opened or closed. |
DragEndEvent
property |
type |
description |
distance |
Number |
The distance in pixels the draggable element was moved by. |