【问题标题】:How can I show popup and the details of the marker in mapboxgl cluster?如何在 mapboxgl 集群中显示弹出窗口和标记的详细信息?
【发布时间】:2017-12-09 23:09:59
【问题描述】:

我尝试了以下链接example

我想在集群上添加弹出窗口并将所有集群数据显示为 HTML。我可以看到弹出窗口,但在弹出内容中未定义。

map.on('click', 'cluster', function (e) {
    let description = "";

    for(let i = 0; i < e.features.length; i++) {
      description = description + e.features[i].properties.description;
      if(i != e.features.length - 1) {
          description = description + "</br>";
      }
    }

    new mapboxgl.Popup()
      .setLngLat(e.features[0].geometry.coordinates)
      .setHTML(description )
      .addTo(map);

  });

【问题讨论】:

    标签: mapbox mapbox-gl-js mapbox-gl mapbox-marker


    【解决方案1】:

    在这里找到的解决方案: https://stackoverflow.com/a/47715517

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

    【讨论】:

      猜你喜欢
      • 2014-06-19
      • 2014-02-04
      • 1970-01-01
      • 1970-01-01
      • 2021-12-29
      • 2018-03-11
      • 2018-04-04
      • 2016-03-14
      • 2017-05-16
      相关资源
      最近更新 更多