Skip to content
This repository has been archived by the owner on Jun 16, 2019. It is now read-only.

Marker cluster using geojson #138

Open
ronak90 opened this issue Sep 11, 2017 · 3 comments
Open

Marker cluster using geojson #138

ronak90 opened this issue Sep 11, 2017 · 3 comments

Comments

@ronak90
Copy link

ronak90 commented Sep 11, 2017

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.

@Linuus
Copy link

Linuus commented Nov 7, 2017

I'm very much interested in this as well.

@404mike
Copy link

404mike commented Dec 19, 2017

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

@joenammour
Copy link

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 });

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants