How to get area / area boundaries data from Google Maps?

When I search for a region on Google Maps, for example: "Kuala Lumpur", it will show me the polygon boundary of that region.

enter image description here

I know that Google provides its map data through the Google Places API. So I'm asking for the term "Kuala Lumpur", for example: https://maps.googleapis.com/maps/api/place/autocomplete/json?input=kuala%20lumpur&types=(cities)

From this I got the place_id: "ChIJ5-rvAcdJzDERfSgcL1uO2fQ"

Then I ask for the place id in the Google Places API (provide details), for example: https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJ5-rvAcdJzDERfSgcL1uO2fQ

The geometry data returned gives me the 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 to get complex polygon endpoints in an area?

+3


source to share


1 answer


This data is not available in the Google Maps API. An alternative solution would be to use the KML data, which can probably be found on the internet and the url can be obtained. This can be imported to a map using a url using google.maps.KmlLayer

.



+2


source







All Articles