Layer

继承Evented

所有图层类的父类。


示例

//创建图层对象添加到地图上

var latlng = W.latLng(39.908719,116.390879);
var layer = W.marker(latlng).addTo(map);

方法

方法 返回值 描述
addTo(< Map > type) this 将图层添加到地图中
remove() this 从地图中移除图层

气泡方法

所有继承自Layer的子类都继承绑定气泡信息方法。气泡为地图弹出窗口的形象说法。

//图层对象绑定气泡

var layer = W.marker(latlng).bindPopup('气泡信息').addTo(map);
layer.openPopup();
layer.closePopup();
方法 返回值 描述
bindPopup (< String / HTMLElement / Function /Popup > content, options?) this 绑定一个气泡
unbindPopup() this 取消气泡绑定
openPopup() this 打开气泡
closePopup() this 关闭气泡
isPopupOpen() this 气泡是否打开
setPopupContent(< String / HTMLElement / Popup > content) this 修改气泡内容

提示信息方法

//所有继承自Layer的子类都继承绑定提示信息方法

var layer = W.marker(latlng).bindTooltip('提示信息').addTo(map);
layer.openTooltip();
layer.closeTooltip();
方法 返回值 描述
bindTooltip( content, options?) this 绑定提示信息
unbindTooltip() this 取消提示信息绑定
openTooltip( latlng?) this 打开提示信息
closeTooltip() this 关闭提示信息}
isTooltipOpen() boolean 获取提示信息打开还是关闭状态
setTooltipContent( content) this 设置提示信息内容

事件

事件名称 数据 描述
add Event 图层添加到地图
remove Event 图层从地图上移除

气泡事件

事件名称 回调数据 描述
popupopen PopupEvent 当气泡打开时触发
popupclose PopupEvent 当气泡关闭时触发

提示信息事件

事件名称 回调数据 描述
tooltipopen TooltipEvent 当提示信息打开时触发
tooltipclose TooltipEvent 当提示信息关闭时触发

results matching ""

    No results matching ""