|
1
|
|
|
/** global: google */ |
|
2
|
|
|
/** global: pokemon_id */ |
|
3
|
|
|
var map, heatmap; |
|
4
|
|
|
|
|
5
|
|
|
function initMap() { |
|
6
|
|
|
|
|
7
|
|
|
$.getJSON( "core/json/variables.json", function( jsondata ) { |
|
8
|
|
|
|
|
9
|
|
|
var variables = jsondata; |
|
10
|
|
|
|
|
11
|
|
|
var lattitude = Number(variables['system']['map_center_lat']); |
|
12
|
|
|
var longitude = Number(variables['system']['map_center_long']); |
|
13
|
|
|
var zoom_level = Number(variables['system']['zoom_level']); |
|
14
|
|
|
|
|
15
|
|
|
|
|
16
|
|
|
map = new google.maps.Map(document.getElementById('map'), { |
|
17
|
|
|
center: {lat: lattitude, lng: longitude}, |
|
18
|
|
|
zoom: zoom_level, |
|
19
|
|
|
zoomControl: true, |
|
20
|
|
|
scaleControl: false, |
|
21
|
|
|
scrollwheel: true, |
|
22
|
|
|
disableDoubleClickZoom: false, |
|
23
|
|
|
}); |
|
24
|
|
|
|
|
25
|
|
|
map.set('styles',[ |
|
26
|
|
|
{ |
|
27
|
|
|
"featureType":"all", |
|
28
|
|
|
"elementType":"labels.text.fill", |
|
29
|
|
|
"stylers":[{"saturation":36},{"color":"#333333"},{"lightness":40}] |
|
30
|
|
|
}, |
|
31
|
|
|
{ |
|
32
|
|
|
"featureType":"all", |
|
33
|
|
|
"elementType":"labels.text.stroke", |
|
34
|
|
|
"stylers":[{"visibility":"on"},{"color":"#ffffff"},{"lightness":16}] |
|
35
|
|
|
}, |
|
36
|
|
|
{ |
|
37
|
|
|
"featureType":"all", |
|
38
|
|
|
"elementType":"labels.icon", |
|
39
|
|
|
"stylers":[{"visibility":"off"}] |
|
40
|
|
|
}, |
|
41
|
|
|
{ |
|
42
|
|
|
"featureType":"administrative", |
|
43
|
|
|
"elementType":"geometry.fill", |
|
44
|
|
|
"stylers":[{"color":"#fefefe"},{"lightness":20}] |
|
45
|
|
|
}, |
|
46
|
|
|
{ |
|
47
|
|
|
"featureType":"administrative", |
|
48
|
|
|
"elementType":"geometry.stroke", |
|
49
|
|
|
"stylers":[{"color":"#fefefe"},{"lightness":17},{"weight":1.2}] |
|
50
|
|
|
}, |
|
51
|
|
|
{ |
|
52
|
|
|
"featureType":"landscape", |
|
53
|
|
|
"elementType":"geometry", |
|
54
|
|
|
"stylers":[{"color":"#f5f5f5"},{"lightness":20}] |
|
55
|
|
|
}, |
|
56
|
|
|
{ |
|
57
|
|
|
"featureType":"poi", |
|
58
|
|
|
"elementType":"geometry", |
|
59
|
|
|
"stylers":[{"color":"#f5f5f5"},{"lightness":21}] |
|
60
|
|
|
}, |
|
61
|
|
|
{ |
|
62
|
|
|
"featureType":"poi.park", |
|
63
|
|
|
"elementType":"geometry", |
|
64
|
|
|
"stylers":[{"color":"#dedede"},{"lightness":21}] |
|
65
|
|
|
}, |
|
66
|
|
|
{ |
|
67
|
|
|
"featureType":"poi.park", |
|
68
|
|
|
"elementType":"geometry.fill", |
|
69
|
|
|
"stylers":[{"color":"#c2ffd7"}] |
|
70
|
|
|
}, |
|
71
|
|
|
{ |
|
72
|
|
|
"featureType":"road.highway", |
|
73
|
|
|
"elementType":"geometry.fill", |
|
74
|
|
|
"stylers":[{"color":"#ffffff"},{"lightness":17}]}, |
|
75
|
|
|
{ |
|
76
|
|
|
"featureType":"road.highway", |
|
77
|
|
|
"elementType":"geometry.stroke", |
|
78
|
|
|
"stylers":[{"color":"#ffffff"},{"lightness":29},{"weight":0.2}]}, |
|
79
|
|
|
{ |
|
80
|
|
|
"featureType":"road.arterial", |
|
81
|
|
|
"elementType":"geometry", |
|
82
|
|
|
"stylers":[{"color":"#ffffff"},{"lightness":18}]}, |
|
83
|
|
|
{ |
|
84
|
|
|
"featureType":"road.local", |
|
85
|
|
|
"elementType":"geometry", |
|
86
|
|
|
"stylers":[{"color":"#ffffff"},{"lightness":16}]}, |
|
87
|
|
|
{ |
|
88
|
|
|
"featureType":"transit", |
|
89
|
|
|
"elementType":"geometry", |
|
90
|
|
|
"stylers":[{"color":"#f2f2f2"},{"lightness":19}]}, |
|
91
|
|
|
{ |
|
92
|
|
|
"featureType":"water", |
|
93
|
|
|
"elementType":"geometry", |
|
94
|
|
|
"stylers":[{"color":"#e9e9e9"},{"lightness":17}]}, |
|
95
|
|
|
{ |
|
96
|
|
|
"featureType":"water", |
|
97
|
|
|
"elementType":"geometry.fill", |
|
98
|
|
|
"stylers":[{"color":"#b3d8f9"}] |
|
99
|
|
|
} |
|
100
|
|
|
]); |
|
101
|
|
|
initSlider(); |
|
102
|
|
|
}); |
|
103
|
|
|
|
|
104
|
|
|
} |
|
105
|
|
|
function initSlider(){ |
|
106
|
|
|
$.ajax({ |
|
107
|
|
|
'async': true, |
|
108
|
|
|
'type': "GET", |
|
109
|
|
|
'global': false, |
|
110
|
|
|
'dataType': 'json', |
|
111
|
|
|
'url': "core/process/aru.php", |
|
112
|
|
|
'data': { |
|
113
|
|
|
'request': "", |
|
114
|
|
|
'target': 'arrange_url', |
|
115
|
|
|
'method': 'method_target', |
|
116
|
|
|
'type' : 'pokemon_slider_init' |
|
117
|
|
|
} |
|
118
|
|
|
}).done(function(bounds){ |
|
119
|
|
|
var selectorMax = new Date(bounds.max); |
|
120
|
|
|
var selectorMin = new Date(bounds.min); |
|
121
|
|
|
var maxMinus2Weeks = new Date(selectorMax.getTime() - 2 * 7 * 24 * 60 * 60 * 1000); |
|
122
|
|
|
if(selectorMin < maxMinus2Weeks){ |
|
123
|
|
|
selectorMin = maxMinus2Weeks; |
|
124
|
|
|
} |
|
125
|
|
|
$("#timeSelector").dateRangeSlider({ |
|
126
|
|
|
bounds:{ |
|
127
|
|
|
min: new Date(bounds.min), |
|
128
|
|
|
max: new Date(bounds.max) |
|
129
|
|
|
}, |
|
130
|
|
|
defaultValues:{ |
|
131
|
|
|
min: selectorMin, |
|
132
|
|
|
max: selectorMax |
|
133
|
|
|
} |
|
134
|
|
|
}); |
|
135
|
|
|
createHeatmap(); |
|
136
|
|
|
}); |
|
137
|
|
|
|
|
138
|
|
|
} |
|
139
|
|
|
function createHeatmap() { |
|
140
|
|
|
|
|
141
|
|
|
heatmap = new google.maps.visualization.HeatmapLayer({ |
|
142
|
|
|
data: [], |
|
143
|
|
|
map: map |
|
144
|
|
|
}); |
|
145
|
|
|
|
|
146
|
|
|
var gradient = [ |
|
147
|
|
|
'rgba(0, 255, 255, 0)', |
|
148
|
|
|
'rgba(0, 255, 255, 1)', |
|
149
|
|
|
'rgba(0, 191, 255, 1)', |
|
150
|
|
|
'rgba(0, 127, 255, 1)', |
|
151
|
|
|
'rgba(0, 63, 255, 1)', |
|
152
|
|
|
'rgba(0, 0, 255, 1)', |
|
153
|
|
|
'rgba(0, 0, 223, 1)', |
|
154
|
|
|
'rgba(0, 0, 191, 1)', |
|
155
|
|
|
'rgba(0, 0, 159, 1)', |
|
156
|
|
|
'rgba(0, 0, 127, 1)', |
|
157
|
|
|
'rgba(63, 0, 91, 1)', |
|
158
|
|
|
'rgba(127, 0, 63, 1)', |
|
159
|
|
|
'rgba(191, 0, 31, 1)', |
|
160
|
|
|
'rgba(255, 0, 0, 1)' |
|
161
|
|
|
]; |
|
162
|
|
|
heatmap.set('gradient', gradient); |
|
163
|
|
|
heatmap.setMap(map); |
|
164
|
|
|
updateHeatmap(); |
|
165
|
|
|
$("#timeSelector").bind("valuesChanged",function(){updateHeatmap()}); |
|
166
|
|
|
} |
|
167
|
|
|
|
|
168
|
|
|
function updateHeatmap() { |
|
169
|
|
|
var dateMin = $("#timeSelector").dateRangeSlider("min"); |
|
170
|
|
|
var dateMax = $("#timeSelector").dateRangeSlider("max"); |
|
171
|
|
|
|
|
172
|
|
|
$.ajax({ |
|
173
|
|
|
'async': true, |
|
174
|
|
|
'type': "GET", |
|
175
|
|
|
'global': false, |
|
176
|
|
|
'dataType': 'json', |
|
177
|
|
|
'url': "core/process/aru.php", |
|
178
|
|
|
'data': { |
|
179
|
|
|
'request': "", |
|
180
|
|
|
'target': 'arrange_url', |
|
181
|
|
|
'method': 'method_target', |
|
182
|
|
|
'type' : 'pokemon_heatmap_points', |
|
183
|
|
|
'pokemon_id' : pokemon_id, |
|
184
|
|
|
'start' : Math.floor(dateMin.getTime()/1000), |
|
185
|
|
|
'end' : Math.floor(dateMax.getTime()/1000) |
|
186
|
|
|
} |
|
187
|
|
|
}).done(function(points){ |
|
188
|
|
|
var googlePoints = []; |
|
189
|
|
|
for (var i = 0; i < points.length; i++) { |
|
190
|
|
|
googlePoints.push(new google.maps.LatLng(points[i].latitude,points[i].longitude)) |
|
191
|
|
|
} |
|
192
|
|
|
var newPoints = new google.maps.MVCArray(googlePoints); |
|
193
|
|
|
heatmap.set('data', newPoints); |
|
194
|
|
|
}); |
|
195
|
|
|
} |