Would it be possible have gmap zoom in on the area of clustered markers instead of showing a text list of the markers available?

For example, if a user was looking at a worldview map where five markers were in a cluster over Seattle, instead of bringing up a list of the items in the cluster when clicked, gmap could autozoom into the area (Downtown Seattle for example) showing the 5 markers.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Scott Falconer’s picture

Version: 6.x-1.x-dev » 5.x-1.x-dev

I can put up a cash bounty for this feature...anyone interested give me an idea on how long you'd think it take and we can figure out a price.

ray007’s picture

The popup-action for cluster markers is hardcoded in the Clusterer.js file (if we're talking about Jef's clusterer).
Maybe not trivial, but should be doable in 2 days work.

Scott Falconer’s picture

I was able to modify the Clusterer.PopUp function in clusterer2.js (based on another modification found here to get it to work as I needed. Thanks for pointing me in the right direction.

Works in OSX in Firefox and Safari. Haven't had a chance to test in IE.

Clusterer.PopUp = function ( cluster )
    {
	var clusterer = cluster.clusterer;

	if (clusterer.boundsDisplay)
		clusterer.map.removeOverlay(clusterer.boundsDisplay);
		
	var bounds = new GLatLngBounds();
	for (var k in cluster.markers)
		bounds.extend(cluster.markers[k].getPoint());

	var sw = bounds.getSouthWest();
	var ne = bounds.getNorthEast();
	var rect = [ sw,
		     new GLatLng(sw.lat(), ne.lng()),
		     ne,
		     new GLatLng(ne.lat(), sw.lng()),
                     sw
		   ];

	clusterer.boundsDisplay = new GPolyline(rect, "#FFFF33", 2, 0.8);
	clusterer.map.addOverlay(clusterer.boundsDisplay);
	clusterer.boundsDisplayOwner = cluster;


	var center = bounds.getCenter();
	var zoom = clusterer.map.getBoundsZoomLevel(bounds);

    clusterer.map.setCenter(new GLatLng(+center.lat(),+center.lng()),+zoom);

};
ray007’s picture

Thanks for sharing this code.

Changing the clusterer2.js script is of course the easy way, if you want to change the popup-action for cluster markers generally.
Maybe we should make a contrib-directory to save such hacks?

Making a configurable way to have different cluster-actions on demand is a bit more involved, but maybe that's not really needed.

marcoBauli’s picture

that works sweet, thanks! :)

bdragon’s picture

Status: Active » Fixed

Fixed as part of my work today on marker managers.

http://drupal.org/cvs?commit=171293
http://drupal.org/cvs?commit=171294

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

rares’s picture

Status: Closed (fixed) » Active
FileSize
31.13 KB
71.17 KB
90 KB

@bdragon, thanks for the amazing patch for this.
I have an issues to report with new implementation. If you think this should be a new issue (or two new issues), just mark this closed and I can post new issues. Just thought that there's already way too many issues in the queue.

I have: /* $Id: clusterer_marker.js,v 1.4 2009/02/12 23:45:23 bdragon Exp $ */
and am using Activate on 3 or more markers and Cluster on 3 or more markers.

The following behavior applies when I use the zoom-in behavior for clusterer.
- There are some zoom thresholds and marker layouts that make it difficult to see the markers when zoomed in. For instance, I have a cluster for New York and Boston, and when I click on it, I can't see Boston, because it is right in the top-right corner. See invisible.jpg
by changing line 85, the markers are easier to see.

var zoom = cluster.clusterer.map.getBoundsZoomLevel(bounds);
TO
var zoom = cluster.clusterer.map.getBoundsZoomLevel(bounds) - 1;

The second issue is that the markers that were in the initial cluster still have a cluster icon, and still behave as clusters. If I click on one of them, I get a zoom in to the street level for that single marker (see still clustered.jpg)

oranki42’s picture

Title: Zoom to cluster area » Zoom to cluster area, hi patched and merged several suggestions from here
Version: 5.x-1.x-dev » 6.x-1.0
Component: User interface » Miscellaneous
FileSize
2.19 KB

Hi,

I've written a patch for clusterer2.js with a new version of Clusterer.PopUp = function ( cluster ); Basically if you click on a cluster it now zooms until zoomlevel 17 is reached and then it starts listing the markers below. Some one would still need to add tabbing to it. But hey now it works al lot nicer. Together with the fix for the clusterer_marker.js to put the text not/the title in the popup it should work like a dream for most default drupal sites. Perhaps someone can create a patch or what you dev-guy's do?

david.a.king’s picture

I get a problem with this in IE (6,7,8) - clicking on a cluster which is set to zoom gives the following error:

Message: Object doesn't support this property or method

in this area:

for (var k in cluster.markers)
bounds.extend(cluster.markers[k].getPoint());

Currently bodging with an "if IE.." but i'd love to know if there's a way around it!

thanks,

david

eliosh’s picture

I'd like to follow this issue, but i don't know how to subscribe :-(

so....
subscribe...
:-D

Summit’s picture

Subscribe, greetings, Martijn

emudojo’s picture

subscribing