I am placing multiple Clustered locations on the map. How can I retrieve number of total of featured returned?
Here is my code:
<script>
$.getJSON("datafile.json", function(data) {
var geojson = L.geoJson(data, {
onEachFeature: function (feature, layer) {
layer.setIcon(L.mapbox.marker.icon({'marker-symbol': 'circle-stroked', 'marker-color': '59245f'}));
var popUp="pouptext";
layer.bindPopup(popUp,{
closeButton: true,
minWidth: 320
});
}
});
markers.addLayer(geojson);
var map = L.mapbox.map('map', 'mapbox.streets') .setView([42, -90], 4);
baseLayer.addTo(map);
markers.addTo(map);
});
</script>
Thanks.
Assuming that datafile.json
contains a GeoJSON FeatureCollection, the number of features would be stored in the data.features.length
property.