I am currently in the process of setting up a clustered map on mapbox, similar to the example shown here:
At the moment, my point data is being extracted from MYSQL and then converted into GeoJson using GeoPHP. You can view the current map setup here.
I was wondering if there is a way for me to integrate the MarkerCluster plugin with my GeoJson file, which is named mysql_points_geojson.php in the code snippet 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());
});