-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathViewTask.html
527 lines (416 loc) · 16.2 KB
/
ViewTask.html
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
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
<HTML>
<HEAD>
<TITLE>Layout Example</TITLE>
<link rel="stylesheet" href="css/jquery.multiselect.css" />
<link rel="stylesheet" href="css/ui-darkness/jquery-ui-1.10.3.custom.min.css" />
<script src="https://www.google.com/jsapi"> </script>
<script src="http://earth-api-samples.googlecode.com/svn/trunk/lib/kmldomwalk.js" type="text/javascript"> </script>
<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
<SCRIPT type="text/javascript" src="js/jquery.layout-latest.min.js"></SCRIPT>
<script src="js/jquery-ui-1.10.3.custom.min.js"></script>
<script src="js/jquery.multiselect.min.js"></script>
<script id="loader" src="js/ajax-loader.js" type="text/javascript"></script>
<style>
.ajax_loader {background: url("img/spinner_squares_circle.gif") no-repeat bottom center transparent;width:230px;height:100%;}
.blue-loader .ajax_loader {background: url("img/ajax-loader_blue.gif") no-repeat center center transparent;}
.iframe-container {z-index: 100;}
.content-container {
margin:0px;
padding:0px;
overflow-x: hidden;
overflow-y: hidden;
}
.iframeshim {
position: absolute;
left: 0px;
top: 0px;
width: 100%;
height: 100%;
z-index: -10000;
background: black;
}
.ui-layout-pane {
padding: 0px !important;
}
#footer
{
color: #f0c;
font-size: 12px;
font-family: Verdana, Geneva, Arial, sans-serif;
background-color: #000;
text-align: center;
position: absolute;
bottom: 50px;
left: 0px;
width: 100%;
height: 18px
}
</style>
<style type="text/css">
/* remove padding and scrolling from elements that contain an Accordion OR a content-div */
.ui-layout-center , /* has content-div */
.ui-layout-west , /* has Accordion */
.ui-layout-east , /* has content-div ... */
.ui-layout-east .ui-layout-content { /* content-div has Accordion */
padding: 0;
overflow: hidden;
background: #000;
}
.ui-layout-center P.ui-layout-content {
line-height: 1.4em;
margin: 0; /* remove top/bottom margins from <P> used as content-div */
}
h3, h4 { /* Headers & Footer in Center & East panes */
font-size: 1.1em;
background: #EEF;
border: 1px solid #BBB;
border-width: 0 0 1px;
padding: 7px 10px;
margin: 0;
}
.ui-layout-east h4 { /* Footer in East-pane */
font-size: 0.9em;
font-weight: normal;
border-width: 1px 0 0;
}
.ui-layout-west{ /
font-size: 1.1em;
background: #000;
border: 1px solid #BBB;
border-width: 0 0 1px;
padding: 0px 0px;
margin: 0;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
$('body').layout({ west__size:270,
applyDefaultStyles: true });
box1 = new ajaxLoader($("#controls"));
audio = $('audio')[0];
audio.addEventListener('ended', function() {
this.currentTime = 0;
this.play();
}, false);
});
$.urlParam = function(name) {
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;
}
$(function(){
});
</script>
<script type="text/javascript">
var appPath = document.location.href.replace(/\/[^\/]*$/, '/');
var audio;
var href = $.urlParam('kmz'); // name
var namearr = href.split("/");
name = namearr[namearr.length -1 ]
document.title = name.split(".")[0];
// if ( href == null ) {
// alert("kmz not defined. Usage : ViewTask.html?kmz=fullurl.kmz");
// return;
// }
//var href = 'http://www.vololiberomontecucco.it/TaskToKmz/trofeo2013_task1.kmz';
//var href = 'http://www.vololiberomontecucco.it/docs/05082013.kmz';
var box1;
var ge;
var fullScreenState = false;
var noFullScreenIcon = null;
var fullScreenIcon = null;
var tour;
var tours = new Array();
var placemarks = new Array();
google.load("earth", "1");
google.load("maps", "2");
function init() {
google.earth.createInstance('map3d', initCB, failureCB);
}
function initCB(instance) {
ge = instance;
ge.getWindow().setVisibility(true);
ge.getNavigationControl().setVisibility(ge.VISIBILITY_SHOW);
enterTour();
createFullScreenIcon();
createNormalScreenIcon();
google.earth.addEventListener(ge.getWindow(), "click", handleMouseClick);
}
function failureCB(errorCode) {
}
function addPilot(i,pilotName,checked) {
//alert(tour.getName());
var pilotsActive =document.getElementById("pilotsActive");
var option1=document.createElement("option");
option1.text= pilotName;
option1.value = i;
option1.selected = checked;
try {
// for IE earlier than version 8
pilotsActive.add(option1,pilotsActive.options[null]);
} catch (e) {
pilotsActive.add(option1,null);
}
}
function addTour(i,pilotName) {
//alert(tour.getName());
var pilotSelect =document.getElementById("pilotToFollow");
var option=document.createElement("option");
option.text= pilotName;
option.value = i;
try {
// for IE earlier than version 8
pilotSelect.add(option,pilotSelect.options[null]);
} catch (e) {
pilotSelect.add(option,null);
}
}
// Tour control functions.
function enterTour() {
google.earth.fetchKml(ge, href, fetchCallback);
function fetchCallback(fetchedKml) {
// Alert if no KML was found at the specified URL.
if (!fetchedKml) {
setTimeout(function() {
alert('Bad or null KML');
}, 0);
return;
}
// Add the fetched KML into this Earth instance.
ge.getFeatures().appendChild(fetchedKml);
// Walk through the KML to find the tour object; assign to variable 'tour.'
var i = 0;
var k = 0;
walkKmlDom(fetchedKml, function() {
//alert(this.getType());
if (this.getType() == 'KmlTour') {
tour = this;
tours[i] = this;
addTour(i,tour.getName());
i++;
//return false;
}
if (this.getType() == 'KmlPlacemark') {
placemarks[k] = this;
addPilot(k,this.getName(),this.getVisibility());
k++;
//return false;
}
});
document.getElementById("playButton").disabled = false;
ge.getTourPlayer().setTour(tours[0]);
setTimeout(playTour,500);
$("#pilotsActive").multiselect({
height : 400,
autoOpen:true,
click: function(event, ui){
//alert(ui.value + ' ' + (ui.checked ? 'checked' : 'unchecked') );
if ( ui.checked )
placemarks[ui.value].setVisibility(true);
else
placemarks[ui.value].setVisibility(false);
},
beforeopen: function(){
//alert("Select about to be opened...");
},
open: function(){
//alert("Select opened!");
},
beforeclose: function(){
//alert("Select about to be closed...");
},
close: function(){
//alert("Select closed!");
},
checkAll: function(){
for (var i = 0; i < placemarks.length; i++) {
placemarks[i].setVisibility(true);
}
},
uncheckAll: function(){
for (var i = 0; i < placemarks.length; i++) {
placemarks[i].setVisibility(false);
}
},
optgrouptoggle: function(event, ui){
var values = $.map(ui.inputs, function(checkbox){
return checkbox.value;
}).join(", ");
alert("Checkboxes " + (ui.checked ? "checked" : "unchecked") + ": " + values);
}
});
$("#pilotToFollow").multiselect({
multiple: false,
height : 400,
header: "Select a Pilot",
noneSelectedText: "Select a Pilot",
selectedList: 1
});
//$("#playButton").button()
$( "#playButton" ).button({
icons: {
primary: "ui-icon-play"
},
text: false
});
$( "#pauseButton" ).button({
icons: {
primary: "ui-icon-pause"
},
text: false
});
$("#playButton").show();
$("#pauseButton").show();
// $("#pilotToFollow").show();
// $("#pilotsActive").show();
$("#message").text("Select Pilot to follow: ");
box1.remove();
}
}
function playTour() {
ge.getTourPlayer().play();
audio.play();
}
function pauseTour() {
ge.getTourPlayer().pause();
audio.pause();
}
function resetTour() {
ge.getTourPlayer().reset();
}
function exitTour() {
ge.getTourPlayer().setTour(null);
}
function pilotChanged(){
var myselect = document.getElementById("pilotToFollow");
var pilotID = myselect.options[myselect.selectedIndex].value;
var currentTime = ge.getTourPlayer().getCurrentTime();
var oldDuration = ge.getTourPlayer().getDuration()
ge.getTourPlayer().setTour(tours[pilotID]);
var newDuration = ge.getTourPlayer().getDuration()
ge.getTourPlayer().setCurrentTime(currentTime * oldDuration / newDuration);
ge.getTourPlayer().play();
}
function handleMouseClick(event){
var INSET_PIXELS_X = document.getElementById("map3d").offsetWidth - event.getClientX();
var INSET_PIXELS_Y = event.getClientY();
if (INSET_PIXELS_X < 32){
if (INSET_PIXELS_Y < 32){ toggleFullScreen();}
}
}
function toggleFullScreen(){
if (fullScreenState == true) {makeNormalScreen();}
else {makeFullScreen();}
}
function makeFullScreen(){
var samplecontainer = document.getElementById('app');
var container = document.getElementById('map3d');
container.style.left = 0;
container.style.top = 0;
container.style.width = samplecontainer.offsetWidth + 'px';
container.style.height = samplecontainer.offsetHeight + 'px';
fullScreenState = true;
noFullScreenIcon.setVisibility(fullScreenState);
fullScreenIcon.setVisibility(!fullScreenState);
}
function makeNormalScreen(){
var samplecontainer = document.getElementById('app');
var container = document.getElementById('map3d');
container.style.left = samplecontainer.style.left;
container.style.top = samplecontainer.style.top;
container.style.width = samplecontainer.offsetWidth + 'px';
container.style.height = samplecontainer.offsetHeight + 'px';
fullScreenState = false;
noFullScreenIcon.setVisibility(fullScreenState);
fullScreenIcon.setVisibility(!fullScreenState);
}
function createFullScreenIcon() {
// create an image for the screen overlay
var icon = ge.createIcon('');
icon.setHref('http://earth-api-samples.googlecode.com/svn/trunk/external/dinther_fullscreen_tofull.png');
// create the screen overlay
fullScreenIcon = ge.createScreenOverlay('');
fullScreenIcon.setDrawOrder(60);
fullScreenIcon.setIcon(icon);
// anchor point in top left of icon.
fullScreenIcon.getScreenXY().setXUnits(ge.UNITS_FRACTION);
fullScreenIcon.getScreenXY().setYUnits(ge.UNITS_FRACTION);
fullScreenIcon.getScreenXY().setX(1);
fullScreenIcon.getScreenXY().setY(1);
// place icon in top left of screen.
fullScreenIcon.getOverlayXY().setXUnits(ge.UNITS_INSET_PIXELS);
fullScreenIcon.getOverlayXY().setYUnits(ge.UNITS_INSET_PIXELS);
fullScreenIcon.getOverlayXY().setX(2);
fullScreenIcon.getOverlayXY().setY(4);
// Set icon size.
fullScreenIcon.getSize().setXUnits(ge.UNITS_PIXELS);
fullScreenIcon.getSize().setYUnits(ge.UNITS_PIXELS);
fullScreenIcon.getSize().setY(32);
fullScreenIcon.getSize().setX(32);
// add the screen overlay to Earth
ge.getFeatures().appendChild(fullScreenIcon);
}
function createNormalScreenIcon() {
// create an image for the screen overlay
var icon = ge.createIcon('');
icon.setHref('http://earth-api-samples.googlecode.com/svn/trunk/external/dinther_fullscreen_tonormal.png');
// create the screen overlay
noFullScreenIcon = ge.createScreenOverlay('');
noFullScreenIcon.setDrawOrder(62);
noFullScreenIcon.setIcon(icon);
// anchor point in top left of icon.
noFullScreenIcon.getScreenXY().setXUnits(ge.UNITS_FRACTION);
noFullScreenIcon.getScreenXY().setYUnits(ge.UNITS_FRACTION);
noFullScreenIcon.getScreenXY().setX(1);
noFullScreenIcon.getScreenXY().setY(1);
// place icon in top right of screen.
noFullScreenIcon.getOverlayXY().setXUnits(ge.UNITS_INSET_PIXELS);
noFullScreenIcon.getOverlayXY().setYUnits(ge.UNITS_INSET_PIXELS);
noFullScreenIcon.getOverlayXY().setX(2);
noFullScreenIcon.getOverlayXY().setY(4);
// Set icon size.
noFullScreenIcon.getSize().setXUnits(ge.UNITS_PIXELS);
noFullScreenIcon.getSize().setYUnits(ge.UNITS_PIXELS);
noFullScreenIcon.getSize().setY(32);
noFullScreenIcon.getSize().setX(32);
noFullScreenIcon.setVisibility(false);
// add the screen overlay to Earth
ge.getFeatures().appendChild(noFullScreenIcon);
}
function handleFullScreen(){
if (window.innerWidth == screen.width){
if (window.innerHeight > screen.height - 10){
//this is likely caused by pressing F11 on the browser
makeFullScreen();
} else if (fullScreenState == true) { makeNormalScreen();}
} else {makeNormalScreen();}
}
google.setOnLoadCallback(init);
</script>
</HEAD>
<BODY >
<DIV class="ui-layout-center" style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%;padding:0px;">
<div id="map3d" style="padding:0px;">
</div>
<audio id="audio" src="music/music.ogg" preload="auto">
</DIV>
<DIV class="ui-layout-west" style="padding:0px;">
<div class="ui-layout-content" style="background-color:black;color:white;padding:0px;">
<button style = "display:none" id="playButton" onclick="playTour()" value="Start" > </button>
<button style = "display:none" id="pauseButton" onclick="pauseTour()" value="Pause"> </button>
<br>
<hr>
<label id="message">Loading ... Please wait </label>
<br>
<select style = "display:none;" id="pilotToFollow" onchange="pilotChanged()"> </select>
<hr>
<label >Select Pilots to show </label>
<br>
<select style = "display:none;" id="pilotsActive" multiple="multiple" > </select>
<div id="footer">
<p >Realized with TaskToKmz - Source Code available @ <a style=color:white;" href="https://github.com/ToninoTarsi/TaskToKmz">https://github.com/ToninoTarsi/TaskToKmz</a> </p>
</div>
</div>
</DIV>
<!-- <DIV class="ui-layout-south">South</DIV> -->
</BODY>
</HTML>