I've read many issues related to autozoom and the fact that it is showing at maximum level when there is only one marker, i.e. in location node block.
In gmap_marker.js (i.e. with no marker manager) when autozoom is enabled, it is setting the zoom level by calling to map.getBoundsZoomLevel() which is returning the zoom level at which the given rectangular region fits in the map view
.
When there is only one marker to show, that rectangular region
is only one point, so it is returning the maximum zoom level.
The GMap's configuration page says that, autozoom automatically zoom the map to fit all markers when markers are added
, but I think that it should only zoom out the map to fit all markers when the zoom level selected with the corresponding macro (or default) is not enough to show all markers.
So, here is my fix for gmap_marker.js:
Before:
obj.map.setCenter(obj.bounds.getCenter(),obj.map.getBoundsZoomLevel(obj.bounds));
After:
// Zoom out to fit all markers, if needed
if (obj.map.getBoundsZoomLevel(obj.bounds) < obj.map.getZoom()) {
obj.map.setCenter(obj.bounds.getCenter(),obj.map.getBoundsZoomLevel(obj.bounds));
}
else {
obj.map.setCenter(obj.bounds.getCenter());
}
jpereza.
Comments
Comment #1
ultimikeInteresting point. I can see arguments for having the autozoom work either way...
Regardless, I tried your patch and it looks good to me (Firefox 2, OS X).
-mike
Comment #2
rbl commentedAt last! Works for me! It was either not centering or showing everything at street level.
Thanks!
Ricardo
Comment #3
twooten commentedSweeeeet! Works great jpereza, thanks a million.
Comment #4
bdragon commentedFixed this in a more flexible way in -dev by actually adding a setting.
http://drupal.org/cvs?commit=113786
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.