10
votes

What the difference between viewport and bounds rects in google geocoding api?

For big countries (USA, Russia) viewport differs from bounds (sample request for Canada: http://maps.googleapis.com/maps/api/geocode/xml?address=Canada&sensor=false, but for smaller countries, regions and cities they are equal.

2

2 Answers

5
votes

I think that if the viewport and the bounds are not the same for big countries is just because they can not be display with the default zoom. So the bounds are correct for the current view but the whole country will not be displayed.

For the viewport, it's just the minimum bound to display the whole country.

Hope i answer your question.

21
votes

Viewport contains the recommended viewport for displaying the returned result, specified as two latitude, longitude values defining the southwest and northeast corner of the viewport bounding box. Generally the viewport is used to frame a result when displaying it to a user.

Bounds stores the bounding box which can fully contain the returned result. Note that these bounds may not match the recommended viewport. (For example, San Francisco includes the Farallon islands, which are technically part of the city, but probably should not be returned in the viewport)

For more info: https://developers.google.com/maps/documentation/geocoding/intro#Results