-
Notifications
You must be signed in to change notification settings - Fork 1
/
tripview.php
455 lines (381 loc) · 12 KB
/
tripview.php
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
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
<html>
<head>
<title>BYOS's Trip</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<meta property="og:title" content="TripNShare"/>
<meta property="og:type" content="website"/>
<meta property="og:url" content="http://91.134.142.192/share/tripview.php?pointtrip=58cd11e31af0c500010c5e03"/>
<meta property="og:image" content="http://91.134.142.192/tripandshare.png"/>
<meta property="og:description" content="Voyagez,Immortaliser,Preserver,Reviver,Partager avec votre entourage"/>
<meta property="og:site_name" content="TripAndShare"/>
<style>
html, body {
height: 100%;
margin: 0;
padding: 0;
font-family: sans-serif;
background-image: url("blueTapaTile.png");
}
#map {
<!-- left: 15%; -->
height: 100%;
width: 100%;
}
</style>
<script src="vis.js"></script>
<link href="vis-timeline-graph2d.min.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.vis-timeline {
border: 2px solid blue;
font-size: 12pt;
background: #0072c6;
}
.vis-item {
border-color: #00b7c6;
background-color: #00b7c6;
font-size: 15pt;
color: #00b7c6;
box-shadow: 5px 5px 20px rgba(128,128,128, 0.5);
}
.vis-item,
.vis-item.vis-line {
border-width: 3px;
}
.vis-item.vis-dot {
border-width: 10px;
border-radius: 10px;
}
.vis-item.vis-selected {
border-color: green;
background-color: lightgreen;
}
.vis-time-axis .vis-text {
color: #00b7c6;
padding-top: 10px;
padding-left: 10px;
}
.vis-time-axis .vis-text.vis-major {
font-weight: bold;
}
.vis-time-axis .vis-grid.vis-minor {
border-width: 2px;
border-color: #00b7c6;
}
.vis-time-axis .vis-grid.vis-major {
border-width: 2px;
border-color: #00b7c6;
}
.divbutton {
height: 50px;
background: #000;
}
button {
display: none;
}
.divbutton:hover button {
display: block;
}
.image {
position: relative;
width: 100%; /* for IE 6 */
}
#PICDSC {
position: absolute;
top: 300px;
left: 0;
width: 92%;
margin: 0 2%;
color: white;
font: bold 24px/45px Helvetica, Sans-Serif;
letter-spacing: -1px;
background: rgba(0, 0, 0, 0.7);
padding: 10px;
}
</style>
</head>
<script>
<?php
/**
* Send a GET requst using cURL
* @param string $url to request
* @param array $get values to send
* @param array $options for cURL
* @return string
*/
function curl_get($url, array $get = NULL, array $options = array())
{
$defaults = array(
CURLOPT_URL => $url. (strpos($url, '?') === FALSE ? '?' : ''). http_build_query($get),
CURLOPT_HEADER => 0,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_TIMEOUT => 4
);
$ch = curl_init();
curl_setopt_array($ch, ($options + $defaults));
if( ! $result = curl_exec($ch))
{
trigger_error(curl_error($ch));
}
curl_close($ch);
return $result;
}
$gget = array();
$options = array();
$resCurl = curl_get('http://91.134.142.192:3000/gettripbyidtrip/'. $_GET['pointtrip'], $gget, $options);
echo 'var dataDB = '. $resCurl .';';
?>
var adresseServer = "http://91.134.142.192/media";
var map;
function initMap()
{
map = new google.maps.Map(document.getElementById('map'), {
center: {lat:-17.555138,lng:-149.609086},
zoom: 10
});
setMarkers( map );
// Define a symbol using SVG path notation, with an opacity of 1.
var lineSymbol = {
path: 'M 0,-1 0,1',
strokeOpacity: 1,
scale: 3
};
var coords = [];
for( var i=0; i < dataDB.length; i++ ) {
coords.push( {lat:dataDB[i].Lat,lng:dataDB[i].Lon} );
}
// Create the polyline, passing the symbol in the 'icons' property.
// Give the line an opacity of 0.
// Repeat the symbol at intervals of 20 pixels to create the dashed effect.
var line = new google.maps.Polyline({
path: coords, //[{lat: initLat, lng: initLong}, {lat: initLat+0.1, lng: initLong+0.3}],
strokeOpacity: 0,
icons: [{
icon: lineSymbol,
offset: '0',
repeat: '20px'
}],
map: map
});
}
var markerAvion;
var imageAvion;
//var posAvion;
function setMarkers( map )
{
imageAvion = {
url: 'avion_NE.png',
size: new google.maps.Size(32, 32),
origin: new google.maps.Point(0, 0),
anchor: new google.maps.Point(16, 16)
};
markerAvion = new google.maps.Marker({
position: {lat:-17.555138,lng:-149.609086},
map: map,
icon: imageAvion,
title: "rien",
zIndex: 0
});
}
//////////////////////////////////////////////////////////////////
///////////// le mouvement de la carte d'un point à l'autre
var panPath = []; // An array of points the current panning action will use
var panQueue = []; // An array of subsequent panTo actions to take
var STEPS = 50; // The number of steps that each panTo action will undergo
var waitTime = 10;
var panAvPath = [];
function panTo(newLat, newLng) {
if (panPath.length > 0) {
// We are already panning...queue this up for next move
panQueue.push([newLat, newLng]);
} else {
// Lets compute the points we'll use
panPath.push("LAZY SYNCRONIZED LOCK"); // make length non-zero - 'release' this before calling setTimeout
var curLat = map.getCenter().lat();
var curLng = map.getCenter().lng();
var dLat = (newLat - curLat)/STEPS;
var dLng = (newLng - curLng)/STEPS;
// afficher la bonne icone en fonction de la direction du mouvement
var llAvion = markerAvion.getPosition();
var daLat = (newLat - llAvion.lat())/STEPS;
var daLng = (newLng - llAvion.lng())/STEPS;
if( daLat >= 0 ){
if( daLng >= 0 ) imageAvion.url = 'avion_NE.png'; //document.avion.src = 'avion_NE.png';
else imageAvion.url = 'avion_NW.png';
} else {
if( daLng >= 0 ) imageAvion.url = 'avion_SE.png';
else imageAvion.url = 'avion_SW.png';
}
markerAvion.setIcon( imageAvion );
// on calcule les positions de l'avion durant l'animation : l'avion peut avoir une trajectoire differente de la camera si l'utilisateur a bougé la carte
for( var i=0; i < STEPS; i++ ) {
panAvPath.push([llAvion.lat() + daLat * i, llAvion.lng() + daLng * i]);
}
panAvPath.push([newLat, newLng]);
for (var i=0; i < STEPS; i++) {
panPath.push([curLat + dLat * i, curLng + dLng * i]);
}
panPath.push([newLat, newLng]);
panPath.shift(); // LAZY SYNCRONIZED LOCK
setTimeout(doPan, waitTime);
}
}
function doPan()
{
var next = panPath.shift();
if (next != null) {
// Continue our current pan action
map.panTo( new google.maps.LatLng(next[0], next[1]));
var avNext = panAvPath.shift();
markerAvion.setPosition( new google.maps.LatLng( avNext[0], avNext[1] ) );
setTimeout(doPan, waitTime );
} else {
// We are finished with this pan - check if there are any queue'd up locations to pan to
var queued = panQueue.shift();
if (queued != null) {
panTo(queued[0], queued[1]);
}
}
}
//////////////////////////////////////////////////////////////////
function fade(element) {
var op = 1; // initial opacity
var timer = setInterval(function () {
if (op <= 0.1){
clearInterval(timer);
element.style.display = 'none';
}
element.style.opacity = op;
element.style.filter = 'alpha(opacity=' + op * 100 + ")";
op -= op * 0.1;
}, 20);
}
function unfade(element) {
var op = 0.1; // initial opacity
element.style.display = 'block';
var timer = setInterval(function () {
if (op >= 1){
clearInterval(timer);
}
element.style.opacity = op;
element.style.filter = 'alpha(opacity=' + op * 100 + ")";
op += op * 0.1;
}, 10);
}
function fadeTransitionImg(element,newSrc) {
var op = 1; // initial opacity
var timer = setInterval(function () {
if (op <= 0.1){
clearInterval(timer);
element.style.display = 'none';
element.src = newSrc;
unfade( element );
}
element.style.opacity = op;
element.style.filter = 'alpha(opacity=' + op * 100 + ")";
op -= op * 0.1;
}, 20);
}
var lastId = -1;
var timeline;
function showTravel( id )
{
if( id == lastId ) return;
if( id < 0 || id >= dataDB.length ) return;
lastId = id;
timeline.focus( id );
timeline.setSelection( id );
// document.PIC.src = dataDB[ id ].src;
fadeTransitionImg( document.PIC, adresseServer +"/"+ dataDB[ id ].mediaName );
panTo( dataDB[id].Lat, dataDB[id].Lon );
var imgDsc = document.getElementById('PICDSC');
imgDsc.innerHTML = dataDB[id].desc;
}
var indRun = 0;
var diaporamaSpeed = 3000;
function diaporamaRunning()
{
if( indRun < dataDB.length ) {
showTravel( indRun );
indRun++;
setTimeout( diaporamaRunning, diaporamaSpeed );
}
}
function diaporama()
{
indRun = 0;
setTimeout( diaporamaRunning, diaporamaSpeed/2 );
}
function firstStep(step)
{
step = (step)?step:0;
showTravel(step);
timeline.fit();
timeline.setSelection(step);
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDd8ohSW6WXH9M4U2bMFVCRGVP92dBK_tY&callback=initMap" async defer></script>
<body onload="firstStep(0);">
<center>
<table style="width:80%; height:100px">
<tr>
<td><center>
<!-- <img name="BANDEAV" src="banderolleAvion.png" style="height:100px;"> -->
<canvas id="myCanvas" width="1250px" height="200px"></canvas>
</center></td>
</tr>
</table>
<table style="width:80%">
<tr>
<td width="40%" height="500px"><div id="map" style="width:100%; height:100%"></div>
</td>
<td width="60%"><center>
<div class="image">
<img name="PIC" src="" style="height:500px;max-width:900px;width: expression(this.width > 900 ? 900: this.width);">
<div id="PICDSC"></div>
</div>
</center>
</td>
</tr>
</table>
<div id="visualization" style="width:80%;"></div>
</br>
<img src="prev.png" alt="Previous" style="width:50px;height:50px;" onclick="if( lastId>0 ) showTravel( lastId-1 );">
<img src="diaporama.png" alt="Diaporama" style="width:50px;height:50px;" onclick="diaporama();">
<img src="next.png" alt="Next" style="width:50px;height:50px;" onclick="if( lastId < dataDB.length-1 ) showTravel( lastId+1 );">
</center>
<script>
var canvas = document.getElementById('myCanvas');
var context = canvas.getContext('2d');
var imageObj = new Image();
imageObj.onload = function() {
context.drawImage(imageObj, 0, 0);
context.font = "40pt Calibri";
context.strokeText("BYOS's Trip", 60, 80);
};
imageObj.src = 'banderolleAvion.png';
</script>
<script type="text/javascript">
// DOM element where the Timeline will be attached
var container = document.getElementById('visualization');
var timelineItems = [];
//alert( dataDB.length );
for( var i=0; i < dataDB.length; i++ ) {
if( dataDB == null ) {
alert( 'NULL !!');
continue;
}
//var datetime = dataDB[i].mediaDate.replace('T', ' ').replace( 'Z', '' );
//datetime = datetime.replace(/Z/g, '');
//alert( datetime );
var datetime = dataDB[i].mediaDate;
timelineItems.push( {id: i, content: '<img src="'+ adresseServer +'/'+ dataDB[i].mediaName +'" onclick="showTravel('+ i +');" style="width:32px; height:32px;">', start:datetime } );
}
var items = new vis.DataSet( timelineItems );
var options = {};
timeline = new vis.Timeline( container, items, options );
</script>
<!-- <div id="plane"><img src="https://www.airtahitinui.com/sites/all/themes/bootstrap_atn/images/icone-avion-on.png" alt="avion" style="width:50;height:50;"></div> -->
<!-- <canvas id="canvas" width="400" height="400" style="background:#000;"></canvas> -->
</body>
</html>