問題描述
如果我在谷歌地圖中搜索一個查詢,例如carlton victoria australia",那么它會給我一張該地區(qū)邊界的地圖.
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獲取所有地區(qū)的列表某個省份或國家?
- 我可以合并區(qū)域信息,例如更改顏色并在區(qū)域頂部添加一些信息窗口嗎?
- 我可以從 api(區(qū)、街道、村)獲得什么樣的區(qū)域級別?
推薦答案
目前 Google Maps JavaScript API 沒有公開任何地理特征的邊界.公共問題跟蹤器中有一個非常古老的功能請求來添加此功能,但看起來 Google 并未對此設(shè)置高優(yōu)先級:
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
請隨時為公開功能請求加注星標(biāo)以表達(dá)您的興趣并訂閱 Google 的進(jìn)一步更新.
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 格式的多邊形的好方法在以下答案中進(jìn)行了描述:
The nice workaround to get polygons in GeoJSON format from OpenStreetMap is described in the following answer:
https://stackoverflow.com/a/40172098/5140781
因此,如果您下載 GeoJSON,您將能夠使用數(shù)據(jù)層及其 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
您可以設(shè)置 GeoJSON 對象的顏色樣式并創(chuàng)建信息窗口.只需閱讀上述文檔.
You can style colors of GeoJSON objects and create info windows. Just read the aforementioned documentation.
我希望這會有所幫助!
這篇關(guān)于在谷歌地圖上繪制區(qū)域的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!