The autozoom currently sets the zoom so that all the points are within the area of the displayed map. But if there is a point located at the very top of the map, the marker extends above the top of the map and can't be seen.

Suggested solution is to add a margin around the points so the zoom is always set leaving enough room to show the markers.

So in gmap_marker.js replace:

obj.map.setCenter(obj.bounds.getCenter(),obj.map.getBoundsZoomLevel(obj.bounds));

with

      var SW = obj.bounds.getSouthWest();
      var NE = obj.bounds.getNorthEast();
      var height = NE.lat() - SW.lat();
      var width = NE.lng() - SW.lng();
      // Set a 5% margin for left, right, and bottom, but 10% margin for top as markers are tall and need extra space
      var marginBounds = new GLatLngBounds(new GLatLng(SW.lat() - 0.05*height, SW.lng() - 0.05*width), new GLatLng(NE.lat() + 0.10*height, NE.lng() + 0.05*width) );
      obj.map.setCenter(marginBounds.getCenter(),obj.map.getBoundsZoomLevel(marginBounds));
CommentFileSizeAuthor
#1 gmap-243985.patch1.2 KBtobiassjosten

Comments

tobiassjosten’s picture

StatusFileSize
new1.2 KB

This also applies to the 6.x branch, but since it didn't seem any good to duplicate it, I'll add my input here. mrb's solution works great and so I have taken the liberty of rolling a patch of the changes.

Note that this patch is for the 6.x branch!

dpatte’s picture

was looking for this. Thanks!

dustin bons’s picture

Also works for 7.x branch

podarok’s picture

Status: Active » Closed (won't fix)

release unsupported
feel free to open issue against latest 7.x dev