我目前正在设计一个广泛使用 openlayers 的网站。 map 上放置了各种矢量标记,当用户单击标记时会出现一个弹出窗口。在此弹出窗口中,有一些已为灯箱设置的图像。唯一的问题是,当单击缩略图时,图像会在新窗口中打开(即 Lightbox 没有识别链接的事件)。灯箱的 html 非常好,因为我已经在弹出窗口之外对其进行了测试。
我想让灯箱在弹出窗口中工作,任何帮助将不胜感激。
这是我的代码:
弹出窗口创建:
function onFeatureSelect(feature) {
selectedFeature = feature;
popup = new OpenLayers.Popup.AnchoredBubble("PopUp",
feature.geometry.getBounds().getCenterLonLat(),
null,
null,
null, true, onPopupClose);
popup.setContentHTML('<div><a href="large_image.png" rel="lightbox"><img src="thumb_image.png" /></a></div>');
feature.popup = popup;
map.addPopup(popup);
}
摘自
Lightbox.js
关于点击收听:updateImageList: function() {
this.updateImageList = Prototype.emptyFunction;
document.observe('click', (function(event){
var target = event.findElement('a[rel^=lightbox]') || event.findElement('area[rel^=lightbox]');
if (target) {
event.stop();
this.start(target);
}
}).bind(this));
},
谢谢阅读。任何帮助将不胜感激。
最佳答案
虽然我从来没有用 Lightbox 解决过这个问题,但切换到 Lightbox2.js为我解决了这个问题。
关于javascript - OpenLayers 弹出窗口中的灯箱画廊,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14335165/