3

我尝试了以下链接示例

我想在集群上添加弹出窗口并将所有集群数据显示为 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);

  });
4

1 回答 1

0

在这里找到解决方案: 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})**
于 2018-11-29T16:46:26.710 回答