Leaflet.markercluster integration #117
-
Hi! Has anyone had any success integrating Leaflet.markercluster and if so could you please share how you did so, or give some pointers? I've read all of the documentation and am completely stuck! Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
As a note, should be achievable with the FAQ: How can I add another Leaflet Plugin (https://github.com/bozdoz/wp-plugin-leaflet-map#how-can-i-add-another-leaflet-plugin). I think marker cluster was used before maybe a few years back. Might have some examples in the WP Forum |
Beta Was this translation helpful? Give feedback.
-
I have never made any progress with this either. I would find it super if that would work just with the integration of KML, GPX, or Json files, because you can include many POIs. Thanks for the tip, I'll see if I can find something there. |
Beta Was this translation helpful? Give feedback.
-
After much toil I'm pleased to say that I have finally got this working using the method outlined by Ben in his FAQ "How can I add another Leaflet Plugin" and the following javascript. Hope it comes in handy and thank you once again Ben for your great plugin. (function () {
function main() {
if (!window.WPLeafletMapPlugin) { console.log('no plugin found!'); return; }
var geojsons = window.WPLeafletMapPlugin.geojsons;
for (var i = 0, len = geojsons.length; i < len; i++) {
var geojson = geojsons[i];
geojson.addEventListener('ready', function (e) {
var cluster = L.markerClusterGroup();
cluster.addLayer(e.sourceTarget.layer);
e.sourceTarget.map.addLayer(cluster).removeLayer(e.sourceTarget.layer);
});
}
}
window.addEventListener('load', main);
})(); |
Beta Was this translation helpful? Give feedback.
After much toil I'm pleased to say that I have finally got this working using the method outlined by Ben in his FAQ "How can I add another Leaflet Plugin" and the following javascript. Hope it comes in handy and thank you once again Ben for your great plugin.