Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
169 views
in Technique[技术] by (71.8m points)

javascript - Drawing region on google maps

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. Carlton

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)?
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...