fitBounds after creating map

495 views
Skip to first unread message

Nick Spacek

unread,
Oct 6, 2009, 8:42:21 AM10/6/09
to Google Maps JavaScript API v3
Hi there,

I found today that if I do:

var map = new google.maps.Map( /* blah */ );
map.fitBounds( someBounds );

I get a very zoomed out version of my map. Thought there was something
wrong with my bounds, but then I tried:

var map = new google.maps.Map( /* blah */ );
setTimeout( function() { map.fitBounds( someBounds ); }, 1 );

And it works fine. I get the same behavior in Firefox 3.5 and Chrome.
Anyone else run into this?

Dones

unread,
Oct 7, 2009, 12:16:49 PM10/7/09
to Google Maps JavaScript API v3
I think i had (and i have still now...) the same problem... You can
see some reply (that doesn't solve the problem)

http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/c9a45e8a302e54f1/eabce6917839d49b?lnk=gst&q=fitBounds#eabce6917839d49b

I'll try ur method with setTimeout function... Is it only a timeout of
1 (milli?)second before the call of the fitBounds function?

Nick Spacek

unread,
Oct 8, 2009, 1:54:07 PM10/8/09
to google-map...@googlegroups.com
On Wed, Oct 7, 2009 at 1:16 PM, Dones <manuel...@gmail.com> wrote:

I think i had (and i have still now...) the same problem... You can
see some reply (that doesn't solve the problem)

http://groups.google.com/group/google-maps-js-api-v3/browse_thread/thread/c9a45e8a302e54f1/eabce6917839d49b?lnk=gst&q=fitBounds#eabce6917839d49b

Hmm, could be, not sure I know exactly what's going on there. :)
 
I'll try ur method with setTimeout function... Is it only a timeout of
1 (milli?)second before the call of the fitBounds function?

Yup, that worked for me anyways. Kinda hacky though.

Nick
Reply all
Reply to author
Forward
0 new messages