googlearchive / js-info-bubble

A library for customizable CSS3 InfoWindows in the Google Maps JavaScript API v3

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

autopan centres clicked marker rather than moving map just enough for infobubble to be visible

gigmaps opened this issue · comments

Under the current infobubble.js code the 'autoPan' feature is very basic - simply centering the selected / clicked marker, rather than moving the map just enough to make the infobubble visible.

Compare the following jsfiddles :

  1. Using the standard google.maps.InfoWindow() - http://jsfiddle.net/goredwards/3r7r1zkq/
  2. Using the current infobubble.js code - http://jsfiddle.net/goredwards/v9934fqm/

...you may have to move the map to have the marker near the edge to see the autopan effects.

The part of the code that's problematic is the panToView() function which contains code to
effectively centre the map on the selected pin.

This might be fine for very small maps, but on larger maps is completely unnecessary and frankly has an annoying effect that can't be useful in many circumstances.

Was there a plan to update this part of the code to be more in line with the far superior performance of the standard google.maps.InfoWindow() autoPan feature ?

PR #14 updates infobubble autopan (which really only centres the map on the clicked marker) to bring it inline with (ahead of ?) the standard google.maps.InfoWindow() autopan functionality:

  • map is only panned enough for the infobubble window to be visible with an edge margin - as per
  • adds an autopanMargin option to set the margin between the map edge and the infobubble window (with default = 10px)

see updated code working here: http://jsfiddle.net/goredwards/2cs4puaz/
...feel free to modify the autopanMargin: 15 option in the infobubble definition to see how the margin works (you can even put a -ve margin)

I know that this repository is unmaintained but autopanMargin seems like a very useful option -
does anyone know if there are plans to incorporate such an option in the main Google Maps InfoWindowOptions object?

I'm seeing an excessive amount of left margin and would love to be able to minimize that:

image

Thanks.