在Google地图上绘制区域 [英] Drawing region on google maps

查看:269
本文介绍了在Google地图上绘制区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在谷歌地图中搜索一个查询,例如carlton victoria australia,那么它会给我一个带有该地区周围边界的地区地图。



您可以自由地向公众发布功能请求,以表达您的兴趣并订阅Google的更新更新。



您可以从其他来源获取多边形并将其添加到Google地图作为附加图层。



以下答案描述了用于从OpenStreetMap获取GeoJSON格式多边形的很好的解决方法:



https://stackoverflow.com/a/40172098/5140781



因此,如果您下载GeoJSON,您将可以使用数据层及其 loadGeoJson()方法将其添加到地图中:



https://developers.google.com/maps/documentation/javascript/datalayer#load_geojson



您可以设置GeoJSON对象的颜色样式并创建信息窗口。请阅读前面提到的文档。



我希望这有助于您!


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.

My questions are:

  1. Is there a way to get list of all regions from the google map api for certain province or country?
  2. Can I combine the region information for example, change the color and also add some infowindow on top of the region?
  3. What kind of level of the region that I can get from the api (district, subdistrict, village)?

解决方案

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

Feel free to star the public feature request to express your interest and subscribe to further updates from Google.

You can get polygons from other sources and add them to Google maps as additional layers.

The nice workaround to get polygons in GeoJSON format from OpenStreetMap is described in the following answer:

https://stackoverflow.com/a/40172098/5140781

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

You can style colors of GeoJSON objects and create info windows. Just read the aforementioned documentation.

I hope this helps!

这篇关于在Google地图上绘制区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆