I'm trying to set up a clustered map on mapbox, like http://leaflet.github.io/Leaflet.markercluster/example/marker-clustering-realworld.388.html
Currently, my point data are being pulled from MYSQL and converted into GeoJson using GeoPHP. The map.
I would like to know if there is a way to use MarkerCluster plugin with my GeoJson file, called mysql_points_geojson.php in code below:
// Bike Racks
var bikeRacksIcon = L.icon({
iconUrl: 'bicycleparking.png',
iconSize: [24, 28],
iconAnchor: [12, 28],
popupAnchor: [0, -25]
});
bikeRacks = new L.geoJson(null, {
pointToLayer: function (feature, latlng) {
return L.marker(latlng, {
icon: bikeRacksIcon,
title: feature.properties.city
});
},
onEachFeature: function (feature, layer) {
if (feature.properties) {
var content = '<table border="0" style="border-collapse:collapse;" cellpadding="2">' +
'<tr>' + '<th>City</th>' + '<td>' + feature.properties.city + '</td>' + '</tr>' +
'<tr>' + '<th>Country</th>' + '<td>' + feature.properties.country + '</td>' + '</tr>' +
'<table>';
layer.bindPopup(content);
}
}
});
$.getJSON("mysql_points_geojson.php", function (data) {
bikeRacks.addData(data);
}).complete(function () {
map.fitBounds(bikeRacks.getBounds());
});