如何从谷歌地图获取区域/区域多边形边界数据?

时间:2015-07-29 12:58:17

标签: api google-maps google-maps-api-3 google-places-api

当我在Google地图中搜索某个地区时,例如:“吉隆坡”,它会显示该地区的多边形边界。

enter image description here

我知道Google会通过Google Places API提供地图数据。 所以,我查询“吉隆坡”一词,如下:https://maps.googleapis.com/maps/api/place/autocomplete/json?input=kuala%20lumpur&types=(cities)

从那里我得到了地方ID “place_id”:“ChIJ5-rvAcdJzDERfSgcL1uO2fQ”,

然后,我将地点ID查询到Google Places API(地点详情),如下所示: https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJ5-rvAcdJzDERfSgcL1uO2fQ

返回的几何数据只给我位置坐标和视口:

 "geometry" : {          
        "location" : {             
            "lat" : 3.139003,             
            "lng" : 101.686855          
        },          
        "viewport" : {             
            "northeast" : {                
                "lat" : 3.245252,                
                "lng" : 101.758509             
            },             
            "southwest" : {                
                "lat" : 3.0327539,                
                "lng" : 101.6152019             
            }          
        }       
    }

如何获取区域的复杂多边形边界点?

1 个答案:

答案 0 :(得分:2)

Google Maps API无法提供此数据。另一种解决方案是使用KML数据,可以在网上找到,并且可以检索URL。可以使用google.maps.KmlLayer使用网址将其导入地图。

相关问题