问题描述
如何在搜索城市的基础上在 G-Map
上绘制边界线,如图所示,红线显示搜索到的城市地图?
我已经看到各种链接,但无法找到解决方案。
谢谢 现在Google Maps JavaScript API不公开地理特征的任何界限。在公共问题追踪器中有一个非常旧的功能请求来添加这个功能,但是看起来谷歌没有在这个任务上设置高优先级:
请随时为公众特征请求发送星标,以表达您的兴趣并订阅通知。
另外,您可以找到解决方法来从其他来源获取多边形,用OSM从GeoJSON格式获取多边形的好方法在下面的答案中有所描述:
因此,如果您下载GeoJSON,您可以使用数据层及其 loadGeoJson()
方法将它添加到地图中:
我希望这有助于!
How can I plot boundary line on G-Map
on the basis of city searched like in this image red line showing searched city map?
I have see various links but unable to find a solution.
Thanks
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 task:
https://issuetracker.google.com/issues/35816953
Feel free to star the public feature request to express your interest and subscribe to notifications.
Also, you can find a workaround to get polygons from other sources and add them to Google maps as additional layers.
The nice workaround to get polygons in GeoJSON format from OSM 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
I hope this helps!
这篇关于如何通过边界线在地图上绘制城市?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!