Leaflet 地图开发–Leaflet Map Control—用于实现映射控件的基类

Leaflet 地图开发–Leaflet Map Control—用于实现映射控件的基类

L.Control is a base class for implementing map controls. Handles positioning. All other controls extend from this class.

L.Control是用于实现映射控件的基类。手柄定位。所有其他控件都从该类扩展。

Options

Option Type Default Description
position String 'topright' The position of the control (one of the map corners). Possible values are 'topleft''topright''bottomleft' or 'bottomright'

控件的位置(地图角之一)。可能的值为“topleft”、“topright”、“bottomleft”或“bottomright”

Methods

Classes extending L.Control will inherit the following methods:
扩展L.Control的类将继承以下方法:
Method Returns Description
getPosition() string Returns the position of the control.

返回控件的位置。

setPosition(<string> position) this Sets the position of the control.

设置控件的位置。

getContainer() HTMLElement Returns the HTMLElement that contains the control.

返回包含控件的HTMLElement。

addTo(<Mapmap) this Adds the control to the given map.

将控件添加到给定的映射。

remove() this Removes the control from the map it is currently active on.

从当前处于活动状态的贴图中删除控件。

Extension methods

扩展方法

Every control should extend from L.Control and (re-)implement the following methods.
每项控制都应从L.control扩展,并(重新)实施以下方法。
Method Returns Description
onAdd(<Mapmap) HTMLElement Should return the container DOM element for the control and add listeners on relevant map events. Called on control.addTo(map).

应返回控件的容器DOM元素,并在相关映射事件上添加侦听器。在control.addTo(map)上调用。

onRemove(<Mapmap) Optional method. Should contain all clean up code that removes the listeners previously added in onAdd. Called on control.remove().

可选方法。应该包含删除之前在onAdd中添加的侦听器的所有清理代码。对control.remove()调用。

5 1 投票
文章评分
订阅评论
提醒
0 评论
内联反馈
查看所有评论
0
希望看到您的想法,请您发表评论x