When I search for a region in Google Maps, for example: "Kuala Lumpur", it will show me the polygon boundary of that region.
I know that Google provide its Maps data via Google Places API. So, I query the term "Kuala Lumpur", like this: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=kuala%20lumpur&types=(cities)
From that I got place ID "place_id" : "ChIJ5-rvAcdJzDERfSgcL1uO2fQ",
Then, I query the place ID to Google Places API (place details), like this: https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJ5-rvAcdJzDERfSgcL1uO2fQ
The geometry data returned only give me location coordinate and viewport:
"geometry" : { "location" : { "lat" : 3.139003, "lng" : 101.686855 }, "viewport" : { "northeast" : { "lat" : 3.245252, "lng" : 101.758509 }, "southwest" : { "lat" : 3.0327539, "lng" : 101.6152019 } } }
How do I get the complex polygon boundary points of a region?
This data is not available from the Google Maps APIs. An alternative solution would be to use KML data, which can probably be found online, and the URL can be retrieved. This can be imported into the map using the URL using google.maps.KmlLayer
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With