Clustering markers on mapbox / leaflet

后端 未结 2 1787
眼角桃花
眼角桃花 2021-02-09 08:00

I\'m trying to set up a clustered map on mapbox, like http://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-realworld.388.html

But their example uses

2条回答
  •  时光取名叫无心
    2021-02-09 08:56

    Create a geoJson layer and then add that layer to MarkerCluster:

     var markers = new L.MarkerClusterGroup();
     var geoJsonFeature =  = {
      "type": "Feature",
      "properties": {
        "name": "Coors Field",
        "amenity": "Baseball Stadium",
        "popupContent": "This is where the Rockies play!"
      },
      "geometry": {
        "type": "Point",
        "coordinates": [-104.99404, 39.75621]
      }
     };
     var geoJsonLayer = L.geoJson(geoJsonFeature);
    
     markers.addLayer(geoJsonLayer);
     map.addLayer(markers);
    

提交回复
热议问题