I'd like MarkerCluster to work with InfoWindows for clusters of markers on the same coordinates. For example, if you have more than one markers at exactly the same coordinates that form a marker cluster, I'd want that marker cluster not to expand into separate markers when zoomed in since they would be at the same position. It should also be possible for these non-expandable marker clusters to be able to show InfoWindows/InfoBubbles containing the content of the individual markers (e.g. with a right click).

Comments

hutch’s picture

Category: feature » support

If you are a dab hand at javascript, you can set your site to use your own versions of the scripts that provide this functionality by setting the paths to the javascripts in admin/config/services/getlocations.

However my guess is that this will not work, Google provide the handler that manages clicking on a marker so that cannot be rewritten.

It would be far easier to move duplicate markers apart a little bit so that they can be clicked on or if you have a lot of duplicates write a function (running on a cronjob) to find them in the database and tweak the latitude/longitude so that the markers can be displayed in a useable manner.

bobek10’s picture

I'm not so good with javascript. This problem is widely known and discussed. For the GMap module it seem's that there is a solution at http://drupal.org/node/1139088, At this point I would like to use MarkerClustererPlus and move the markers randomly according to https://gist.github.com/1780787

// source : http://techxplorer.com/2010/02/05/managing-markers-with-the-same-coordin...
// get the coordinates
var hash = points[i].getAttribute("lat") + points[i].getAttribute("lng");
hash = hash.replace(".","").replace(",", "").replace("-","");
// source : http://techxplorer.com/2010/02/05/managing-markers-with-the-same-coordin...
// check to see if we've seen this hash before
if(coords[hash] == null) {
// get coordinate object
var latlng = new google.maps.LatLng(parseFloat(points[i].getAttribute("lat")), parseFloat(points[i].getAttribute("lng")));

// store an indicator that we've seen this point before
coords[hash] = 1;
} else {

// add some randomness to this point
var lat = parseFloat(points[i].getAttribute("lat")) + (Math.random() -.5) / 1500;
var lng = parseFloat(points[i].getAttribute("lng")) + (Math.random() -.5) / 1500;

// get the coordinate object
var latlng = new google.maps.LatLng(lat.toFixed(6), lng.toFixed(6));
}

but I do not know where exactly to put this. Please help.

The best solution would be to combine MarkerClustererPlus because of the dynamic clustering with ifobuble according to Martin Pearman's ClusterMarker-http://developer.martinpearman.co.uk/phpfusion7/infusions/google_my_maps... or like elsewhere http://stackoverflow.com/questions/9993484/creating-popup-box-for-marker... and move the markers at random.

Another idea would be to make a marker cluster multicolored according to content types (one marker cluster icon partitioned with different colors). I believe that if someone would be willing to do this then there would be people like myself willing to contribute with a sponsoring donation.

hutch’s picture

OK, I will look at idea No. 1. It looks doable although the Math.random method looks a bit arbitrary, we need a minimum distance away as well as a maximum.

I know Martin Pearman's work, its very good but all Googlemaps v2 which works very differently. Wether the functionality in it can be done in MarkerClustererPlus (which is what getlocations is using) remains to be seen.

As for idea No. 3 that would require the javascript to know about content-types which is not the case at the moment. It would probably require a complete rewrite of MarkerClustererPlus.

hutch’s picture

I have commited a fix of the duplicate markers problem to dev, please test.

bobek10’s picture

It seems to be working. Thank you!
I found http://www.x2x1.com/show/3548920.aspx with a description on how to add infowindows on a cluster. Also, anither thing someone might find useful is to re-position same-location-markers in circle. Another infowindow can be found at https://github.com/plank/MarkerClusterer

For idea 3, markercluster would definitely have to be rewriten and also use https://developers.google.com/fusiontables/

hutch’s picture

I'll have a look at the plank Markerclusterer.
Idea No. 3 is for someone with a lot of time on their hands.

hutch’s picture

The plank Markerclusterer does have infoWindows but it is much rougher than MarkerClustererPlus. It does not close infoWindows automatically if you open another and the zoom does not work as well.

bobek10’s picture

You are right, my mistake. MarkerClustererPlus is derived from MarkerClusterer which has InfoWindows, then MarkerClustererPlus cloud have them as well. There is also Clusterer2 which has InfoWindows.

hutch’s picture

MarkerClustererPlus has been updated with a new version, I will add it to the repository soon.
Perhaps you should ask the maintainer of MarkerClustererPlus, he is clearly active and might be willing to add Infowindows support.

hutch’s picture

Status: Active » Closed (works as designed)