I have a GeoJSON file of fly tipping incidents that I have managed to display on a basic Leaflet map.
I am now trying to incorporate the marker cluster plugin, but I am having problems as it does not seem to be clustering the markers when zooming out.
My code is below, is there an obvious reason why it is not working? I am receiving no error messages.
(I followed the tutorial from http://maptimeboston.github.io/leaflet-intro/)
// initialize the map
var map = L.map('map').setView([51.394845, -0.538516], 12);
// load a tile layer
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
{
maxZoom: 17,
minZoom: 9
}).addTo(map);
// load GeoJSON from an external file
$.getJSON("data/incidents.geojson",function(data){
// add GeoJSON layer to the map once the file is loaded
var incidents = L.geoJson(data,{
pointToLayer: function(feature,latlng){
var marker = L.marker(latlng);
marker.bindPopup('Fly tip reported on ' + feature.properties.date_rec + '<br/>' + 'Reported waste type: ' + feature.properties.waste_type + '<br/>' + 'Located on land type: ' + feature.properties.land_type);
return marker;
}
});
var clusters = L.markerClusterGroup();
clusters.addLayer(incidents);
map.addLayer(clusters);
});