Leaflet Map DivOverlay—地图DivOverlay

Leaflet Map DivOverlay—地图DivOverlay

L.Popup 和 L.Tooltip 的基本模型。从它继承自定义覆盖,如插件。

Options

OptionTypeDefaultDescription
interactiveBooleanfalseIf true, the popup/tooltip will listen to the mouse events.
如果为真,弹出/工具提示将监听鼠标事件。
offsetPointPoint(0, 0)The offset of the overlay position.
叠加位置的偏移量。
classNameString''A custom CSS class name to assign to the overlay.
要分配给叠加层的自定义 CSS 类名称。
paneStringundefinedMap pane where the overlay will be added.
将添加叠加层的地图窗格。

▶ Options inherited from Interactive layer 从交互层继承的选项

OptionTypeDefaultDescription
bubblingMouseEventsBooleantrueWhen true, a mouse event on this layer will trigger the same event on the map (unless L.DomEvent.stopPropagation is used).
如果为 true,此图层上的鼠标事件将触发地图上的相同事件(除非使用 L.DomEvent.stopPropagation)。

▶ Options inherited from Layer 从图层继承的选项

OptionTypeDefaultDescription
attributionStringnullString to be shown in the attribution control, e.g. “© OpenStreetMap contributors”. It describes the layer data and is often a legal obligation towards copyright holders and tile providers.
要在归因控件中显示的字符串,例如“© OpenStreetMap 贡献者”。它描述了图层数据,并且通常是对版权所有者和切片提供者的法律义务。

Events

DivOverlay events DivOverlay 事件

EventDataDescription
contentupdateEventFired when the content of the overlay is updated
当覆盖的内容更新时触发

▶ Mouse events inherited from Interactive layer

EventDataDescription
clickMouseEventFired when the user clicks (or taps) the layer.
当用户单击(或点击)图层时触发。
dblclickMouseEventFired when the user double-clicks (or double-taps) the layer.
当用户双击(或双击)图层时触发。
mousedownMouseEventFired when the user pushes the mouse button on the layer.
当用户在图层上按下鼠标按钮时触发。
mouseupMouseEventFired when the user releases the mouse button pushed on the layer.
当用户释放在图层上按下的鼠标按钮时触发。
mouseoverMouseEventFired when the mouse enters the layer.
当鼠标进入图层时触发。
mouseoutMouseEventFired when the mouse leaves the layer.
当鼠标离开图层时触发。
contextmenuMouseEventFired when the user right-clicks on the layer, prevents default browser context menu from showing if there are listeners on this event. Also fired on mobile when the user holds a single touch for a second (also called long press).
当用户右键单击图层时触发,防止默认浏览器上下文菜单显示此事件是否有侦听器。当用户按住单次触摸一秒钟(也称为长按)时,也会在移动设备上触发。

▶ Events inherited from Layer

EventDataDescription
addEventFired after the layer is added to a map
在图层添加到地图后触发
removeEventFired after the layer is removed from a map
从地图中移除图层后触发

▶ Popup events inherited from Layer

EventDataDescription
popupopenPopupEventFired when a popup bound to this layer is opened
打开绑定到该层的弹出窗口时触发
popupclosePopupEventFired when a popup bound to this layer is closed
当绑定到该层的弹出窗口关闭时触发

▶ Tooltip events inherited from Layer

EventDataDescription
tooltipopenTooltipEventFired when a tooltip bound to this layer is opened.
打开绑定到此图层的工具提示时触发。
tooltipcloseTooltipEventFired when a tooltip bound to this layer is closed
当绑定到该层的工具提示关闭时触发

Methods 方法

MethodReturnsDescription
openOn(<Mapmap)thisAdds the overlay to the map. Alternative to map.openPopup(popup)/.openTooltip(tooltip).
将叠加层添加到地图。替代 map.openPopup(popup)/.openTooltip(tooltip)。
close()thisCloses the overlay. Alternative to map.closePopup(popup)/.closeTooltip(tooltip) and layer.closePopup()/.closeTooltip().
关闭覆盖。替代 map.closePopup(popup)/.closeTooltip(tooltip) 和 layer.closePopup()/.closeTooltip()
toggle(<Layerlayer?)thisOpens or closes the overlay bound to layer depending on its current state. Argument may be omitted only for overlay bound to layer. Alternative to layer.togglePopup()/.toggleTooltip().
根据当前状态打开或关闭绑定到图层的叠加层。仅对于绑定到图层的叠加层,可以省略参数。替代 layer.togglePopup()/.toggleTooltip()。
getLatLng()LatLngReturns the geographical point of the overlay.
返回覆盖的地理点。
setLatLng(<LatLnglatlng)thisSets the geographical point where the overlay will open.
设置覆盖将打开的地理点。
getContent()String|HTMLElementReturns the content of the overlay.
返回叠加层的内容。
setContent(<String|HTMLElement|Function> htmlContent)thisSets the HTML content of the overlay. If a function is passed the source layer will be passed to the function. The function should return a String or HTMLElement to be used in the overlay.
设置叠加层的 HTML 内容。如果传递了一个函数,则源层将传递给该函数。该函数应返回要在叠加层中使用的字符串或 HTMLElement。
getElement()String|HTMLElementReturns the HTML container of the overlay.
返回叠加层的 HTML 容器。
update()nullUpdates the overlay content, layout and position. Useful for updating the overlay after something inside changed, e.g. image loaded.
更新覆盖内容、布局和位置。用于在内部发生更改后更新叠加层,例如图像加载。
isOpen()BooleanReturns true when the overlay is visible on the map.
当叠加层在地图上可见时返回 true。
bringToFront()thisBrings this overlay in front of other overlays (in the same map pane).
将此叠加层置于其他叠加层之前(在同一地图窗格中)。
bringToBack()thisBrings this overlay to the back of other overlays (in the same map pane).
将此叠加层置于其他叠加层的后面(在同一地图窗格中)。

▶ Popup methods inherited from Layer

MethodReturnsDescription
bindPopup(<String|HTMLElement|Function|Popup> content, <Popup optionsoptions?)thisBinds a popup to the layer with the passed content and sets up the necessary event listeners. If a Function is passed it will receive the layer as the first argument and should return a String or HTMLElement.
unbindPopup()thisRemoves the popup previously bound with bindPopup.
openPopup(<LatLnglatlng?)thisOpens the bound popup at the specified latlng or at the default popup anchor if no latlng is passed.
closePopup()thisCloses the popup bound to this layer if it is open.
togglePopup()thisOpens or closes the popup bound to this layer depending on its current state.
isPopupOpen()booleanReturns true if the popup bound to this layer is currently open.
setPopupContent(<String|HTMLElement|Popup> content)thisSets the content of the popup bound to this layer.
getPopup()PopupReturns the popup bound to this layer.

▶ Tooltip methods inherited from Layer 从图层继承的工具提示方法

MethodReturnsDescription
bindTooltip(<String|HTMLElement|Function|Tooltip> content, <Tooltip optionsoptions?)thisBinds a tooltip to the layer with the passed content and sets up the necessary event listeners. If a Function is passed it will receive the layer as the first argument and should return a String or HTMLElement.
使用传递的内容将工具提示绑定到图层并设置必要的事件侦听器。如果传递了一个函数,它将接收图层作为第一个参数,并应返回一个字符串或 HTMLElement。
unbindTooltip()thisRemoves the tooltip previously bound with bindTooltip.
移除之前与 bindTooltip 绑定的工具提示。
openTooltip(<LatLnglatlng?)thisOpens the bound tooltip at the specified latlng or at the default tooltip anchor if no latlng is passed.
如果未传递任何 latlng,则在指定的 latlng 或默认的工具提示锚点处打开绑定的工具提示。
closeTooltip()thisCloses the tooltip bound to this layer if it is open.
如果此图层打开,则关闭绑定到此图层的工具提示。
toggleTooltip()thisOpens or closes the tooltip bound to this layer depending on its current state.
根据其当前状态打开或关闭绑定到此图层的工具提示。
isTooltipOpen()booleanReturns true if the tooltip bound to this layer is currently open.
如果绑定到此图层的工具提示当前打开,则返回 true。
setTooltipContent(<String|HTMLElement|Tooltip> content)thisSets the content of the tooltip bound to this layer.
设置绑定到该图层的工具提示的内容。
getTooltip()TooltipReturns the tooltip bound to this layer.
返回绑定到该图层的工具提示。

▶ Methods inherited from Evented 继承自 Evented 的方法

MethodReturnsDescription
on(<String> type, <Function> fn, <Object> context?)thisAdds a listener function (fn) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. 'click dblclick').
将侦听器函数 (fn) 添加到对象的特定事件类型。您可以选择指定侦听器的上下文(this 关键字将指向的对象)。您还可以传递几种以空格分隔的类型(例如“click dblclick”)。
on(<Object> eventMap)thisAdds a set of type/listener pairs, e.g. {click: onClick, mousemove: onMouseMove}
添加一组类型/侦听器对,例如{点击:onClick,鼠标移动:onMouseMove}
off(<String> type, <Function> fn?, <Object> context?)thisRemoves a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to on, you must pass the same context to off in order to remove the listener.
删除以前添加的侦听器函数。如果未指定函数,它将从对象中删除该特定事件的所有侦听器。请注意,如果您将自定义上下文传递给 on,则必须将相同的上下文传递给 off 才能移除侦听器。
off(<Object> eventMap)thisRemoves a set of type/listener pairs.
删除一组类型/侦听器对。
off()thisRemoves all listeners to all events on the object. This includes implicitly attached events.
删除对象上所有事件的所有侦听器。这包括隐式附加事件。
fire(<String> type, <Object> data?, <Boolean> propagate?)thisFires an event of the specified type. You can optionally provide a data object — the first argument of the listener function will contain its properties. The event can optionally be propagated to event parents.
触发指定类型的事件。您可以选择提供一个数据对象——侦听器函数的第一个参数将包含其属性。可以选择将事件传播到事件父级。
listens(<String> type, <Boolean> propagate?)BooleanReturns true if a particular event type has any listeners attached to it. The verification can optionally be propagated, it will return true if parents have the listener attached to it.
如果特定事件类型附加了任何侦听器,则返回 true。验证可以选择传播,如果父母有监听器附加到它,它将返回 true。
once()thisBehaves as on(…), except the listener will only get fired once and then removed.
表现为 on(…),除了监听器只会被触发一次然后被移除。
addEventParent(<Eventedobj)thisAdds an event parent – an Evented that will receive propagated events
添加事件父级 – 将接收传播事件的事件
removeEventParent(<Eventedobj)thisRemoves an event parent, so it will stop receiving propagated events
删除事件父级,因此它将停止接收传播的事件
addEventListener()thisAlias to on(…) on(…) 的别名
removeEventListener()thisAlias to off(…)
clearAllEventListeners()thisAlias to off()
addOneTimeEventListener()thisAlias to once(…)
fireEvent()thisAlias to fire(…)
hasEventListeners()BooleanAlias to listens(…)
0 0 投票数
文章评分
订阅评论
提醒
0 评论
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x