Help : Defining specific cities in GoogleCharts API coding

20 views
Skip to first unread message

Sami Abbas

unread,
Aug 24, 2018, 4:19:38 AM8/24/18
to Google Visualization API
Dear All,

I require your assistance in the following:

Below is a sample code gratefully offered by Google in how to create a dot map charts where the dot markers are referred as 'city'

my question is, if I want to add a city (that i have its coordinates) not recognized/implemented in Google API  inside the array , how am I able to do so? (ease of reference I added the arrow on the line that I wish to implement)

<html>
 
<head>
   
<script type='text/javascript' src='https://www.gstatic.com/charts/loader.js'></script>
   
<script type='text/javascript'>
     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],
 ====>       [ 'Adding NEW CITY with Latitude Longitude",   55555, 100]


     
]);

     
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>
Reply all
Reply to author
Forward
0 new messages