googlearchive/js-marker-clusterer

Marker cluster using geojson

ronak90 opened this issue · 3 comments

Is there any way to implement marker cluster using geojson data layer? This JS supports only those markers which are created by google.maps.Marker objects.

I'm very much interested in this as well.

map.data.loadGeoJson('locate.json' + param, null, function(features) {
    
    // group items / cluster
    var markers = features.map(function(feature) {
        var g = feature.getGeometry();

        var marker = new google.maps.Marker({
            'position': g.get(0),
            'data' : feature
        });

        return marker;
    });

    // create a new marker cluster
    var markerCluster = new MarkerClusterer(map, markers, {
        imagePath: 'https://cdn.rawgit.com/googlemaps/js-marker-clusterer/gh-pages/images/m',
        gridSize: 15, 
        zoomOnClick: false
    });

    // add event listener to the cluster
    google.maps.event.addListener(markerCluster, 'clusterclick', function (cluster) {
     // handle clickevent
    });

});

https://googlemaps.github.io/js-marker-clusterer/docs/reference.html

Hi Everyone, for some reason this did not work for me but if I added this as as style then it worked. I wanted to mention it just in case it helps anyone else because it was driving me crazy.

map.data.setStyle({ visible: false });