Geolocation plugin and Google maps marker clustering

55 views
Skip to first unread message

Anneliese Dehner

unread,
Oct 5, 2016, 12:18:01 PM10/5/16
to Omeka Dev
I'm trying to use the MarkerCluster library with the Geolocation plugin. Specifically, I would like to add clusters to the public browse view of the map (views/public/map/browse.php).

The problem is I can't figure out where to add the clusterer so I can reference the markers:
var markerCluster = new MarkerClusterer(map, markers);

I've tried lots of things including appending it to $js at the end of helpers/GoogleMap.php, but nothing I try works.

What am I missing? I appreciate any suggestions you have.

Thanks,
Anneliese

Anneliese Dehner

unread,
Oct 5, 2016, 4:22:38 PM10/5/16
to Omeka Dev
Ah ha! Got it.

In case anyone else out there wants to try this. 
Add the markercluster script.
In Geolocation/views/shared/javascripts/map.js, modify fitMarkers: function in OmekaMap.prototype to look like the code below (additions are highlighted)

fitMarkers: function () {
        if (this.markers.length == 1) {
            this.map.setCenter(this.markers[0].getPosition());
            
        } else {
            this.map.fitBounds(this.markerBounds);
            var markeroptions = {
        };
            var markerCluster = new MarkerClusterer(this.map, this.markers, markeroptions);
        }
    }
Reply all
Reply to author
Forward
0 new messages