【问题标题】:How can I Open Multiple Popups in Leaflet Marker at a time如何一次在 Leaflet Marker 中打开多个弹出窗口
【发布时间】:2016-08-15 14:58:06
【问题描述】:

像这样的地图:

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});

【问题讨论】:

    标签: leaflet mapbox leaflet.markercluster


    【解决方案1】:

    2017 年 12 月更新 Leaflet 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});
    

    【讨论】:

      【解决方案2】:

      让我引用Leaflet documentation on L.Popup

      用于在地图的某些地方打开弹出窗口。使用Map.openPopup 打开弹出窗口,同时确保一次只打开一个弹出窗口(建议使用方便),或使用Map.addLayer 打开任意数量的窗口。

      要打开多个弹出窗口,请使用L.popup(latlng, options) 实例化它们,然后使用.addTo(map) 它们。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2022-12-01
        • 1970-01-01
        • 1970-01-01
        • 2014-10-07
        • 2012-12-12
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多