Geolocation: how to cluster overlapping markers?

When using Geolocation and displaying a large number of markers on a map, it should be possible to use the MarkerClusterer library in combination with the Google Maps JavaScript API to combine markers of close proximity into clusters, and simplify the display of markers on the map.
@adehner seems to have found where to add a line of code to have Geolocation use this function, but I could not figure out where the markercluster script should be loaded into my server, nor if it is necessary to download the

JavaScript library and image files for the MarkerClusterer are available in the Google Maps repo on GitHub.

The hell page specifies that these files can be copied to a “location accessible to your app”, but I have no clue where in Omeka’s folder structure this would fit…

Any help would be greatly valued.

It would be better to not edit core plugin files, but I did…
In GeolocationPlugin.php I added links to the JS files for both MarkerClusterer and Overlapping MarkerSpiderifier. Here’s a screenshot of my file:

In views/shared/javascripts/map.js (or your theme version of this file):
Update the fitMarkers function like so:

            fitMarkers: function () {
        if (this.markers.length == 1) {
            this.map.setCenter(this.markers[0].getPosition());
        } else {
            var markeroptions = {
            	imagePath: "/plugins/Geolocation/views/shared/images/m",
            	maxZoom:15
            };
            if (this.markers.length > 10) {
            	var markerCluster = new MarkerClusterer(this.map, this.markers, markeroptions);
            }
        
            this.map.fitBounds(this.markerBounds);
        }
    }

Then you need to upload the colored circle images (used for clusters) [https://github.com/googlemaps/v3-utility-library/tree/master/markerclusterer/images] to an image directory. You only need images m1-m5.png. It would be best to upload these to your theme, but you can see here (in the markeroptions variable) that I uploaded them to an image directory in the Geolocation plugin.

Incorporating Spiderifier requires more editing. But this should get MarkerClusterer set up. I hope this helps!

This topic was automatically closed after 250 days. New replies are no longer allowed.