2016-08-15 78 views
0

Map`這樣打開的傳單標記多個彈出窗口:我怎麼能在一個時間

L.Map = L.Map.extend({ 
openPopup: function(popup) { 
this._popup = popup; 
     return this.addLayer(popup).fire('popupopen', { 
      popup: this._popup 
     }); 
    } 
}); 

但是我使用單張。反正有這樣的程度,以便我可以防止關閉我的標記彈出?

L.mapbox.accessToken = constant.accessToken; 
var map = L.mapbox.map('map', 'mapbox.streets', {zoomControl: true}); 

回答

3

我引述Leaflet documentation on L.Popup

用於打開地圖的某些地方彈出。使用Map.openPopup打開彈出窗口,同時確保一次只打開一個彈出窗口(建議可用性),或使用Map.addLayer打開任意多的窗口。

爲了打開幾個彈出窗口,使用L.popup(latlng, options),然後.addTo(map)來實例化它們。

0

更新2017年12月 傳單popup選項已經被擴展到包括{ autoClose: false }具有所需的效果:

var my_marker = L.marker([my_lat, my_lng], {icon: my_icon}) 
        .addTo(map) 
        .bindPopup('My Popup HTML', {closeOnClick: false, autoClose: false});