1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
@namespace 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:
```js
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:
@miniclass Event (Event objects)
@section
The base event object. All other event objects contain these properties too.
@property type: String
The event type (e.g. `'click'`).
@property target: Object
The object that fired the event. For propagated events, the last object in
the propagation chain that fired the event.
@property sourceTarget: Object
The object that originally fired the event. For non-propagated events, this will
be the same as the `target`.
@property propagatedFrom: Object
For propagated events, the last object that propagated the event to its
event parent.
@property layer: Object
**Deprecated.** The same as `propagatedFrom`.
@miniclass KeyboardEvent (Event objects)
@inherits Event
@property originalEvent: DOMEvent
The original [DOM `KeyboardEvent`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent) that triggered this Leaflet event.
@miniclass MouseEvent (Event objects)
@inherits Event
@property latlng: LatLng
The geographical point where the mouse event occured.
@property layerPoint: Point
Pixel coordinates of the point where the mouse event occured relative to the map layer.
@property containerPoint: Point
Pixel coordinates of the point where the mouse event occured relative to the map сontainer.
@property originalEvent: DOMEvent
The original [DOM `MouseEvent`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent) or [DOM `TouchEvent`](https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent) that triggered this Leaflet event.
@miniclass LocationEvent (Event objects)
@inherits Event
@property latlng: LatLng
Detected geographical location of the user.
@property bounds: LatLngBounds
Geographical bounds of the area user is located in (with respect to the accuracy of location).
@property accuracy: Number
Accuracy of location in meters.
@property altitude: Number
Height of the position above the WGS84 ellipsoid in meters.
@property altitudeAccuracy: Number
Accuracy of altitude in meters.
@property heading: Number
The direction of travel in degrees counting clockwise from true North.
@property speed: Number
Current velocity in meters per second.
@property timestamp: Number
The time when the position was acquired.
@miniclass ErrorEvent (Event objects)
@inherits Event
@property message: String
Error message.
@property code: Number
Error code (if applicable).
@miniclass LayerEvent (Event objects)
@inherits Event
@property layer: Layer
The layer that was added or removed.
@miniclass LayersControlEvent (Event objects)
@inherits Event
@property layer: Layer
The layer that was added or removed.
@property name: String
The name of the layer that was added or removed.
@miniclass TileEvent (Event objects)
@inherits Event
@property tile: HTMLElement
The tile element (image).
@property coords: Point
Point object with the tile's `x`, `y`, and `z` (zoom level) coordinates.
@miniclass TileErrorEvent (Event objects)
@inherits Event
@property tile: HTMLElement
The tile element (image).
@property coords: Point
Point object with the tile's `x`, `y`, and `z` (zoom level) coordinates.
@property error: *
Error passed to the tile's `done()` callback.
@miniclass ResizeEvent (Event objects)
@inherits Event
@property oldSize: Point
The old size before resize event.
@property newSize: Point
The new size after the resize event.
@miniclass GeoJSONEvent (Event objects)
@inherits Event
@property layer: Layer
The layer for the GeoJSON feature that is being added to the map.
@property properties: Object
GeoJSON properties of the feature.
@property geometryType: String
GeoJSON geometry type of the feature.
@property id: String
GeoJSON ID of the feature (if present).
@miniclass PopupEvent (Event objects)
@inherits Event
@property popup: Popup
The popup that was opened or closed.
@miniclass TooltipEvent (Event objects)
@inherits Event
@property tooltip: Tooltip
The tooltip that was opened or closed.
@miniclass DragEndEvent (Event objects)
@inherits Event
@property distance: Number
The distance in pixels the draggable element was moved by.
@miniclass ZoomAnimEvent (Event objects)
@inherits Event
@property center: LatLng; The current center of the map
@property zoom: Number; The current zoom level of the map
@property noUpdate: Boolean; Whether layers should update their contents due to this event
|