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
var geojson = dataFromMapbox;
var lat;
var lng;
for(var i= 0;i<geojson.features.length;i++)
{
lat = geojson.features[i].geometry.coordinates[0];
lng = geojson.features[i].geometry.coordinates[1];
//create a marker with those values, pass it to a MarkerCluster object
}
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);