我有一个infoBox,当点击谷歌地图标记时打开。在infoBox里面有一个按钮'#open-popup',点击时应该打开一个magnificPopup模式窗口,但没有任何反应。Magnific-popup无法打开从谷歌地图infoBox中的按钮
作为一项测试,我已经把相同的按钮放在包含谷歌地图的div外面,该地图打开模式窗口,但仅在第二次点击!到底是怎么回事?
我已经尝试了几天的所有事情,但都有最坏的副作用。
任何帮助将不胜感激。
HTML的按钮内的信息框:
<button id="open-popup">Open popup</button>
<div id="my-popup" class="mfp-hide white-popup">Inline popup</div>
JS:
<div style=...>
<centre>
<button id="open-popup">Open popup</button>
<div id="my-popup" class="mfp-hide white-popup">Inline popup</div>
</center>
</div>
以外谷歌地图的div HTML的按钮
myapp.triggerClick = function(){
google.maps.event.trigger(gmarkers[id],"click")
};
var infoboxOptions = {
content: ''
,disableAutoPan: false
,alignBottom: true
,maxWidth: 0
,pixelOffset: new google.maps.Size(0, 0)
,zIndex: 1000
,boxStyle: {
background:''
,opacity: 0.9
}
,closeBoxMargin: "4px 4px 0 0"
,closeBoxURL: "http://www.google.com/intl/en_us/mapfiles/close.gif"
,infoBoxClearance: new google.maps.Size(1,1)
,isHidden: false
,pane: "floatPane"
,enableEventPropagation: false
};
var ib = new InfoBox(infoboxOptions);
function createMarker(latlng, html, id) {
var contentString = html;
var marker = new google.maps.Marker({
position: latlng,
map: map
//zIndex: Math.round(latlng.lat()*-100000)<<5
});
google.maps.event.addListener(marker, 'click', function() {
ib.setContent(contentString);
ib.open(map,marker);
});
gmarkers[id] = marker;
}
$(document).on('click', '#open-popup', function() {
$(this).magnificPopup({
items: {
src: 'http://upload.wikimedia.org/wikipedia/commons/thumb/6/64/Peter_%26_Paul_fortress_in_SPB_03.jpg/800px-Peter_%26_Paul_fortress_in_SPB_03.jpg'
},
type: 'image' // this is default type
});
});
谢谢,它的工作......现在弹出窗口只打开一秒钟,并进一步点击。首次点击不适用于每个信息框。 –
@asier_js设置一个JSFiddle或Plunker,我会看看。 – GFoley83
非常感谢GFoley83在这里。 http://jsfiddle.net/asier_adq/hgYXG/ –