我正在尝试创建一个保持打开的弹出窗口,直到我点击右上角的x将其关闭。做这个的最好方式是什么?我的代码在下面,谢谢!
//pop up code
//create custom icon
var newicon = L.icon({
iconUrl: 'logo.png',
})
// creating marker
var marker = L.marker(new L.LatLng(41.77, -87.6), {
icon: L.mapbox.marker.icon({
'marker-color': 'ff8888'
}),
icon: newicon,
draggable: true,
}).addTo(map);
// bind popup to marker
marker.bindPopup("I am a text that will stay open until closed").openPopup();
答案 0 :(得分:0)
使用:
foreach (range(1, 100) as $x) {
foreach (range(1, 9) as $y) {
$html = get_data('http://mysite.info/screenshots/'.$x.'-'.$y.'.jpeg' );
}
}
答案 1 :(得分:0)
新解决方案,旧解决方案似乎无效:
var new_popup = L.popup({"autoClose": false, "closeOnClick": null});
marker.bindPopup(new_popup);
答案 2 :(得分:0)
要打开弹出窗口,您需要在 L.map() 中指定 closePopupsOnClick: false 以便默认情况下不会关闭弹出窗口
L.map('地图', { ... closePopupOnClick: 假 }
然后,对于您想要关闭的单个弹出窗口,您可以在 click() 中关闭它们
map.on('popupopen', function (e) {
//save e.popup to an array or something
}
map.on('click', () => {
//close the popups you want to by calling map.closePopup(popup);
});