問題描述
如果我在谷歌地圖中搜索一個查詢,例如carlton victoria australia",那么它會給我一張該地區邊界的地圖.
If I search a query in google maps for example "carlton victoria australia" then it will give me a map of the region with the border around that area.
我的問題是:
- 有沒有辦法從谷歌地圖api獲取所有地區的列表某個省份或國家?
- 我可以合并區域信息,例如更改顏色并在區域頂部添加一些信息窗口嗎?
- 我可以從 api(區、街道、村)獲得什么樣的區域級別?
推薦答案
目前 Google Maps JavaScript API 沒有公開任何地理特征的邊界.公共問題跟蹤器中有一個非常古老的功能請求來添加此功能,但看起來 Google 并未對此設置高優先級:
Currently Google Maps JavaScript API doesn't expose any boundaries of geographic features. There is very old feature request in the public issue tracker to add this functionality, however it looks like Google didn't set high priority on this:
https://issuetracker.google.com/issues/35816953
請隨時為公開功能請求加注星標以表達您的興趣并訂閱 Google 的進一步更新.
Feel free to star the public feature request to express your interest and subscribe to further updates from Google.
您可以從其他來源獲取多邊形并將它們作為附加圖層添加到 Google 地圖中.
You can get polygons from other sources and add them to Google maps as additional layers.
從 OpenStreetMap 獲取 GeoJSON 格式的多邊形的好方法在以下答案中進行了描述:
The nice workaround to get polygons in GeoJSON format from OpenStreetMap is described in the following answer:
https://stackoverflow.com/a/40172098/5140781
因此,如果您下載 GeoJSON,您將能夠使用數據層及其 loadGeoJson()
方法將其添加到地圖中:
So, if you download the GeoJSON you will be able to add it to map using the data layer and its loadGeoJson()
method:
https://developers.google.com/maps/documentation/javascript/datalayer#load_geojson
您可以設置 GeoJSON 對象的顏色樣式并創建信息窗口.只需閱讀上述文檔.
You can style colors of GeoJSON objects and create info windows. Just read the aforementioned documentation.
我希望這會有所幫助!
這篇關于在谷歌地圖上繪制區域的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!