Zoom, fitBounds

52 views
Skip to first unread message

Erich

unread,
Jan 26, 2010, 2:44:55 PM1/26/10
to Google Maps JavaScript API v3
Hi,
while Map.fitBounds is obviously useful, I see two shortcomings with
it:

1. Margin for floats
It's nice to be able to fit all the coordinates to the screen, but
depending on the information I have surrounding them - which may be in
pixels, not in latlng, so I can't add it to the bounds - they might
then still not actuall fit completely. For this it would be useful to
be able to specify such a required padding to the fitToBounds function
(e.g. if my markers are 15 pixels in each direction, a 15 pixel margin
would be sufficient).

2. no control about max/min zoom (-increase).
As reported in
http://code.google.com/p/gmaps-api-issues/issues/detail?id=2122
(Sorry, I should probably have posted here first, then reported?)
there are use cases where one wants to know the optimal zoom level,
but NOT automatically set it. In my particular case, I'd like to have
a maximum zoom increase of 3 or 4 levels with each click. With the old
API, where I would just get the target value, this was easier.
I havn't tried the hack of doing "oldZoom = map.getZoom();
map.fitBounds(bounds); newZoom = map.getZoom(); map.setZoom(myValue)".

(A similar hack should be possible for #1, by essentially zooming in,
comparing the bounds screen positions with the canvas size, and
eventually zooming out one step again...)

3. (also applies to v2): are zoom levels considered stable? So if I
deem a particular zoom level to be high enough, should I use it as max
zoom for e.g. autozooming clicked objects?

Reply all
Reply to author
Forward
0 new messages