问题描述
我有一张Google地图 URL .在我的应用中,我使用gmaps js 库
I got a google map URL.In my apps I use gmaps js library
我想要的是,如何将gmaps js显示与google maps完全相同.
What I want is, how to the gmaps js could show the exactly same what is google maps shown.
我试图发送参数数据:
有人可以告诉我如何从Google地图网址中获取多边形吗?
could someone please tell me how to get the polygons from google maps url?
推荐答案
当前,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
您可以为公共功能请求加注星标,以添加投票并订阅通知.
You can star the public feature request to add your vote and subscribe to notifications.
此外,您可以找到一种解决方法,以从其他来源获取多边形并将其作为其他图层添加到Google地图中.
Also, you can find a workaround to get polygons from other sources and add them to Google maps as additional layers.
以下答案描述了从OSM获取GeoJSON格式的多边形的一种很好的解决方法:
The nice workaround to get polygons in GeoJSON format from OSM 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
正如我所见,gmaps.js也支持GeoJSON多边形:
As I can see the gmaps.js supports GeoJSON polygons as well:
https://hpneo.github.io/gmaps/examples/geojson_polygon.html
我希望这会有所帮助!
这篇关于如何在Google Maps URL中获取多边形并在gmaps js中使用多边形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!