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:
每当从Evented继承的类触发事件时,将使用事件参数调用侦听器函数,该参数是包含事件信息的纯对象。例如:
map.on('click' , function (ev ) {
alert(ev.latlng);
});
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. For propagated events, the last object in the propagation chain that fired the event.
引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。
sourceTarget
Object
The object that originally fired the event. For non-propagated events, this will be the same as the target.
最初激发事件的对象。对于未传播的事件,这将与目标相同。
propagatedFrom
Object
For propagated events, the last object that propagated the event to its event parent.
对于传播的事件,将事件传播到其事件父级的最后一个对象。
layer
Object
Deprecated. The same as propagatedFrom.
已弃用。与propagatedFrom相同。
KeyboardEvent
Property
Type
Description
originalEvent
DOMEvent
The original DOM KeyboardEvent that triggered this Leaflet event.
触发此传单事件的原始DOM KeyboardEvent。
▶ Properties inherited from Event
从事件继承的属性
Property
Type
Description
type
String
The event type (e.g. 'click').
事件类型(例如“单击”)。
target
Object
The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.
引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。
sourceTarget
Object
The object that originally fired the event. For non-propagated events, this will be the same as the target.
最初激发事件的对象。对于未传播的事件,这将与目标相同。
propagatedFrom
Object
For propagated events, the last object that propagated the event to its event parent.
对于传播的事件,将事件传播到其事件父级的最后一个对象。
layer
Object
Deprecated. The same as propagatedFrom.
已弃用。与propagatedFrom相同。
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
DOMEvent
The original DOM MouseEvent or DOM TouchEvent that triggered this Leaflet event.
触发此传单事件的原始DOM MouseEvent或DOM TouchEvent。
▶ Properties inherited from Event
从事件继承的属性
Property
Type
Description
type
String
The event type (e.g. 'click').
事件类型(例如“单击”)。
target
Object
The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.
引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。
sourceTarget
Object
The object that originally fired the event. For non-propagated events, this will be the same as the target.
最初激发事件的对象。对于未传播的事件,这将与目标相同。
propagatedFrom
Object
For propagated events, the last object that propagated the event to its event parent.
对于传播的事件,将事件传播到其事件父级的最后一个对象。
layer
Object
Deprecated. The same as propagatedFrom.
已弃用。与propagatedFrom相同。
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.
WGS84椭球上方位置的高度,单位为米。
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. For propagated events, the last object in the propagation chain that fired the event.
引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。
sourceTarget
Object
The object that originally fired the event. For non-propagated events, this will be the same as the target.
最初激发事件的对象。对于未传播的事件,这将与目标相同。
propagatedFrom
Object
For propagated events, the last object that propagated the event to its event parent.
对于传播的事件,将事件传播到其事件父级的最后一个对象。
layer
Object
Deprecated. The same as propagatedFrom.
已弃用。与propagatedFrom相同。
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. For propagated events, the last object in the propagation chain that fired the event.
引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。
sourceTarget
Object
The object that originally fired the event. For non-propagated events, this will be the same as the target.
最初激发事件的对象。对于未传播的事件,这将与目标相同。
propagatedFrom
Object
For propagated events, the last object that propagated the event to its event parent.
对于传播的事件,将事件传播到其事件父级的最后一个对象。
layer
Object
Deprecated. The same as propagatedFrom.
已弃用。与propagatedFrom相同。
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. For propagated events, the last object in the propagation chain that fired the event.
引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。
sourceTarget
Object
The object that originally fired the event. For non-propagated events, this will be the same as the target.
最初激发事件的对象。对于未传播的事件,这将与目标相同。
propagatedFrom
Object
For propagated events, the last object that propagated the event to its event parent.
对于传播的事件,将事件传播到其事件父级的最后一个对象。
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. For propagated events, the last object in the propagation chain that fired the event.
引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。
sourceTarget
Object
The object that originally fired the event. For non-propagated events, this will be the same as the target.
最初激发事件的对象。对于未传播的事件,这将与目标相同。
propagatedFrom
Object
For propagated events, the last object that propagated the event to its event parent.
对于传播的事件,将事件传播到其事件父级的最后一个对象。
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.
使用平铺的x、y和z(缩放级别)坐标指向对象。
▶ Properties inherited from Event
从事件继承的属性
Property
Type
Description
type
String
The event type (e.g. 'click').
事件类型(例如“单击”)。
target
Object
The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.
引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。
sourceTarget
Object
The object that originally fired the event. For non-propagated events, this will be the same as the target.
最初激发事件的对象。对于未传播的事件,这将与目标相同。
propagatedFrom
Object
For propagated events, the last object that propagated the event to its event parent.
对于传播的事件,将事件传播到其事件父级的最后一个对象。
layer
Object
Deprecated. The same as propagatedFrom.
已弃用。与propagatedFrom相同。
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.
使用平铺的x、y和z(缩放级别)坐标指向对象。
error
*
Error passed to the tile’s done() callback.
传递给磁贴的done()回调的错误。
▶ Properties inherited from Event
从事件继承的属性
Property
Type
Description
type
String
The event type (e.g. 'click').
事件类型(例如“单击”)。
target
Object
The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.
引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。
sourceTarget
Object
The object that originally fired the event. For non-propagated events, this will be the same as the target.
最初激发事件的对象。对于未传播的事件,这将与目标相同。
propagatedFrom
Object
For propagated events, the last object that propagated the event to its event parent.
对于传播的事件,将事件传播到其事件父级的最后一个对象。
layer
Object
Deprecated. The same as propagatedFrom.
已弃用。与propagatedFrom相同。
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. For propagated events, the last object in the propagation chain that fired the event.
引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。
sourceTarget
Object
The object that originally fired the event. For non-propagated events, this will be the same as the target.
最初激发事件的对象。对于未传播的事件,这将与目标相同。
propagatedFrom
Object
For propagated events, the last object that propagated the event to its event parent.
对于传播的事件,将事件传播到其事件父级的最后一个对象。
layer
Object
Deprecated. The same as propagatedFrom.
已弃用。与propagatedFrom相同。
GeoJSONEvent
Property
Type
Description
layer
Layer
The layer for the GeoJSON feature that is being added to the map.
正在添加到地图中的GeoJSON功能的图层。
properties
Object
GeoJSON properties of the feature.
功能的GeoJSON属性。
geometryType
String
GeoJSON geometry type of the feature.
功能的GeoJSON几何类型。
id
String
GeoJSON ID of the feature (if present).
功能的GeoJSON ID(如果存在)。
▶ Properties inherited from Event
从事件继承的属性
Property
Type
Description
type
String
The event type (e.g. 'click').
事件类型(例如“单击”)。
target
Object
The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.
引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。
sourceTarget
Object
The object that originally fired the event. For non-propagated events, this will be the same as the target.
最初激发事件的对象。对于未传播的事件,这将与目标相同。
propagatedFrom
Object
For propagated events, the last object that propagated the event to its event parent.
对于传播的事件,将事件传播到其事件父级的最后一个对象。
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. For propagated events, the last object in the propagation chain that fired the event.
引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。
sourceTarget
Object
The object that originally fired the event. For non-propagated events, this will be the same as the target.
最初激发事件的对象。对于未传播的事件,这将与目标相同。
propagatedFrom
Object
For propagated events, the last object that propagated the event to its event parent.
对于传播的事件,将事件传播到其事件父级的最后一个对象。
layer
Object
Deprecated. The same as propagatedFrom.
已弃用。与propagatedFrom相同。
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. For propagated events, the last object in the propagation chain that fired the event.
引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。
sourceTarget
Object
The object that originally fired the event. For non-propagated events, this will be the same as the target.
最初激发事件的对象。对于未传播的事件,这将与目标相同。
propagatedFrom
Object
For propagated events, the last object that propagated the event to its event parent.
对于传播的事件,将事件传播到其事件父级的最后一个对象。
layer
Object
Deprecated. The same as propagatedFrom.
已弃用。与propagatedFrom相同。
ZoomAnimEvent
Property
Type
Description
center
LatLng
The current center of the map
地图的当前中心
zoom
Number
The current zoom level of the map
地图的当前缩放级别
noUpdate
Boolean
Whether layers should update their contents due to this event
层是否应因此事件更新其内容
▶ Properties inherited from Event
从事件继承的属性
Property
Type
Description
type
String
The event type (e.g. 'click').
事件类型(例如“单击”)。
target
Object
The object that fired the event. For propagated events, the last object in the propagation chain that fired the event.
引发事件的对象。对于传播的事件,传播链中激发事件的最后一个对象。
sourceTarget
Object
The object that originally fired the event. For non-propagated events, this will be the same as the target.
最初激发事件的对象。对于未传播的事件,这将与目标相同。
propagatedFrom
Object
For propagated events, the last object that propagated the event to its event parent.
对于传播的事件,将事件传播到其事件父级的最后一个对象。
layer
Object
Deprecated. The same as propagatedFrom.
已弃用。与propagatedFrom相同。