Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get region / district polygon boundaries data from google Maps? [duplicate]

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

enter image description here

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?

like image 564
Anton R Avatar asked Jul 29 '15 12:07

Anton R


1 Answers

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.

like image 91
bcdan Avatar answered Sep 28 '22 14:09

bcdan