-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_en.html
executable file
·1564 lines (1423 loc) · 73.1 KB
/
index_en.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
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
var language = 'en';
var str_title = 'Roadbook generator v0.4';
var str_distance = 'Distance:';
var str_distance_unit = ' km';
var str_timetravel = 'Travel time: ';
var str_timetravel_unit = ' minutes';
var str_nblines_intersections = 'Nb lines/intersections: ';
var str_menu_preview_switch = 'Switch preview Tablet <-> A4' ;
var str_menu_preview_mouseover = 'Tablet=1 page per line<br/>A4 = 2x10 lines per page';
var str_menu_export_tablet = 'Tablet PDF Export' ;
var str_menu_tablet_mouseover = '';
var str_menu_export_A4 = 'A4 PDF Export';
var str_menu_A4_mouseover ='';
var str_menu_save = 'Save';
var str_menu_load = 'Load';
var str_default_filename = 'MyRoadbook_' ;
var str_option_title = 'Option config';
var str_option_directions = 'Route for :';
var str_option_car = 'Driving';
var str_option_bike = 'Bike';
var str_option_pedestrian = 'Walking';
var str_option_restritions = 'Restrictions : ';
var str_option_avoid_toll = 'No toll';
var str_option_avoid_highway = 'No highway';
var str_option_avoid_ferry = 'No ferries';
var str_option_no_avoid = 'No restriction';
var str_render = 'Symbology :';
var str_render_arrow = 'Arrows';
var str_render_fishbone = 'Fishbone'
var str_rb_total_distance = 'Total Distance';
var str_rb_partial_distance = 'Partial';
var str_rb_note = 'Note';
var str_rb_description = 'Description';
var str_rb_ith_out = 'th out / ';
var str_map_road = 'roads';
var str_map_hiking = 'hiking';
var str_map_satellite = 'satellite';
var str_map_find = 'Find';
var str_help = 'Help';
var str_help_title = "Roadbook Generator help";
var str_help_page01 = "Welcome to the Roadbook Generator";
var str_help_page02 = "Let's begin our roadbook ! In the search box, at the upper right corner";
var str_help_page03 = "enter the first letters of the departure, then click on the suggested place";
var str_help_page04 = "Map will zoom to the selected place";
var str_help_page05 = "Move/Zoom to the correct departure, with mouse or keyboard (arrows and + - keys)";
var str_help_page06 = "Select the <bold>Line</bold> tool to switch to edit mode. Mouse cursor will change...";
var str_help_page07 = "and click on the departure place. A circle will appear";
var str_help_page08 = "Pan/zoom the map to next waypoint and click where it should be. Repeat for all waypoints";
var str_help_page09 = "Double-click for the arrival waypoint. Roadbook will appear on the left.";
var str_help_page10 = "To insert a waypoint, put your mouse over the dotted line. Mouse cursor will change...";
var str_help_page11 = "and double-click. Roadbook will be updated.";
var str_help_page12 = "To move a waypoint : click on the circle to select it, then drag and drop it to the new place.\
To remove it, first select it, then click on the trash icon in the toolbar";
var str_help_page13 = "The config menu lets you choose routing options (driving/bike/walking), restrictions and \
symbology of the roadbook : arrows (default) or fishbone. \
You can switch at anytime, roadbook will be updated accordingly.";
var str_help_page14 = "Here is the same raodbook in fishbone symbology.";
var str_help_page15 = "Select page setup.";
var str_help_page16 = "In tablet mode, each page of the resulting PDF will contain only one roadbook line";
var str_help_page17 = "In A4 mode, each PDF page will contain 2 columns of 9 lines.";
var str_help_page18 = "Click on the export button depending your preferred choice. It will download your roadbook.";
var str_help_end = "Have fun and be careful while driving/riding !";
var str_contact = 'Contact : rpiroadbook at gmail dot com';
var str_git_link = 'Bug reports : <a href="https://github.com/tqhien/RoadbookGen">the project Github</a>';
var str_error_file_unreadable = 'File unreadable';
var str_json_load = 'Choose a geoJSON file to restore :';
var str_button_cancel = 'Cancel';
var str_button_reload = 'Load';
</script>
<meta charset='utf-8' />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>RpiRoadbook RB Gen using Mapbox Directions API v0.4</title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v2.5.1/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v2.5.1/mapbox-gl.css' rel='stylesheet' />
<link rel="stylesheet" href="font-awesome.min.css">
<link rel="stylesheet" href="w3.css">
<script src="html2pdf.bundle.min.js"></script>
<script src="turf.min.js"></script>
<script src="myAPIKey.js"></script>
<script>
function switch_tablette_A4() {
var x = document.getElementById('directions_instructions');
var y = document.getElementById('directions_instructions_A4');
var x2 = document.getElementById('directions_intersections_instructions');
var y2 = document.getElementById('directions_intersections_instructions_A4');
// var z1 = document.getElementsByClassName('info-box');
//var z2 = document.getElementsByClassName('stats');
var schema_options = document.getElementById('schema_form').elements['schema_options'].value ;
if (schema_options == 'boulefleche') {
if (x.style.display === "none") {
x.style.display = "block";
y.style.display = "none" ;
x2.style.display = "none";
y2.style.display = "none" ;
// z1[0].style.left = '400px';
// z2[0].style.left = '400px';
} else {
x.style.display = "none";
y.style.display = "block" ;
x2.style.display = "none";
y2.style.display = "none" ;
// z1[0].style.left = '800px';
// z2[0].style.left = '800px';
}
}
else {
if (x2.style.display === "none") {
x.style.display = "none";
y.style.display = "none" ;
x2.style.display = "block";
y2.style.display = "none" ;
// z1[0].style.left = '400px';
// z2[0].style.left = '400px';
} else {
x.style.display = "none";
y.style.display = "none" ;
x2.style.display = "none";
y2.style.display = "block" ;
// z1[0].style.left = '800px';
// z2[0].style.left = '800px';
}
}
}
function printPDF() {
var schema_options = document.getElementById('schema_form').elements['schema_options'].value ;
if (schema_options == 'boulefleche') {
var element = document.getElementById('instructions');
} else {
var element = document.getElementById('instructions_fishbone');
}
// Enable all 'modes', with no explicit elements.
html2pdf().set({
pagebreak: { mode: ['avoid-all', 'css', 'legacy'] }
});
var opt = {
margin: 1,
filename: str_default_filename+'rb.pdf',
image: { type: 'jpeg', quality: 0.98 },
//html2canvas: { allowTaint:true,foreignObjectRendering:true},
html2canvas: { allowTaint:true},
jsPDF: { unit: 'mm', format: [105,35], orientation: 'landscape'}
};
html2pdf().from(element).set(opt).save();
}
var myDirections = '' ;
var myPoints = '' ;
function printPDF_A4() {
var schema_options = document.getElementById('schema_form').elements['schema_options'].value ;
if (schema_options == 'boulefleche') {
var element = document.getElementById('instructions_A4');
} else {
var element = document.getElementById('instructions_fishbone_A4');
}
// Enable all 'modes', with no explicit elements.
html2pdf().set({
pagebreak: { mode: ['avoid-all', 'css', 'legacy'] }
});
var opt = {
margin: 1,
filename: str_default_filename+'A4.pdf',
image: { type: 'jpeg', quality: 0.98 },
html2canvas: { allowTaint:true },
jsPDF: { unit: 'mm', format: [210,291], orientation: 'portrait'}
};
html2pdf().from(element).set(opt).save();
}
function savePoints() {
var features = draw.getAll();
// Keeping only last linestring
var removed = features.features.splice(0,features.features.length-1) ;
myPoints = JSON.stringify(features) ;
// Saving on browser local storage
localStorage.myPoints = myPoints ;
localStorage.myDirections = myDirections ;
// Download to file on client side
//var file = new Blob([myDirections,'\r\n',myPoints], {type: 'text/plain'});
var file = new Blob([myPoints], {type: 'text/plain'});
if (window.navigator.msSaveOrOpenBlob) // IE10+
window.navigator.msSaveOrOpenBlob(file, 'mesPoints.geoJSON');
else { // Others
var a = document.createElement("a"),
url = URL.createObjectURL(file);
a.href = url;
a.download = 'mesPoints.geoJSON';
document.body.appendChild(a);
a.click();
setTimeout(function() {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
}
function restorePoints() {
if (localStorage.myPoints != null) {
var features = JSON.parse(localStorage.myPoints) ;
myDirections = localStorage.myDirections ;
getMatch(myDirections) ;
draw.set(features) ;
} ;
}
var slideIndex = 1;
//showDivs(slideIndex);
function plusDivs(n) {
showDivs(slideIndex += n);
}
function showDivs(n) {
var i;
var x = document.getElementsByClassName("mySlides");
if (n > x.length) {slideIndex = 1}
if (n < 1) {slideIndex = x.length} ;
for (i = 0; i < x.length; i++) {
x[i].style.display = "none";
}
x[slideIndex-1].style.display = "block";
}
function handleRbFiles(files) {
// Check for the various File API support.
if (window.FileReader) {
// FileReader are supported.
getAsText(files[0]);
document.getElementById('restore').style.display='none' ;
} else {
alert('FileReader are not supported in this browser.');
}
}
function getAsText(fileToRead) {
var reader = new FileReader();
// Handle errors load
reader.onload = loadHandler;
reader.onerror = errorHandler;
// Read file into memory as UTF-8
reader.readAsText(fileToRead);
}
function loadHandler(event) {
myPoints = event.target.result;
var t = JSON.parse(myPoints) ;
var l = '' ;
for (var i=0;i<t['features'][0].geometry.coordinates.length; i++) {
l = l + t['features'][0].geometry.coordinates[i][0] + ',' + t['features'][0].geometry.coordinates[i][1] + ';'
}
l = l.slice(0, -1); //remove last semi-colom
localStorage.myDirections = l;
localStorage.myPoints = myPoints;
restorePoints() ;
}
function errorHandler(evt) {
if(evt.target.error.name == "NotReadableError") {
alert(str_error_file_unreadable);
}
}
</script>
<style>
html,body {
height:100% ;
width:100% ;
}
#rb { max-width: 400px;max-height:80%;overflow-y:auto;overflow-x: auto; }
#directions_instructions {
top: 0; bottom:0; left:0; width:400px; height:100%;
background-color: rgba(255, 255, 255, 0.8);
overflow: auto ;
font-family: sans-serif;
}
#instructions {
position:relative;
font-size:12px;
width:380px;
}
#directions_instructions_A4 {
top: 0; bottom:0; left:0; width:800px; height:100%;
background-color: rgba(255, 255, 255, 0.8);
overflow: auto ;
font-family: sans-serif;
}
#instructions_A4 {
position:relative;
font-size:12px;
width:760px;
}
table {
border: medium solid #6495ed;
border-collapse: collapse;
width: 380px;
}
#instructable_A4 {
border: medium solid #6495ed;
border-collapse: collapse;
width: 760px;
}
th {
font-family: monospace;
border: thin solid #6495ed;
padding: 0px;
background-color: #D0E3FA;
}
tr {
padding: 0px;
max-height: 100px ;
overflow: hidden ;
}
td {
font-family: sans-serif;
border: thin solid #6495ed;
padding: 0px;
text-align: center;
background-color: #ffffff;
height:100px;
max-height: 100px;
overflow:hidden;
}
caption {
font-family: sans-serif;
}
.total_distance_header {
font-size: 10px;
text-align: center;
position: relative;
}
.numero {
top:0px;
font-size: 10px;
text-align: left;
position: relative;
}
.total_distance {
font-size: 40px;
text-align: center;
position: relative;
}
.partial_distance {
position: relative;
font-size:10px;
bottom:0px;
text-align: right;
background-color: rgba(125,125,125,0.9);
}
.space_distance {
position: relative;
height:10px;
}
.instruction {
position: relative;
height:67px;
overflow:hidden;
}
.route {
position: relative;
bottom:0px;
text-align: center;
font-size:15px;
/* background-color: rgba(125,125,125,0.9); */
outline : 1px solid;
overflow:hidden;
height:20px;
max-height:20px;
}
.img_direction {
width: 100px;
height:100px;
font-size: 25px;
text-align: center;
position: relative;
}
#map { position:absolute; top:0; bottom:0; left:0px; right:0px; }
#mapmenu {
position: absolute;
background: #fff;
padding: 10px;
font-family: 'Open Sans', sans-serif;
}
</style>
</head>
<body>
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.0.9/mapbox-gl-draw.js'></script>
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-draw/v1.0.9/mapbox-gl-draw.css' type='text/css'/>
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-directions/v4.1.0/mapbox-gl-directions.js'></script>
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-directions/v4.1.0/mapbox-gl-directions.css' type='text/css' />
<script src='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v4.3.0/mapbox-gl-geocoder.min.js'></script>
<link rel='stylesheet' href='https://api.mapbox.com/mapbox-gl-js/plugins/mapbox-gl-geocoder/v4.3.0/mapbox-gl-geocoder.css' type='text/css' />
<!-- definition du layout -->
<!-- Titre -->
<div id='RbGen' class='w3-container w3-row'>
<div class='w3-col m3 w3-light-blue'>
<div id='calculated-line'>
<script type="text/javascript">
document.write(str_distance+' '+str_distance_unit+'<br>'+str_timetravel+' '+str_timetravel_unit+'<br>'+str_nblines_intersections);
</script>
</div>
<div id='info' class='stats'></div>
</div>
<div class='w3-col m8 w3-center'>
<h1><script type="text/javascript">
document.write(str_title);
</script></h1>
</div>
<div class='w3-col m1 w3-right'>
<!-- Trigger/Open the Modal -->
<button onclick="document.getElementById('config').style.display='block'" class="w3-button w3-right"><i class="w3-xxlarge fa fa-gear"></i></button>
<!-- The Config Modal -->
<div id="config" class="w3-modal">
<div class="w3-modal-content">
<div class="w3-container">
<span onclick="document.getElementById('config').style.display='none'"
class="w3-button w3-display-topright">×</span>
<h2><script type="text/javascript">
document.write(str_option_title);
</script></h2>
<hr>
<!-- Choix du mode -->
<form id="mode_form" class="w3-container w3-left">
<script type="text/javascript">
document.write(str_option_directions);
</script>
<input class="w3-radio" type="radio" name="mode_transport" value="vl" checked>
<label><script type="text/javascript">
document.write(str_option_car);
</script></label>
<input class="w3-radio" type="radio" name="mode_transport" value="velo">
<label><script type="text/javascript">
document.write(str_option_bike);
</script></label>
<input class="w3-radio" type="radio" name="mode_transport" value="piéton">
<label><script type="text/javascript">
document.write(str_option_pedestrian);
</script></label>
</form>
<!-- Option de routage -->
<form id="options_form" class="w3-container w3-left">
<script type="text/javascript">
document.write(str_option_restritions);
</script>
<input class="w3-radio" type="radio" name="transport_options" value="toll">
<label><script type="text/javascript">
document.write(str_option_avoid_toll);
</script></label>
<input class="w3-radio" type="radio" name="transport_options" value="motorway" checked>
<label><script type="text/javascript">
document.write(str_option_avoid_highway);
</script></label>
<input class="w3-radio" type="radio" name="transport_options" value="ferry">
<label><script type="text/javascript">
document.write(str_option_avoid_ferry);
</script></label>
<input class="w3-radio" type="radio" name="transport_options" value="no_limit">
<label><script type="text/javascript">
document.write(str_option_no_avoid);
</script></label>
</form>
<br><br><br>
<hr>
<!-- Option de representation -->
<form id="schema_form" class="w3-container w3-left">
<script type="text/javascript">
document.write(str_render);
</script>
<input class="w3-radio" type="radio" name="schema_options" value="boulefleche" checked>
<label><script type="text/javascript">
document.write(str_render_arrow);
</script></label>
<input class="w3-radio" type="radio" name="schema_options" value="fishbone">
<label><script type="text/javascript">
document.write(str_render_fishbone);
</script></label>
</form>
<br><br>
</div>
</div>
</div>
</div>
</div>
<!-- Barre de fonctions -->
<div id='menu' class='w3-bar w3-black'>
<button class='w3-bar-item w3-button w3-hover-green' type="button" title="" onclick="switch_tablette_A4();"><script type="text/javascript">
document.write(str_menu_preview_switch);
</script></button>
<button class='w3-bar-item w3-button w3-hover-red' type="button" onclick="printPDF();"><script type="text/javascript">
document.write(str_menu_export_tablet);
</script></button>
<button class='w3-bar-item w3-button w3-hover-blue' type="button" onclick="printPDF_A4();"><script type="text/javascript">
document.write(str_menu_export_A4);
</script></button>
<button class='w3-bar-item w3-button w3-hover-blue' type="button" onclick="savePoints();"><script type="text/javascript">
document.write(str_menu_save);
</script></button>
<button onclick="document.getElementById('restore').style.display='block'" class='w3-bar-item w3-button w3-hover-blue' type="button"><script type="text/javascript">
document.write(str_menu_load);
</script></button>
<!-- The Restore Modal -->
<div id="restore" class="w3-modal w3-text-black">
<div class="w3-modal-content">
<div class="w3-container">
<span onclick="document.getElementById('restore').style.display='none'"
class="w3-button w3-display-topright">×</span>
<h2><script type="text/javascript">
document.write(str_json_load);
</script></h2>
<hr>
<form class="w3-container w3-left">
<input type="file" id="rbFileInput" onchange="handleRbFiles(this.files)" accept=".geoJSON">
<button onclick="document.getElementById('restore').style.display='none'" class='w3-bar-item w3-button w3-hover-blue w3-right' type="button"><script type="text/javascript">document.write(str_button_cancel);</script></button>
<button onclick="handleRbFiles(document.getElementById('rbFileInput').files)" class='w3-bar-item w3-green w3-button w3-hover-blue w3-right' type="button"><script type="text/javascript">document.write(str_button_reload);</script></button>
</form>
</div>
</div>
</div>
<!-- <a href="index_es.html" class="w3-button w3-black w3-right">ES</a>
<a href="index_it.html" class="w3-button w3-black w3-right">IT</a>
<a href="index_de.html" class="w3-button w3-black w3-right">DE</a> -->
<a href="index.html" class="w3-button w3-black w3-right">FR</a>
</div>
<!-- Le Roadbook -->
<div id='rb' style='float:left;width:400px'>
<!-- Format RB -->
<div id='directions_instructions' >
<div id='instructions'>
<table id='instructable'>
<thead>
<tr>
<th width=100px><div class="total_distance_header"><script type="text/javascript">document.write(str_rb_total_distance);</script></div><p>
<div class="partial_distance"><script type="text/javascript">document.write(str_rb_partial_distance);</script></div></th>
<th width=100px><div class="total_distance_header"><script type="text/javascript">document.write(str_rb_note);</script></div></th>
<th width=180px><div class="total_distance_header"><script type="text/javascript">document.write(str_rb_description);</script></div></th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<th width=100px><div class="total_distance_header"><script type="text/javascript">document.write(str_rb_total_distance);</script></div><p>
<div class="partial_distance"><script type="text/javascript">document.write(str_rb_partial_distance);</script></div></th>
<th width=100px><div class="total_distance_header"><script type="text/javascript">document.write(str_rb_note);</script></div></th>
<th width=180px><div class="total_distance_header"><script type="text/javascript">document.write(str_rb_description);</script></div></th>
</tr>
</tfoot>
</table>
</div>
</div>
<!-- Format A4 -->
<div id='directions_instructions_A4' style="float:left;width:800px;display: none;">
<div id='instructions_A4'>
<table id='instructable_A4'>
<tbody>
</tbody>
</table>
</div>
</div>
<!-- Format allemandRB -->
<div id='directions_intersections_instructions' style="float:left;width:400px;display: none;">
<div id='instructions_fishbone'>
<table id='fishbonetable'>
<thead>
<tr>
<th width=100px><div class="total_distance_header"><script type="text/javascript">document.write(str_rb_total_distance);</script></div><p>
<div class="partial_distance"><script type="text/javascript">document.write(str_rb_partial_distance);</script></div></th>
<th width=100px><div class="total_distance_header"><script type="text/javascript">document.write(str_rb_note);</script></div></th>
<th width=180px><div class="total_distance_header"><script type="text/javascript">document.write(str_rb_description);</script></div></th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<th width=100px><div class="total_distance_header"><script type="text/javascript">document.write(str_rb_total_distance);</script></div><p>
<div class="partial_distance"><script type="text/javascript">document.write(str_rb_partial_distance);</script></div></th>
<th width=100px><div class="total_distance_header"><script type="text/javascript">document.write(str_rb_note);</script></div></th>
<th width=180px><div class="total_distance_header"><script type="text/javascript">document.write(str_rb_description);</script></div></th>
</tr>
</tfoot>
</table>
</div>
</div>
<!-- Format allemandA4 -->
<div id='directions_intersections_instructions_A4' style="float:left;width:800px;display: none;">
<div id='instructions_fishbone_A4'>
<table id='fishbone_A4'>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
<!-- Partie carte et réglages -->
<div id='mapdiv' style='float:left;width:calc(100% - 400px);height:80%;top:0'>
<!-- Carte -->
<div style='position:relative;height:90%'>
<div id='map' >
</div>
<div id="mapmenu">
<input
id="streets-v11"
type="radio"
name="rtoggle"
value="streets"
checked="checked"
/>
<label for="streets"><script type="text/javascript">document.write(str_map_road);</script></label>
<input id="outdoors-v11" type="radio" name="rtoggle" value="outdoors" />
<label for="outdoors"><script type="text/javascript">document.write(str_map_hiking);</script></label>
<input id="satellite-streets-v11" type="radio" name="rtoggle" value="satellite" />
<label for="satellite"><script type="text/javascript">document.write(str_map_satellite);</script></label>
</div>
</div>
<!-- Trigger/Open the Modal -->
<button onclick="document.getElementById('help_fr').style.display='block'" class="w3-button w3-right"><script type="text/javascript">document.write(str_help);</script></button>
<!-- The Help Modal -->
<div id="help_fr" class="w3-modal">
<div class="w3-modal-content">
<div class="w3-container">
<span onclick="document.getElementById('help_fr').style.display='none'"
class="w3-button w3-display-topright">×</span>
<h2><script type="text/javascript">document.write(str_help_title);</script></h2>
<hr>
<div class="w3-content w3-display-container">
<div class="mySlides" style="display:block">
<img src="help/01-help.png" style="width:100%">
<div class="w3-display-middle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page01);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/02-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page02);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/03-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page03);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/04-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page04);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/05-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page05);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/06-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page06);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/07-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page07);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/08-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page08);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/09-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page09);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/10-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page10);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/11-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page11);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/12-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page12);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/13-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page13);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/14-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page14);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/15-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page15);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/16-help.png" style="width:100%">
<div class="w3-display-topmiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page16);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/17-help.png" style="width:100%">
<div class="w3-display-topmiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page17);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/18-help.png" style="width:100%">
<div class="w3-display-bottommiddle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_page18);</script>
</div>
</div>
<div class="mySlides" style="display:none">
<img src="help/01-help.png" style="width:100%">
<div class="w3-display-middle w3-container w3-padding-16 w3-black">
<script type="text/javascript">document.write(str_help_end);</script>
</div>
</div>
<button class="w3-button w3-display-left" onclick="plusDivs(-1)">❮</button>
<button class="w3-button w3-display-right" onclick="plusDivs(+1)">❯</button>
</div>
</div>
</div>
</div>
</div>
<!-- Partie à propos et aide -->
<div id='apropos' class='w3-container'>
<div class='w3-container w3-right'>
<p><script type="text/javascript">document.write(str_contact);</script></p>
<p><script type="text/javascript">document.write(str_git_link);</script></p>
</div>
</div>
<script>
mapboxgl.accessToken = myMapBoxToken ;
var map = new mapboxgl.Map({
container: 'map', // container id
style: 'mapbox://styles/mapbox/streets-v9', //style par défaut
center: [2.950,46.955], // position de départ
zoom: 14 // zoom initial
});
// MapStyles
var layerList = document.getElementById('mapmenu');
var inputs = layerList.getElementsByTagName('input');
function switchLayer(layer) {
var layerId = layer.target.id;
map.setStyle('mapbox://styles/mapbox/' + layerId);
updateRoute() ;
}
for (var i = 0; i < inputs.length; i++) {
inputs[i].onclick = switchLayer;
}
var draw = new MapboxDraw({
displayControlsDefault: false,
clickBuffer: 10,
controls: {
line_string: true,
trash: true
},
styles: [
// ACTIVE (being drawn)
// line stroke
{
"id": "gl-draw-line",
"type": "line",
"filter": ["all", ["==", "$type", "LineString"], ["!=", "mode", "static"]],
"layout": {
"line-cap": "round",
"line-join": "round"
},
"paint": {
"line-color": "#3b9ddd",
"line-dasharray": [0.2, 2],
"line-width": 4,
"line-opacity": 0.7
}
},
// vertex point halos
{
"id": "gl-draw-polygon-and-line-vertex-halo-active",
"type": "circle",
"filter": ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"], ["!=", "mode", "static"]],
"paint": {
"circle-radius": 10,
"circle-color": "#ff0066"
}
},
// vertex points
{
"id": "gl-draw-polygon-and-line-vertex-active",
"type": "circle",
"filter": ["all", ["==", "meta", "vertex"], ["==", "$type", "Point"], ["!=", "mode", "static"]],
"paint": {
"circle-radius": 6,
"circle-color": "#3b9ddd",
}
},
]
});
// add the geocoding tool to the map
map.addControl(new MapboxGeocoder({
accessToken: mapboxgl.accessToken,
mapboxgl: mapboxgl
}));
// add the draw tool to the map
map.addControl(draw);
// Add zoom and rotation controls to the map.
map.addControl(new mapboxgl.NavigationControl());
// Add geolocate control to the map.
map.addControl(
new mapboxgl.GeolocateControl({
positionOptions: {
enableHighAccuracy: true
},
trackUserLocation: true
})
);
// add create, update, or delete actions
map.on('draw.create', updateRoute);
map.on('draw.update', updateRoute);
map.on('draw.delete', removeRoute);
// pour debug, position du curseur
// map.on('mousemove', function (e) {
// document.getElementById('info').innerHTML =
// //e.point is the x, y coordinates of the mousemove event relative
// //to the top-left corner of the map
// JSON.stringify(e.point) + '<br />' +
// //e.lngLat is the longitude, latitude geographical position of the event
// JSON.stringify(e.lngLat);
// });
map.on('load', function() {
map.getCanvas().focus();
// pour test ajout d'évènement sur touche
map.getCanvas().addEventListener('keydown', function(e) {
e.preventDefault();
if (e.which === 13) { // enter
console.log ('Enter') ;
} else if (e.which === 38) { // up
console.log ('Up') ;
} else if (e.which === 40) { // down
console.log ('Down') ;
} else if (e.which === 45) { // Insert
console.log ('Insert') ;
//draw.changeMode('cut_line');
}
});
});
// traitement du double clic
map.on('dblclick', function(e) {
const ids = draw.getFeatureIdsAt(e.point);
if (!ids.length) { return; }
// TODO : traitement de l'erreur fin de saisie draw vs insert point
// On récupère la ligne
const line = draw.get(ids[0]) ;
if (typeof line === 'undefined') {return;}
const old_line = line.geometry.coordinates ;
// Positions du curseur et du noeud précédent
const cursorAt = turf.point([e.lngLat.lng, e.lngLat.lat]);
const snapped = turf.pointOnLine(line, cursorAt);
// Insertion du point dans l'array de la linestring
// snapped.properties.index contient l'index du noeud précédent
old_line.splice(snapped.properties.index+1,0,cursorAt.geometry.coordinates) ;
// Construction de la nouvelle ligne, en gardant le même id
var feature = {
id : ids[0],
type : 'Feature',
properties: {},
geometry : {type : 'LineString', coordinates: old_line }
} ;
// On met à jour la ligne
var features = draw.add(feature) ;
// On met à jour le roadbook
updateRoute() ;
});
// Fonctions de dessin des fishbone
function drawFish(canvas, context,l,r){
var imagePaper = new Image();
imagePaper.onload = function(){
// dessin de la flèche vers le haut
context.save() ;
context.translate(100,100) ;
context.drawImage(imagePaper,-100, -100);
context.restore() ;
// dessin des traits
context.beginPath();
context.lineWidth=10;
var x1 = 100 ;
var y1 = 100 ;
var rayon = 65;
context.moveTo(x1, y1-rayon);
context.lineTo(x1, y1+rayon);