Google IntensityMap Visualization US States

2019-04-12 15:49发布

问题:

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?

回答1:

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.



回答2:

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!