Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Geographical boundaries of states/provinces -> Google Maps Polygon

I'm building a web application that is going to dynamically highlight certain U.S. states and Canadian provinces on a Google Map, based on buttons and click events.

Plan A) Polygons

My primary idea for this was to draw Polygons. For this I need lists of coordinates (latitude + longitude) of all state and province outlines (clockwise or counter-clockwise). On government websites I found all sorts of different formats (i.e. E00), but I have trouble converting these formats into a simple list of coordinates, that I could use to create markers or a polygon on a map. Do you have any tips where to get these coordinates?

Plan B) Overlays

AFAIK, if you use overlays on Google Maps, they become pixelated as you zoom in further (or can you overlay SVGs?) In my case I would need 50 + 11 overlays in the worst-case (all states and all provinces). Is that still possible with Google Maps or will it get unsuably slow?

I'm a bit startled that there isn't a straight-forward way to highlight a state or province, as I would think this is a very common tasks for people using an API for maps.

Thanks in advance

like image 832
motto Avatar asked Nov 28 '09 23:11

motto


People also ask

How do I find state boundaries on Google Maps?

To see it yourself, go to Google Maps and search for a city name or even a zip code. You will see a pinkish highlight around the border. Based on your zoom level, as you zoom out, Google will highlight the whole area, not just the borders, in the pink color.


2 Answers

I've got XML for US state polygons here. I use them like this.

I deliberately kept the detail fairly light to reduce the loading time and end up with a map that's reasonably responsive in slow browsers.

I don't have anything for Canada.

like image 91
Mike Williams Avatar answered Sep 23 '22 16:09

Mike Williams


Using the XML provided, I created a JSON file with a dictionary that includes the 50 states, Washington D.C. and a rough outline of the Canadian provinces to address SaltyNuts' comment as well as Mike Williams note of not having anything for Canada json.

This handy online tool from BirdTheme was what I used to draw the polygons for the provinces for anyone else who needs different levels of detail or to create their own set of coordinates.

like image 25
northcott-j Avatar answered Sep 21 '22 16:09

northcott-j