When searching Google Maps for a city, the city's administrative boundary is displayed.
Is there a way to get the polygon boundaries of City in a JSON format using google maps api?
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.
Sign up to join this communityWhen searching Google Maps for a city, the city's administrative boundary is displayed.
Is there a way to get the polygon boundaries of City in a JSON format using google maps api?
You can get polygon coordenates in json for using with googlemaps using openstreetmap. Go to http://nominatim.openstreetmap.org/ search a place like "Partido de ItuzaingĂł"
click on "details"
Look for OSM ID and copy it (control+c), example: 2018776
paste the ID in http://polygons.openstreetmap.fr/index.py and download the polygon
5638803
, when I run global.mapit.mysociety.org/code/osm_rel/5638803 I get {"code": 404, "error": "No areas were found that matched code osm_rel = 5638803."}
To get polygon boundaries just add format=json
to your request!
So instead of https://nominatim.openstreetmap.org/search.php?q=Warsaw+Poland&polygon_geojson=1
use
https://nominatim.openstreetmap.org/search.php?q=Warsaw+Poland&polygon_geojson=1&format=json
By adding &format=geojson you can get a valid geojson response
I've found a work around solution for this problem.
You can use lat,long data and parse it into an array. This solution is working well, but the quality of the path is sometimes rough.
No, there is no way to steal Google's data. May be you could look at OpenStreetMap which is designed for people to download.
As an alternative to Google Maps API, OpenStreetMap may help you to search for a city by name in this page http://nominatim.openstreetmap.org/ . Then review search results, and you can get region coordinate in GeoJSON format e.g (http://nominatim.openstreetmap.org/details.php?place_id=145126778) to get mashhad geojson coordinates in Administrative tab