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

Categories

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

google maps v3 - highlight states or regions of states

Is it possible to highlight a state of a country or region of a state using google maps v3?

I saw examples with polygon but none of them were very good. Either the boundaries would overlap or is not properly drawn (can be seen when zoomed to maximum level).

From what i saw in various examples, I think I will need all the co-ordinates that makes up that state/region then only i can highlight it properly. Is there any better solution?

Also, how can I find co-ordinates of an entire state/region ?

Thanks a lot for help.

Regards

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

Google maps API doesn't offer a way to access region/state/country/city data. To highlight a region you have to create your custom overlay (polygon, overlay map type, ...) based on data from other sources.

As you wrote inexact polygons are often used. These polygons are usually hand made approximations, because that's the easiest way to do it. It's rather difficult to find and process region boundary data to get the polygons you need.

There might be other drawbacks in using exact region polygons. Such polygon usually have to contain thousands of points (there are the exceptional cases like US-Canada border or borders between some African countries). Polygons with lots of points might be difficult to process in JavaScript maps API. Therefore custom overlay map type might be more suitable in this case. Unfortunately, it demands much more work to create overlay map type than to create simple google.maps.Polygon.

Lots of map data (region coordinates and many other data) can be found on OpenStreetMap. You can export the data via their API.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...