Popups for State Shapes in US map

gschnippel's Avatar

gschnippel

29 Sep, 2011 04:18 PM

Hopefully a trivial question -- I'm Working on a state-by-state map that will show tooltips when a user hovers over an individual state (ex. this map on Energy.gov: http://energy.gov/maps/2009-energy-expenditure-person) but having trouble figuring out how to connect the data points to the tooltip.

I've got a spreadsheet of data loaded with the state-by-state data and the state layers -- is there an easy way to connect these to the tooltips?

  1. 2 Posted by gschnippel on 29 Sep, 2011 04:38 PM

    gschnippel's Avatar

    Clarifying a little the approach I am trying to take. With my current state data file, I'm trying to setup the geojson row template (in Google Refine) like this:

    { 
      "type": "Feature",
      "id": {{jsonize(cells["STATE"].value)}},
      "geometry": { < ?? > }, 
      "properties":
    {
      "STATE" : {{jsonize(cells["STATE"].value)}},
     "DATA1" : {{jsonize(cells["DATA1"].value)}},
      "DATA2" : {{jsonize(cells["DATA2"].value)}},
    

    ... etc.

    I am assuming that what I need to define is a new column in my spreadsheet with the correct geometry parameter for each state polygon and then add that to the row template specification above.

    Another approach (though less than ideal) would be to add a 'state capital' dot with the correct longitude / latitude defined in the spreadsheet and then add this in as a geometry type of 'point', ex:

    "geometry": { "type": "Point", "coordinates": [{{cells["longitude"].value}}, {{cells["latitude"].value}}] },

  2. Support Staff 3 Posted by Tom MacWright on 29 Sep, 2011 07:01 PM

    Tom MacWright's Avatar

    Hey gschnippel,

    Have you seen any of our posts about UTFGrid (and this one)? We do polygon interaction by rasterizing data. In your case, you'd, yes, join your data with GeoJSON, a shapefile, or Postgres, and render a tileset with TileMill, which provides an interface for displaying data from your datasource in tooltips on a map.

    This is how the Dept. Energy maps are currently working - they brought a shapefile into TileMill, and rendered a tileset with interactivity.

    Tom

  3. 4 Posted by gschnippel on 30 Sep, 2011 07:17 PM

    gschnippel's Avatar

    Thanks Tom - that helped. I ended up grabbing shape layer from TIGER and binding the data layer to it using QGIS then importing it back into tilemill. I've kept decent notes on the process and post the writeup soon in case its useful for anyone else.

  4. gschnippel closed this discussion on 30 Sep, 2011 07:17 PM.

Comments are currently closed for this discussion. You can start a new one.

Recent Discussions

25 May, 2013 09:12 AM
25 May, 2013 08:30 AM
25 May, 2013 01:00 AM
25 May, 2013 12:58 AM
25 May, 2013 12:20 AM