Hi! I'm a newbie, I started playing around with GoogleCharts last week, because I would like to use GeoCharts for my project website. I started off copying and pasting the examples given at:
but only the first one works, the one for "regions". As for the other examples, they do show the geographic boundaries, but ignore the data.
Reading around the documentation, I found that the syntax for loading the libraries has changed, but also using the new syntax the data is not shown. I also changed the API key given in the example with my own, just generated for this project. I have searched for similar issues in this group but have not found anything to my case. What have I missed? Can somebody help me understand what's wrong with these examples?
modified with new syntax, but with the same key API given in the example.
<html>
<head>
<script src='
https://www.gstatic.com/charts/loader.js'></script>
<script src="
https://www.google.com/jsapi"></script>
<script>
google.charts.load('current', {
'packages': ['geochart'],
// Note: you will need to get a mapsApiKey for your project.
// See:
https://developers.google.com/chart/interactive/docs/basic_load_libs#load-settings 'mapsApiKey': '
AIzaSyD-9tSrke72PouQMnMX-a7eZSW0jkFMBWY'
});
google.charts.setOnLoadCallback(drawMarkersMap);
function drawMarkersMap() {
var data = google.visualization.arrayToDataTable([
['City', 'Population', 'Area'],
['Rome', 2761477, 1285.31],
['Milan', 1324110, 181.76],
['Naples', 959574, 117.27],
['Turin', 907563, 130.17],
['Palermo', 655875, 158.9],
['Genoa', 607906, 243.60],
['Bologna', 380181, 140.7],
['Florence', 371282, 102.41],
['Fiumicino', 67370, 213.44],
['Anzio', 52192, 43.43],
['Ciampino', 38262, 11]
]);
var options = {
region: 'IT',
displayMode: 'markers',
colorAxis: {colors: ['green', 'blue']}
};
var chart = new google.visualization.GeoChart(document.getElementById('chart_div'));
chart.draw(data, options);
};
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>