gstackoverflow
gstackoverflow

Reputation: 37034

How tweak bounds based on viewport on google maps?

I am trying to tweak map zoom for coordinates.

I want to extend bounds for all points inside viewport object.

I am trying to make it so:

bounds.extend(place.geometry.viewport)

But in debug I see that after this row execution bounds don't change.

What do I wrong?

Upvotes: 0

Views: 564

Answers (1)

geocodezip
geocodezip

Reputation: 161334

bounds.extend takes a google.maps.LatLng as its argument, not a google.maps.LatLngBounds object, which is what place.geometry.viewport (probably) is.

To "add" a google.maps.LatLngBounds to an existing bounds, use bounds.union

bounds.union(place.geometry.viewport);

Upvotes: 2

Related Questions