I'm trying to use a geomap using 2 color schemes. the user will click a link on the page and then, using js, i will change the color of the map and redraw it.
i would change
options['colors'] = [0xbaecc7, 0x3bc75f]; // light to dark green
The problem is that every time i call the function to redraw it seems to reload the geomap. I have two functions.. the one below is for green and the otherone is for drawing the blue map.
At the start i draw the blue map using drawMap
by calling setOnLoadCallBack
google.setOnLoadCallback(drawMap);
Any help or ideas would be appreaciated!
function drawGoalsMap() {
var options = {};
options['dataMode'] = 'regions';
options['region'] = 'world';
options['colors'] = [0xbaecc7, 0x3bc75f]; // light to dark green
options['width'] = '900px';
options['height'] = '400px';
var data = new google.visualization.DataTable();
data.addRows(6);
data.addColumn('string', 'Country');
data.addColumn('number', 'Messages');
data.setValue(0, 0, 'Germany');
data.setValue(0, 1, 200);
data.setValue(1, 0, 'United States');
data.setValue(1, 1, 300);
data.setValue(2, 0, 'Brazil');
data.setValue(2, 1, 400);
data.setValue(3, 0, 'Canada');
data.setValue(3, 1, 500);
data.setValue(4, 0, 'France');
data.setValue(4, 1, 600);
data.setValue(5, 0, 'RU');
data.setValue(5, 1, 700);
var container = document.getElementById('map_canvas');
var geomap = new google.visualization.GeoMap(container);
geomap.draw(data, options);
google.visualization.events.addListener(geomap, 'regionClick',
function(e) {
var countryCode = e['region'];
DrillDown(countryCode);
}
);
};
After a chance edit in my code I found the problem!!!
I was using the link <a href="" onclick="drawGoalsMap()">Goals</a>
I changed it to exclude the href=""
<a onclick="drawGoalsMap()">Goals</a>