google-places-api

Google Places API's search results with huge viewports


I have been trying out Google's new Places API. It's "Places Search" returns a list of places close to the latitude/longitude you provide. Each of the results has its actual lat/lang, and some also have "viewports", which are supposed to be the bounding boxes of larger places like stadiums and malls. However, inspecting the viewports on the map, they are way too big. For example, here is a query (it won't work because it doesn't have a real key):

https://maps.googleapis.com/maps/api/place/search/json?location=47.5932,-122.3318&radius=300&sensor=false&key=FOO

Here is part of the result JSON:

{
  "status": "OK",
  "results": [ {
    "name": "Qwest Field",
    "vicinity": "Occidental Ave S, Seattle",
    "types": [ "stadium", "establishment" ],
    "geometry": {
      "location": {
        "lat": 47.5959329,
        "lng": -122.3317095
      },
      "viewport": {
        "southwest": {
          "lat": 47.5884079,
          "lng": -122.3477169
        },
        "northeast": {
          "lat": 47.6034568,
          "lng": -122.3157021
        }
      }
    },
    "icon": "http://maps.gstatic.com/mapfiles/place_api/icons/stadium-71.png",
    "reference": "CnRrAAAAwM6Pr_ER4VDFNlwg4_JrMxG9FGaqAXokpQXGot9OqzylWRX_NIPsptuMoIeHej9GUDp5otUTQifL-kyP5l0AM5u93PTV22U7-Xz-y_dHuWAjetviEBlo24JIGgWcnuExlE1FBh2FKkNzCdpyUdv7PRIQodCSeacFJtrl8ZkZ1wvfvxoUFCIvCrbknO6tEl3EewS1wrjl06M",
    "id": "d4fd94323d3f462730123ac2c5eb91d0180bb819"
  },
...

If you look at the lat/langs for the two corners, they are way apart.

I tried a few other places and they all had this problem. Has anybody noticed the same issue?


Solution

  • The 'viewport' property does not represent the bounding box of the place. It represents the recommended map view to use when displaying this place on a Google map. For large features, such as a state or a city it may approximate to the bounds of the feature, but for small features there is a minimum size (~500m across) that is returned, so that the map shows a wide enough area around the feature for a user to understand the location of the place in context.

    Hope that helps,

    Thor.