Geographical boundaries of states/provinces -> Google Maps Polygon

50,869

Solution 1

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.

Solution 2

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.

Solution 3

Old question but you can get a more detailed set of points for each US state border from the google website at https://developers.google.com/kml/documentation/us_states.kml

It needs a little bit of parsing of the xml though.

Share:
50,869
motto
Author by

motto

Updated on May 12, 2020

Comments

  • motto
    motto almost 4 years

    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

  • motto
    motto over 14 years
    Thanks a bunch! Your data worked without any problems. Like the level of detail too. You rock!
  • Curd
    Curd over 14 years
    @Mike Williams: Why do the boundaries of adjacent states fit so badly together? I understand that there is some limit in resolution, but there is no reason for gaps and overlaps (visible in higher zoom levels) between adjacent states.
  • MadHacker
    MadHacker about 12 years
    Do you know where I can find this data at the city level?
  • Burferd
    Burferd about 12 years
    Any idea where I can get a file with a bit more detail?
  • geocodezip
    geocodezip almost 12 years
    Try the Natural Earth dataset. It is also available in FusionTables.
  • jjwdesign
    jjwdesign over 11 years
    Thanks for the post Mike. I'm also trying to keep things 'light'.
  • Ben
    Ben over 11 years
    @geocodezip's comment should be an answer of its own, that Natural Earth website is awesome!
  • tentmaking
    tentmaking about 11 years
    @Mike Williams, where did you get that XML file for the US state polygons? I am looking for one exactly like that one, but I would like it to include state counties. Any help you can provide is appreciated.
  • SaltyNuts
    SaltyNuts over 10 years
    This set is awesome but is missing District of Columbia - it's lumped into Maryland :(
  • Waqas Ali Khan Puar
    Waqas Ali Khan Puar over 9 years
    I need coordinates for all city boundaries in Pakistan. Can anyone help please...
  • Bing
    Bing about 7 years
    @Mike Willians, seconding Curd's concerns. New York and New Jersey have overlapping regions: i.imgur.com/tjdSwPS.jpg