I have a problem with displaying Leaflet Marker Cluster working with Leaflet-layerJSON. There are markers, but I cannot show the clusters. This works with GeoJSON, but now I have different data structure and I'm not sure is it possible to show clusters with JSON (not GeoJSON) data structure:



Please take a look at the other (not working) example without angular leaflet directive.

1 Answer 1


You could simply use leaflet-layerJSON option layerTarget, it is specifically made for this case: it adds markers to another Layer Group (which can be a Marker Cluster Group) instead of to itself.

Note that you still need to add both the layerJSON and the MCG to the map, so that MCG displays clusters, and layerJSON receives map events for re-loading data.

var markers = L.markerClusterGroup().addTo(map);

    url: "clean.json",
    propertyLoc: ['latitude', 'longitude'],
    propertyTitle: 'name',
    caching: true,
    layerTarget: markers // Option layerTarget

Demo: http://plnkr.co/edit/vkJs0zkNaEYjLHLwYpMi?p=preview

Note: do not forget to set your map container height (and width if necessary), otherwise you will not see your map. Angular may be taking care of that for you if you are using Leaflet directive.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.