Tooltip

在地图上显示小文本信息。一般和标签一起使用,也可以单独使用。


示例

//Marker显示提示信息

var marker = W.marker(latlng).bindTooltip('提示信息').addTo(map);
marker.openTooltip();

//Marker显示提示信息另外一种写法,通过定义Tooltip对象,可以更好的控制提示信息样式

var tooltip = W.tooltip({offset:new W.Point(0,-8),direction:'top',permanent:true});
            tooltip.setContent("提示信息");

 var marker = W.marker([39.908719,116.790879]).bindTooltip(tooltip).addTo(map);
            marker.openTooltip();

构造函数

方法 描述
W.tooltip( options?, source?) options可设置外观、位置。 可选的souce 用来指定相关的图层

构造选项

选项 类型 默认值 描述
offset Point Point(0, 0) 提示位置偏移量
direction String 'auto' 提示的方向,可选参数:right, left, top, bottom, center, auto
permanent Boolean false 值为ture,提示信息一直打开;值为false,鼠标移到才打开,鼠标移开关闭
opacity Number 0.9 透明度

方法

方法 返回值 描述
addTo( map) this 添加到地图或图层组
remove() this 从当前活动层移除
removeFrom( map this 从指定层移除
setContent(< String / HTMLElement / Function > htmlContent) this 设置提示信息内容

results matching ""

    No results matching ""