Search code examples
google-mapsgeolocationgeocodingfootprintgeoapi

Gazetteer that returns polygons for areas?


Is there a Geo API that I can query with an area name and receive back a polygon that represents the given area boundary? Some form of a gazetteer that gives back a polygon instead of the latitude/longitude coordinates.

For example, if I search for "Santa Barbara" I would like to get back the array of the coordinates of the polygon seen on the picture below. enter image description here


Solution

  • At the moment there is no such function in the public Google APIs. If you search for Santa Barbara using geocoding you will get the location with the viewport and bounding box. However you won't get a polygon around the area. When searching for Santa Barbara using Google Maps it uses a private API to show the polygon around the searched region.

    One workaround would be to create your own polygons and save them to your database and then check if the lat/long is within those polygons.