-
Notifications
You must be signed in to change notification settings - Fork 1
/
mapusage.js
executable file
·298 lines (264 loc) · 7.73 KB
/
mapusage.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
$(window).load(loadjs()); //Wait the page to be fully loaded (Inner frames, images, etc)
// var flightPath;
var map;
var flightPlanCoordinates;
var flightPath;
var markerinit;
var marker;
var myinitialpot;
var myLatLnglast;
function loadjs(){
init();
}
function initmap(){
var myOptions = {
//scrollwheel: false,
//draggable: false,
//disableDefaultUI: true,
mapTypeControl: false,
scaleControl: true,
zoomControl: true,
center: new google.maps.LatLng(+11.01930, -74.85152),
zoom: 17
};
map = new google.maps.Map(document.getElementById('map'), myOptions);
flightPlanCoordinates = [];
//flightPath.setMap(null);
flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
//strokeColor: '#000000',
strokeColor: '#FFCF00',
strokeOpacity: 2.0,
strokeWeight: 5
});
myinitialpot = new google.maps.LatLng(+11.01930, -74.85152);
markerinit = new google.maps.Marker({
position: myinitialpot,
title: 'Start',
icon: {
url: "images/init.png",
scaledSize: new google.maps.Size(64, 78)
}
});
myLatLnglast = new google.maps.LatLng(+11.01930, -74.85152);
marker = new google.maps.Marker({
position: myLatLnglast,
title: 'Current Position',
icon: {
url: "images/truck.png",
scaledSize: new google.maps.Size(64, 96)
}
});
//init();
// // Set the map's style to the initial value of the selector.
}
function init(){
var temp = 0;
var numb_init = 0;
$.post('php/changes.php',function(num){
numb_init = num;
});
temp = numb_init;
setInterval(function(){
$.post('php/changes.php',function(num){
numb_init = num;
if(numb_init != temp) {
temp = numb_init;
readData();
}
});
}, 2000);
}
function readData(){ //This function fetches the requested php code and inserts it on the function defined
$.post('php/readata.php',function(coordinates){
processreadData(coordinates)
});
}
function processreadData(coordinates){
console.log(coordinates);
var entiredata = coordinates.split("*");
var coorC = [];
var latC = [];
var lonC = [];
var dateC = [];
var timeC = [];
var positionC = [];
//var flightPlanCoordinates = [];
for(i=0;i<entiredata.length;i++){
coorC = entiredata[i].split(" ");
latC.push(coorC[0]);
lonC.push(coorC[1]);
dateC.push(coorC[2]);
timeC.push(coorC[3]);
positionC.push(coorC[4]);
}
delete latC[latC.length-1];
delete lonC[lonC.length-1];
delete dateC[dateC.length-1];
delete timeC[timeC.length-1];
map.setOptions({styles: styles['retro']});
var myLatLng = new google.maps.LatLng(latC[Math.round((latC.length - 2) / 2)],lonC[Math.round((lonC.length - 2) / 2)]);
var myOptions = {
scrollwheel: true,
draggable: true,
//disableDefaultUI: true,
mapTypeControl: false,
scaleControl: true,
zoomControl: true,
center:myLatLng,
zoom: 17
};
//Make Polyline
flightPlanCoordinates = [{lat:Number(latC[0]),lng:Number(lonC[0])}];
for(i=1;i<latC.length-1;i++){
flightPlanCoordinates.push({lat:Number(latC[i]),lng:Number(lonC[i])});
}
flightPath.setMap(null);
flightPath = new google.maps.Polyline({
path: flightPlanCoordinates,
geodesic: true,
//strokeColor: '#000000',
strokeColor: '#FFCF00',
strokeOpacity: 2.0,
strokeWeight: 5
});
flightPath.setMap(map);
// Locate initial point
myinitialpot = new google.maps.LatLng(latC[latC.length-2],lonC[lonC.length-2]);
markerinit.setMap(null);
markerinit = new google.maps.Marker({
position: myinitialpot,
title: 'Start',
icon: {
url: "images/init.png",
scaledSize: new google.maps.Size(64, 78)
}
});
markerinit.setMap(map);
//Locate last point
myLatLnglast = new google.maps.LatLng(latC[0],lonC[0]);
marker.setMap(null);
marker = new google.maps.Marker({
position: myLatLnglast,
title: 'Current Position',
icon: {
url: "images/truck.png",
scaledSize: new google.maps.Size(64, 96)
}
});
marker.setMap(map);
}
var styles = {
default: null,
retro: [
{elementType: 'geometry', stylers: [{color: '#ebe3cd'}]},
{elementType: 'labels.text.fill', stylers: [{color: '#523735'}]},
{elementType: 'labels.text.stroke', stylers: [{color: '#f5f1e6'}]},
{
featureType: 'administrative',
elementType: 'geometry.stroke',
stylers: [{color: '#c9b2a6'}]
},
{
featureType: 'administrative.land_parcel',
elementType: 'geometry.stroke',
stylers: [{color: '#dcd2be'}]
},
{
featureType: 'administrative.land_parcel',
elementType: 'labels.text.fill',
stylers: [{color: '#ae9e90'}]
},
{
featureType: 'landscape.natural',
elementType: 'geometry',
stylers: [{color: '#dfd2ae'}]
},
{
featureType: 'poi',
elementType: 'geometry',
stylers: [{color: '#dfd2ae'}]
},
{
featureType: 'poi',
elementType: 'labels.text.fill',
stylers: [{color: '#93817c'}]
},
{
featureType: 'poi.park',
elementType: 'geometry.fill',
stylers: [{color: '#a5b076'}]
},
{
featureType: 'poi.park',
elementType: 'labels.text.fill',
stylers: [{color: '#447530'}]
},
{
featureType: 'road',
elementType: 'geometry',
stylers: [{color: '#f5f1e6'}]
},
{
featureType: 'road.arterial',
elementType: 'geometry',
stylers: [{color: '#fdfcf8'}]
},
{
featureType: 'road.highway',
elementType: 'geometry',
stylers: [{color: '#f8c967'}]
},
{
featureType: 'road.highway',
elementType: 'geometry.stroke',
stylers: [{color: '#e9bc62'}]
},
{
featureType: 'road.highway.controlled_access',
elementType: 'geometry',
stylers: [{color: '#e98d58'}]
},
{
featureType: 'road.highway.controlled_access',
elementType: 'geometry.stroke',
stylers: [{color: '#db8555'}]
},
{
featureType: 'road.local',
elementType: 'labels.text.fill',
stylers: [{color: '#806b63'}]
},
{
featureType: 'transit.line',
elementType: 'geometry',
stylers: [{color: '#dfd2ae'}]
},
{
featureType: 'transit.line',
elementType: 'labels.text.fill',
stylers: [{color: '#8f7d77'}]
},
{
featureType: 'transit.line',
elementType: 'labels.text.stroke',
stylers: [{color: '#ebe3cd'}]
},
{
featureType: 'transit.station',
elementType: 'geometry',
stylers: [{color: '#dfd2ae'}]
},
{
featureType: 'water',
elementType: 'geometry.fill',
stylers: [{color: '#b9d3c2'}]
},
{
featureType: 'water',
elementType: 'labels.text.fill',
stylers: [{color: '#92998d'}]
}
]
};