html鼠标悬停显示不同,如何在点击和鼠标悬停时显示不同的弹出窗口?

的SelectFeature方法在Control类提供添加和通过分别监听事件featureselected和featureunselected除去矢量层上的弹出窗口的方式。下面示出了从我an example在网站的OpenLayers获得的样品的代码:如何在点击和鼠标悬停时显示不同的弹出窗口?

// create the layer with listeners to create and destroy popups

var vector = new OpenLayers.Layer.Vector("Points",{

eventListeners:{

'featureselected':function(evt){

var feature = evt.feature;

var popup = new OpenLayers.Popup.FramedCloud("popup",

OpenLayers.LonLat.fromString(feature.geometry.toShortString()),

null,

"

Feature: " + feature.id +"
Foo:
",

null,

true

);

feature.popup = popup;

map.addPopup(popup);

},

'featureunselected':function(evt){

var feature = evt.feature;

map.removePopup(feature.popup);

feature.popup.destroy();

feature.popup = null;

}

}

});

vector.addFeatures(features);

// create the select feature control

var selector = new OpenLayers.Control.SelectFeature(vector,{

hover:true, # this line

autoActivate:true

});

上面的代码将允许在所述几何对象(在地图上的图标或标记物)上鼠标可显示的弹出。如果行hover:true被删除,弹出窗口将仅在鼠标点击几何对象时显示。

我想要的,是能够显示在鼠标悬停一种类型的弹出窗口(例如,图像加标题)和另一种类型(例如,详细描述)在鼠标点击。我不确定如何做到这一点。一些帮助将不胜感激。谢谢。

+0

我希望你能找到从这里的解决方案:http://www.openlayers.org/dev/examples/highlight-feature.html –

+0

@ user1702401,谢谢你的提示。我注意到该示例使用仅在版本2.13中提供的新事件侦听器。不能等待的稳定版本:) –

+0

如果你的意思是“beforefeaturehighlighted”,“featurehighlighted”和“featureunhighlighted”事件,那么那些已经存在了很长一段时间(2.11以来至少)。用2.12测试这个例子并且工作正常。 –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值