Oleg Dats
Oleg Dats

Reputation: 4133

How to set viewport property in google maps MapOptions v3

I'm using google.maps.Geocoder to get viewport. Then I want to create google.maps.Map so the map will fit this viewport. There is a method fitBounds. It works perfectly. But it's better to specify viewport in constructor. I can't find this option in MapOptions

Upvotes: 2

Views: 3703

Answers (1)

Marcelo
Marcelo

Reputation: 9407

There is no way to set it in the constructor, other than by calculating an exact map width, heighth and zoom level, but zoom levels are discrete values, so it might not be the exact fit that you want.

If you create the map and apply map.fitBounds() immediately after that, it all happens so fast that it is perfectly transparent to the user.

Upvotes: 2

Related Questions