2

I am attempting to use the google visualization library - intensity map. I have a list of states and the number of users in each state. I can only get the world map to show, I want to highlight the us states and only show us map.

http://code.google.com/apis/visualization/documentation/gallery/geomap.html

Does anyone have a good example, tutorial or instructions on how to do this?

jhanifen
  • 4,441
  • 7
  • 43
  • 67

2 Answers2

3

This turned out to be very easy. Just need to figure out the region name 'usa'.

function drawVisualization() {

    var options = {};
    options['region'] = 'usa';
    options['dataMode'] = 'regions';

    var data = new google.visualization.DataTable();
    data.addColumn('string', '', 'USA');
    data.addColumn('number', 'Particpants', 'a');
    data.addRows(1);
    data.setValue(0, 0, CA);
    data.setValue(0, 1, 44);

    // Create and draw the visualization.
    new google.visualization.IntensityMap(document.getElementById('visualization')).
    draw(data, options);
}

google.setOnLoadCallback(drawVisualization);

Hope this helps, let me know if it works for you. This is not the full code snippet but should be enough to get the idea. Let me know if you need more specifics.

jhanifen
  • 4,441
  • 7
  • 43
  • 67
  • 1
    Great find! I've been trying to find a solution to the same question for either the GeoMap or the GeoChart, since I need a more interactivity than the IntensityMap allows. It seems, however, that neither of those support the "usa" region for a state-level view, only countries or world regions for country-level views. – Nate Cook May 16 '11 at 15:46
  • Well, wrong about that too: when given only state-level data GeoMap and GeoChart will display states! – Nate Cook May 16 '11 at 15:55
-1

It looks like Google isn't sharing that capability right now. It's a few months old, but this reply on the Google Chart API group seems to kill the idea. I'm looking for the same functionality, but the closest I've found is Maps Alive (no affiliation). However, their API seems more limited and the pricing adds up quickly. Best of luck!

Nate Cook
  • 92,417
  • 32
  • 217
  • 178
  • This is definitely not correct, please see answer above for how to do this. The google chart api does support this, it is just very hard to find. – jhanifen May 09 '11 at 20:50