I'm trying to add a google visualization asynchronous, but I am running into problems. I've narrowed it down to the google.load causing the problem. When google.load part of the js runs, I get an empty screen/dom. Any one know what I am doing wrong.
I've also tried using the google.setOnLoadCallback, I get the same result.
Any help would be great
Relevant code :
$(document).ready(function () {
google.load('visualization', '1', { 'packages': ['geomap'] }, { 'callback': drawVisualization });
function drawVisualization() {
$.ajax({
type: "POST",
data: "{'monitorId':'" + monitor + "','monitorName':'" + name + "','context':'" + context + "'}",
dataType: "json",
url: "WebService.asmx/LoadMonitorToolGeo",
contentType: "application/json; charset=utf-8",
processData: true,
success: function (msg) {
var obj = jQuery.parseJSON(msg.d);
// $(msg.d).hide().appendTo("#sortable").fadeIn();
$("#" + obj.context).find(".toolContent").hide().html(obj.data).fadeIn();
DrawWorldMap(obj.map, obj.context);
},
error: function (req, status, error) {
},
complete: function (req, status) {
}
});
function DrawWorldMap(response, id) {
var data = new google.visualization.DataTable();
data.addRows(response.d.length);
data.addColumn('string', 'Country');
data.addColumn('number', 'Popularity');
for (var i = 0; i < response.d.length; i++) {
data.setValue(i, 0, response.d[i].Country);
data.setValue(i, 1, response.d[i].Popularity);
}
var options = {};
options['dataMode'] = 'regions';
var container = document.getElementById(id);
var geomap = new google.visualization.GeoMap(container);
geomap.draw(data, options);
}
});