-
Notifications
You must be signed in to change notification settings - Fork 0
/
maps_example.js
64 lines (52 loc) · 1.74 KB
/
maps_example.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/**
* Written by group
*/
// //Array for the list of cities + their count
var array = [];
//
// //Make objects where cityStatus is stored
var cityStatus1 = {
cityName: "London",
count: 100,
};
var cityStatus2 = {
cityName: "Leeds",
count: 70,
};
//push these statuses in the array to use in the map
array.push(cityStatus1);
array.push(cityStatus2);
//function makeMap(array) {
//google.setOnLoadCallback(drawRegionsMap);
//google.charts.setOnLoadCallback(drawRegionsMap);
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': 'AIzaSyA9RNP4ksFWb5Du48Ngghae8Jhg8Ia3oKY'
});
google.charts.setOnLoadCallback(drawRegionsMap);
function drawRegionsMap() {
//create new data table
var data = new google.visualization.DataTable();
//add columns for city and flu count
data.addColumn('string', 'City');
data.addColumn('number', 'Flu count');
//add the values to the columns
for (let i = 0; i < array.length; i++) {
data.addRows([[array[i].cityName, array[i].count]]);
}
//change the default settings in map
var options = {
region: 'GB',
resolution: 'provinces',
displayMode: 'markers',
markerOpacity: 0.8,
//sizeAxis: {minSize:2, maxSize: 5},
colorAxis: {colors: ['#b6e757', '#e05923']}
};
//create chart and put the chart in a div in the HTML
var chart = new google.visualization.GeoChart(document.getElementById('regions_div'));
chart.draw(data, options);
}
//}