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

11,443

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.

Share:
11,443
Anton R
Author by

Anton R

Updated on November 02, 2022

Comments

  • Anton R
    Anton R over 1 year

    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?

  • Anton R
    Anton R over 8 years
    Can you provide me sample query to get polygon lines border for Kuala Lumpur, for instance?
  • saniokazzz
    saniokazzz about 8 years
    Please provide example.
  • AbdealiJK
    AbdealiJK over 7 years
    Example would be nice.
  • Noah Huntington
    Noah Huntington about 5 years
    I think google.maps.kmlayer is only rendering an existing kml in the js api. Is there a REST equivalent using the Places API?