3

I am displaying a very basic map of the US; just the states. What I'm looking for is a good method for dividing the map into regions, with a single hover (all the states in the region change color) and click listener.

So far the best option if found is here: How/Where do I get geoJSON data for states, provinces, and administrative regions of non-US countries?

That seems like a lot more work than it should be. Anyone have suggestions for a better method than importing 50 different shape files, and manually editing them into regions?

Community
  • 1
  • 1
user3226861
  • 181
  • 1
  • 4
  • 14
  • How is your map set up? If each state is an SVG, you can just give them each a class based on their region. – ckersch Jul 14 '14 at 20:22
  • Have a look at this post from Mike Bostock: [Let's Make a Map](http://bost.ocks.org/mike/map/). He walks you through the whole process... getting the data, using the command line tools for topojson, loading it in d3, styling the regions, adding labels, etc. – jshanley Jul 15 '14 at 01:19
  • I'm looking at the Let's Make a Map example, it doesn't do exactly what I'm looking for. I'm not finding any good information on how to do that. I need to merge multiple features (states) into a single feature (region). So when I'm drawing the map in D3, it's drawing each region as a whole, not with the individual states. Suppose this has become more of a geojson problem than D3 problem. – user3226861 Jul 18 '14 at 10:29

1 Answers1

2

This demo is near what you want:

http://bl.ocks.org/mbostock/4060606
http://bl.ocks.org/mbostock/raw/4060606/
http://bl.ocks.org/mbostock/raw/4090846/us.json

What you're going to want to do is manipulate the us.json file; offhand I don't see state names but I see ids, create your regions by merging states in the region into one ID. try applying your own onclick/hover, if you can't get it, share what you tried and we'll go from there.

Peter O.
  • 32,158
  • 14
  • 82
  • 96
albert
  • 8,112
  • 3
  • 47
  • 63