-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathGeocaching_Map_Enhancements.user.js
More file actions
3174 lines (3137 loc) · 194 KB
/
Copy pathGeocaching_Map_Enhancements.user.js
File metadata and controls
3174 lines (3137 loc) · 194 KB
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
// ==UserScript==
// @name Geocaching Map Enhancements
//--> $$001
// @version 0.8.2.2As.13
//<-- $$001
// @author JRI; 2Abendsegler
// @description Adds extra maps and grid reference search to Geocaching.com, along with several other enhancements.
// @include /^https:\/\/www.geocaching.com\/(geocache\/GC|seek\/cache_details\.aspx|seek\/cache_details2\.aspx|map\/|hide\/planning\.aspx|hide\/typelocation\.aspx|hide\/waypoints\.aspx|seek\/$|\/seek\/default\.aspx|track\/map_gm\.aspx)/
// @license MIT License
// @namespace https://github.com/2Abendsegler/GME
// @copyright 2022-2026 2Abendsegler, (2011-2018 James Inge)
// @attribution GeoNames (http://www.geonames.org/)
// @attribution Postcodes.io (https://postcodes.io/)
// @attribution Chris Veness (http://www.movable-type.co.uk/scripts/latlong-gridref.html)
// @grant GM_xmlhttpRequest
// @grant GM.xmlHttpRequest
// @grant GM_info
// @grant GM.info
// @grant GM_getValue
// @grant GM.getValue
// @grant GM_setValue
// @grant GM.setValue
// @connect github.com
// @connect raw.githubusercontent.com
// @connect geograph.org.uk
// @connect channel-islands.geographs.org
// @connect geo-en.hlipp.de
// @connect api.geonames.org
// @connect api.postcodes.io
// @connect www.geocaching.com
// @uploadURL https://raw.githubusercontent.com/2Abendsegler/GME/main/Geocaching_Map_Enhancements.user.js
// @downloadURL https://raw.githubusercontent.com/2Abendsegler/GME/main/Geocaching_Map_Enhancements.user.js
// @icon https://github.com/2Abendsegler/GME/raw/main/images/gme_logo_48.png
// @icon64 https://github.com/2Abendsegler/GME/raw/main/images/gme_logo_64.png
// ==/UserScript==
/* jshint multistr: true */
/* global $, amplify, DMM, FileReader, GM, GM_xmlhttpRequest, Groundspeak, L, LatLon, mapLatLng, MapSettings */
(function() {
"use strict";
var gmeResources = {
parameters: {
// Defaults.
//--> $$002
// Hier nur anpassen wenn die Version als nächstes Live geht oder testweise neue Parameter in den Speicher sollen.
version: "0.8.2.2As.13",
//<-- $$002
brightness: 1, // Default brightness for maps (0-1), can be overridden by custom map parameters.
filterFinds: false, // True filters finds out of list searches.
follow: false, // Locator widget follows current location (moving map mode).
labels: "codes", // Label caches on the map with their GC code. Or "names" to use long name.
measure: "metric", // Or "imperial" - used for the scale indicators.
decimals: -1, // Number of decimals for the measured distance of a route.
osgbSearch: true, // Enhance search box with OSGB grid references, zooming, etc. (may interfere with postal code searches).
defaultMap: "OpenStreetMap",
maps: [
{alt: "OpenStreetMap", tileUrl: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", name: "osm", subdomains: "abc"},
{alt: "OpenCycleMap", tileUrl: "https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png", name: "ocm"},
{alt: "Bing Maps", tileUrl: "https://ecn.t{s}.tiles.virtualearth.net/tiles/r{q}?g=864&mkt=en-gb&lbl=l1&stl=h&shading=hill&n=z", subdomains: "0123", minZoom: 1, maxZoom: 20, attribution: "<a href=\'https://www.bing.com/maps/\'>Bing</a> map data copyright Microsoft and its suppliers", name: "bingmap", ignore: true},
{alt: "Bing Aerial View", tileUrl: "https://ecn.t{s}.tiles.virtualearth.net/tiles/a{q}?g=737&n=z", subdomains: "0123", minZoom: 1, maxZoom: 20, attribution: "<a href=\'https://www.bing.com/maps/\'>Bing</a> map data copyright Microsoft and its suppliers", name: "bingaerial"},
{alt: "Google Maps", tileUrl: "https://mt.google.com/vt?&x={x}&y={y}&z={z}", name: "googlemaps", attribution: "<a href=\'https://maps.google.com/\'>Google</a> Maps", subdomains: "1234", tileSize: 256, maxZoom: 22},
{alt: "Google Satellite", tileUrl: "https://mt.google.com/vt?lyrs=s&x={x}&y={y}&z={z}", name: "googlemapssat", attribution: "<a href=\'https://maps.google.com/\'>Google</a> Maps Satellite", subdomains: "1234", tileSize: 256, maxZoom: 22}
]
},
css: {
main: '.leaflet-control-gme, .leaflet-control-zoomwarning {border-radius: 7px; filter: progid:DXImageTransform.Microsoft.gradient(startColorStr="#3F000000",EndColorStr="#3F000000"); padding: 5px; z-index: 8;} '
+ '.leaflet-control-gme {display: inline-block; padding: 0; background: rgba(0, 0, 0, 0.2); box-shadow: 0 0 8px rgba(0, 0, 0, 0.4);} '
+ '.gme-control-scale {bottom: 45px !important; margin-bottom: 5px !important; margin-left: 1px !important; left: 385px;} '
+ '.leaflet-control-scale-line:first-child {box-shadow: 0 -1px 5px rgba(0, 0, 0, 0.2) !important;} '
+ '.gme-left {left: 385px; margin-left: 1px !important;} '
+ 'div.gme-identify-layer {margin-top: -1em; margin-left: 1em; padding-left: 0.1em; font-weight: bold; background: rgba(255,255,255,0.57);} '
+ '#gme_caches table {margin-top: 0.5em;} '
+ '.GME_search_list {border: 1px solid #679300; border-radius: 7px; padding: 0.5em;} '
+ '.GME_search_results {margin-top: 5px; margin-right: -56px;} '
+ '.GME_search_results p {margin-top: 5px; margin-bottom: 10px;} '
+ '.GME_search_results.hidden, .GME_search_info.hidden {display: none;} '
+ '.GME_search_info {font-size: 12px !important; padding: 4px 12px 0px 12px !important; line-height: 1rem !important;} '
+ '.gme-button {display: inline-block; box-sizing: content-box; -moz-box-sizing: content-box; padding: 2px; vertical-align: middle; background: no-repeat #eee; background-color: rgba(255,255,255,0.8); border: 1px solid #888; height: 22px; width: 22px; text-decoration: none;} '
+ '.gme-button-l {border-bottom-left-radius: 5px; border-top-left-radius: 5px;} '
+ '.gme-button-r {border-right: 1px solid #888; border-bottom-right-radius: 5px; border-top-right-radius: 5px; margin-right: 0.5em;} '
+ '.gme-button:hover {background-color: #fff;} '
+ '.gme-button-active {border: solid 3px #02b; padding: 0px; background-color: #fff;} '
+ '.gme-button-active:hover {border-color: #63f; filter: alpha(opacity=100);} '
+ 'span.gme-button, .gme-button-wide {padding-left: 5px; padding-right: 5px; font-size: 12px; font-weight: bold; width: auto; background-image: none; color: #424242; font-family: inherit;} '
+ 'span.gme-text {vertical-align: text-top;} '
+ 'a.gme-text {display: inline; padding: 5px;} '
+ 'a.gme-text-small {display: inline;} '
+ '#GME_brightness {margin: 0px; height: 2px;} '
+ '.GME_info {background-size: 26px 26px; background-position: center; background-image: url(https://github.com/2Abendsegler/GME/raw/main/images/GME_info.png)} '
+ '.GME_hide {background-size: 22px 22px; background-position: center; background-image: url(https://github.com/2Abendsegler/GME/raw/main/images/GME_hide.png)} '
+ '.GME_route {background-size: 21px 20px; background-position: center; background-image: url(https://github.com/2Abendsegler/GME/raw/main/images/GME_route.png)} '
+ '.GME_home {background-size: 23px 23px; background-position: center; background-image: url(https://github.com/2Abendsegler/GME/raw/main/images/GME_home.png)} '
+ '.GME_config {background-size: 24px 24px; background-position: center; background-image: url(https://github.com/2Abendsegler/GME/raw/main/images/GME_config.png)} '
+ 'a.GME_ctoc {color: #4a4a4a; opacity: 0.8; text-decoration: none; padding-right: 4px;} '
+ 'a.GME_ctoc svg {height: 14px; width: 14px; vertical-align: sub; transform: rotate(180deg);} '
+ '.gme-button-refresh-labels {background-position: -320px 4px;} '
+ '.gme-button-clear-labels {background-position: -69px 4px;} '
+ 'span.gme-distance-container {display: none;} '
+ 'span.gme-distance-container.show {display: inline-block;} '
+ '#GME_loc, a.gme-button.leaflet-active {outline: none;} '
+ '.leaflet-control-zoomwarning {top: 40px; margin-left: 2px !important;} '
+ '.leaflet-control-zoomwarning a {filter: progid:DXImageTransform.Microsoft.gradient(startColorStr="#BFC80000",EndColorStr="#BFC80000"); background-color: rgba(200,0,0,0.75); margin-left: -4px; background-position: -502px 2px; height: 14px; width: 14px; border-color: #b00; box-shadow: 0 0 8px rgba(0, 0, 0, 0.4);} '
+ '.leaflet-control-zoomwarning a:hover {background-color: rgba(230,0,0,0.75);} '
+ '.gme-event {cursor: pointer;} '
+ '.gme-modalDialog {position: fixed; top: 0; right: 0; bottom: 0; left: 0; background: rgba(0,0,0,0.5); z-index: 2501; opacity: .5; -webkit-transition: opacity 400ms ease-in; -moz-transition: opacity 400ms ease-in; transition: opacity 400ms ease-in; pointer-events: none; display: none;} '
+ '.gme-modalDialog:target, .gme-modalDialog.gme-targetted {opacity: 1; display: block; pointer-events: auto;} '
+ '.gme-modalDialog > div {position: relative; margin: 4% 12.5%; height: 30em; max-height: 75%; padding: 0 0 13px 0; border: 1px solid #000; border-radius: 10px; background: #fff; background: -moz-linear-gradient(#fff, #999); background: -webkit-linear-gradient(#fff, #999); background: -o-linear-gradient(#fff, #999);} '
+ '.gme-modalDialog header {color: #eee; background: none #454545; font-size: 15px; text-align: center; border-top-left-radius: 10px; padding: 0.5em 0; font-weight: bold; text-shadow: none; height: auto; min-height: auto; min-width: auto !important;} '
+ '.gme-modalDialog select {appearance: auto; background-color: inherit; background-image: none; background-repeat: no-repeat; color: inherit; border: 1px solid #9b9b9b; border-radius: 4px; width: auto; display: inline; font-size: 14px; line-height: normal; pointer-events: auto; padding: 0px 7px; height: 26px; margin-right: 7px; margin-top: 2px;} '
+ '.gme-modalDialog label {text-transform: none; font-size: inherit; margin-top: 0px;} '
+ '.gme-modal-content {position: absolute; top: 3.5em; left: 0.75em; right: 0.75em; bottom: 0.5em; overflow: auto;} '
+ '.gme-modal-content > .leaflet-control-gme {position: absolute; left: 0.5em; bottom: 0.5em; top: auto;} '
+ '.gme-modal-content a:not(.gme-button) {text-decoration-line: none; color: rgb(61, 118, 197); outline: none;} '
+ '.gme-modal-content a:not(.gme-button):hover {text-decoration-line: underline;} '
+ '.gme-modal-content a.gme-button {text-decoration-line: none !important; color: #424242 !important; outline: none;} '
+ '.gme-modal-content ul {list-style-type: none; padding-left: 0;} '
+ '.gme-close-dialog {background: #606061; color: #fff !important; line-height: 25px; position: absolute; right: -12px; text-align: center; top: -10px; width: 24px; text-decoration: none !important; font-weight: bold; -webkit-border-radius: 12px; -moz-border-radius: 12px; border-radius: 12px; -moz-box-shadow: 1px 1px 3px #000; -webkit-box-shadow: 1px 1px 3px #000; box-shadow: 1px 1px 3px #000;} '
+ '#searchtabs li a {padding: 1em 0.5em;} '
+ '@media print {#search {display: none !important}} '
+ '.tab-switcher {position: relative; font-family: Arial, sans-serif; font-size: 14px;} '
+ '.gme-tab {float: left;} '
+ '.gme-tab {float: left; line-height: 18.2px;} '
+ '.gme-tab-label {border-radius: 8px 8px 0 0; border: 1px solid #ccc; color: #454545; background: #ddd; display: block; position: relative; margin-left: 15px; padding: 3px 0; font-weight: bold; z-index: 0;} '
+ '.gme-tab-label:after {border-bottom: 1px solid #ccc; border-bottom-left-radius: 8px; border-left: 1px solid #ccc; box-shadow: -2px 2px 0 #ddd; bottom: -8px; content: ""; display: inline-block; height: 8px; left: 9px; position: relative; width: 8px; z-index: 3;} '
+ '.gme-tab-label:before {border-bottom: 1px solid #ccc; border-bottom-right-radius: 8px; border-right: 1px solid #ccc; box-shadow: 2px 2px 0 #ddd; bottom: -8px; content: ""; display: inline-block; height: 8px; left: -9px; position: relative; width: 8px; z-index: 3;} '
+ '.gme-tab-label:hover {cursor: pointer;} '
+ '.gme-tab-content {position: absolute; top: 25px; bottom: 3.5em; left: 0; right: 0; padding: 0.5em 0.5em 0 0.5em; background: #000; border: 1px solid #ccc; border-radius: 8px; color: #555; z-index: 1; opacity: 0; overflow: auto;} '
+ '.gme-tab-content ul {margin: 0.5em 0;} '
+ '.gme-tab input[type=radio] {display: none;} '
+ '.gme-tab input[type=radio]:checked ~ .gme-tab-content {z-index: 2; opacity: 1; background: #fff; color: #454545;} '
+ '.gme-tab input[type=radio]:checked ~ .gme-tab-label {background: #fff; color: #454545; border-bottom: 1px solid #fff; z-index: 3;} '
+ '.gme-tab input[type=radio]:checked ~ .gme-tab-label:after {box-shadow: -2px 2px 0 #fff;} '
+ '.gme-tab input[type=radio]:checked ~ .gme-tab-label:before {box-shadow: 2px 2px 0 #fff;} '
+ '.gme-fieldgroup {position: relative; border: 1px solid #ccc; border-radius: 6px; background: #eee; margin: 0.5em 0 1em; padding: 0.5em;} '
+ '.gme-fieldgroup h3 {position: absolute; line-height: 16px; top: -10px; left: 2px; padding: 0 0.5em; margin-top: 0px; margin-bottom: 0px; background: #eee; border-top: 1px solid #ccc; border-radius: 6px; z-index:1; display: inline-block; font-weight: bold; font-size: 12px;} '
+ '.gme-fieldgroup ul {margin: 0.5em 0; padding: 0;} '
+ '.gme-fieldgroup li {display: inline-block; margin: 0 2px 2px 0; background: #ddd; border: 1px solid #ccc; border-radius: 6px; padding: 0 0.5em; height: 28px;} '
+ '.gme-fieldgroup label {display: inline;} '
+ '.gme-fieldgroup input {margin: 7px 0; padding: 3px 6px 6px 6px; outline: none;} '
+ '.gme-fieldgroup input[type="text"] {height: 17px;} '
+ '#GME_map_custom {width: 200px; box-sizing: inherit; border: 1px solid #9b9b9b; border-radius: 4px;} '
+ '.gme-xhair {cursor: crosshair;} '
+ '.map-button-container {margin-right: 5em;} '
+ '#centerMap {margin-right: 100px;} '
+ '#map_canvas .leaflet-control-layers-toggle, #map_canvas-multi .leaflet-control-layers-toggle, #map_canvas2 .leaflet-control-layers-toggle {background-image: url(/app/dist/8f2c4d11474275fbc1614b9098334eae.png); background-size: 26px 26px;} '
+ '#map_canvas label, #map_canvas-multi label, #map_canvas2 label {text-transform: unset; display: block; font-weight: normal;} '
+ '#map_canvas .leaflet-popup-content, #map_canvas-multi .leaflet-popup-content, #map_canvas2 .leaflet-popup-content {text-align: unset;} '
// Prevent areas in preview map in listing from flashing white when zooming.
+ '#map_canvas2.leaflet-container img.leaflet-tile {mix-blend-mode: normal !important;} '
// Positions of sidebar and left map elements and animate left move only on browse map.
+ '.Sidebar {left: -355px !important; transition: left 0.5s ease-in-out !important;} '
+ 'body:has(.Sidebar) .leaflet-control-toolbar, body:has(.Sidebar) .leaflet-control-scale, body:has(.Sidebar) .gme-left {left: 30px !important; transition: left 0.5s ease-in-out !important;} '
+ 'body:has(.Sidebar.Open) .Sidebar {left: 0px !important;} '
+ 'body:has(.Sidebar.Open) .leaflet-control-toolbar, body:has(.Sidebar.Open) .leaflet-control-scale, body:has(.Sidebar.Open) .gme-left {left: 385px !important;} '
// Hide pages: Prevent center button and zoom buttons from overlapping the map layer selection dialog.
+ '.map-wrapper:has(.map-setting-controls) .leaflet-top.leaflet-right, .map-wrapper-multi:has(.map-setting-controls) .leaflet-top.leaflet-right {z-index: 1001;} '
// Hide pages: Align center button and zoom buttons.
+ '.map-setting-controls {top: 62px !important; right: 8px !important;} '
+ '.map-setting-controls .leaflet-control-zoom, .map-setting-controls #centerMap {margin-right: 0px !important;} '
// Shared styles for GClh and GME:
// - Resize map layer control button.
+ 'a.leaflet-control-layers-toggle {width: 36px !important; height: 36px !important;} '
// - Space of the right buttons from the right edge.
+ '.leaflet-control {margin-right: 8px !important;} '
+ '#search-map-cta {right: 8px !important;} '
// - Improve the scale lines on the left side.
+ '.leaflet-control-scale-line {box-shadow: none;} '
// - Lower part of the sidebar toggle is no longer working by click. (Bug on website 28.05.2026.)
+ '.Sidebar footer {padding-right: 0px !important; margin-right: 24px !important;} '
// - Reduce the overly wide border of the "Find My Location" button.
+ '.leaflet-touch .leaflet-control-toolbar {padding: 2px;} '
// - Prevent that zoom buttons overlap map selection dialog and align distance to the right to buttons top right.
+ '.legacy-map-zoom-wrapper {z-index: auto; right: 0px !important;} '
// - Slight opacity for zoom buttons.
+ '.leaflet-control-zoom {opacity: 0.8;} '
// - Prevent close button on cache details screen from overlapping GC code, make height and width of close button proportional and set a hover effect.
+ '.leaflet-container a.leaflet-popup-close-button {padding: 0px; top: -8px; right: -8px; width: 22px; height: 22px; font: 16px/19px Tahoma, Verdana, sans-serif;} '
+ '.leaflet-container a.leaflet-popup-close-button:hover, .leaflet-container a.leaflet-popup-close-button:focus {color: #fff;} '
// - Prevent a possible blue border around the map.
+ '#map_canvas {outline-style: none;} ',
drag: '#cacheDetails .activity-type-icon {border: solid 1px #ccc; border-radius: 7px;} '
+ '.moveable {cursor: move; box-shadow: 0 1px 4px rgba(102, 51, 255, 0.3);} '
},
env: {
dragdrop: (document.createElement('span').draggable !== undefined),
geolocation: !!navigator.geolocation,
init: [],
page: "default",
storage: false,
xhr: (typeof GM_xmlhttpRequest === 'function') ? 'GM' : ((typeof GM === 'object' && typeof GM.xmlHttpRequest === 'function') ? 'GM4': '')
},
html: {
config: ''
+ '<section class="gme-tab"> '
+ ' <input type="radio" name="gme-tab-row" id="gme-tab-maps" checked /> '
+ ' <label class="gme-tab-label" for="gme-tab-maps">Map display</label> '
+ ' <div class="gme-tab-content"> '
+ ' <div class="gme-fieldgroup"> '
+ ' <h3>Maps to show in selector widget</h3> '
+ ' <ul id="GME_mapfields"></ul> '
+ ' <label>Default map source: <select name="GME_map_default" id="GME_map_default"></select></label> '
+ ' </div> '
+ ' </div> '
+ '</section> '
+ '<section class="gme-tab"> '
+ ' <input type="radio" name="gme-tab-row" id="gme-tab-manage" /> '
+ ' <label class="gme-tab-label" for="gme-tab-manage">Manage maps</label> '
+ ' <div class="gme-tab-content"> '
+ ' <div class="gme-fieldgroup"> '
+ ' <h3>Add map sources</h3> '
+ ' <label>Mapsource: <input type="text" name="GME_map_custom" id="GME_map_custom"> </label> '
+ ' <div class="leaflet-control-gme"><button type="button" id="GME_custom_add" class="gme-button gme-button-wide gme-button-l gme-button-r" title="Add custom map source">Add</button> <a href="#GME_format" title="Map source format info" class="gme-button gme-button-wide gme-button-l gme-text">Mapsource format info</a><button type="button" id="GME_custom_export" title="Export custom map source JSON" class="gme-button gme-button-wide gme-button-r">Export custom maps</button></div> '
+ ' </div> '
+ ' <div class="gme-fieldgroup"> '
+ ' <h3>Remove map sources</h3> '
+ ' <ul id="GME_mapfields_del"></ul> '
+ ' </div> '
+ ' </div> '
+ '</section> '
+ '<section class="gme-tab"> '
+ ' <input type="radio" name="gme-tab-row" id="gme-tab-other" /> '
+ ' <label class="gme-tab-label" for="gme-tab-other">Other</label> '
+ ' <div class="gme-tab-content"> '
+ ' <div class="gme-fieldgroup"> '
+ ' <h3>Miscellaneous settings</h3> '
+ ' <ul> '
+ ' <li><label title="Only list unfound caches in search"><input type="checkbox" name="GME_filterFinds" id="GME_filterFinds" /> Filter finds</label></li> '
+ ' <li><label><input type="checkbox" checked="checked" name="GME_osgbSearch" id="GME_osgbSearch" /> Enhance search</label></li> '
+ ' <li><label title="Location widget constantly updates position"><input type="checkbox" name="GME_follow" id="GME_follow" /> FollowMe Mode</label></li> '
+ ' </ul> '
+ ' <label>Labels: '
+ ' <select name="GME_labelStyle" id="GME_labelStyle"> '
+ ' <option value="names">Names</option> '
+ ' <option value="codes" selected="selected">Codes</option> '
+ ' </select> '
+ ' </label> '
+ ' <label>Scale: '
+ ' <select name="GME_measure" id="GME_measure"> '
+ ' <option value="metric" selected="selected">Metric</option> '
+ ' <option value="imperial">Imperial</option> '
+ ' </select> '
+ ' </label> '
+ ' <label>Map brightness: '
+ ' <input type="range" name="GME_brightness" id="GME_brightness" value="100" min="0" max="100" /> '
+ ' </label> '
+ ' <br> '
+ ' <label title="Number of decimals for the measured distance of a route">Route decimals: '
+ ' <select name="GME_decimals" id="GME_decimals"> '
+ ' <option title="1 decimal up to 10 km, 0 decimals from 10 km" value="-1" selected="selected">variable</option> '
+ ' <option title="0 decimals" value="0">0</option> '
+ ' <option title="1 decimal" value="1">1</option> '
+ ' <option title="2 decimals" value="2">2</option> '
+ ' <option title="3 decimals" value="3">3</option> '
+ ' </select> '
+ ' </label> '
+ ' </div> '
+ ' </div> '
+ '</section> '
+ '<section class="gme-tab"> '
+ ' <input type="radio" name="gme-tab-row" id="gme-tab-about" /> '
+ ' <label class="gme-tab-label" for="gme-tab-about">About</label> '
+ ' <div class="gme-tab-content"> '
+ ' <div class="gme-fieldgroup"> '
+ ' <h3>Geocaching Map Enhancements</h3><br /> '
+ ' <p>v<span id="GME_version"></span> © 2022-2026 2Abendsegler, (2011-2018 James Inge). Geocaching Map Enhancements is licensed under the <a target="_blank" rel="noopener noreferrer" href="https://raw.githubusercontent.com/2Abendsegler/GME/main/License">MIT License</a>.<br>A short description and FAQ can be found <a target="_blank" rel="noopener noreferrer" href="https://github.com/2Abendsegler/GME/tree/main#readme">here</a>. The changelog can be found <a target="_blank" rel="noopener noreferrer" href="https://github.com/2Abendsegler/GME/blob/main/docu/changelog.md#readme">here</a>. An older documentation can be found <a target="_blank" rel="noopener noreferrer" href="http://geo.inge.org.uk/gme.htm">here</a>.</p> '
+ ' <p>Elevation and reverse geocoding data provided by <a target="_blank" rel="noopener noreferrer" href="http://www.geonames.org/">GeoNames</a> and used under a <a target="_blank" rel="noopener noreferrer" href="https://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> (CC-BY) License.</p> '
+ ' <p>Grid reference manipulation is adapted from code © 2005-2014 Chris Veness (<a target="_blank" rel="noopener noreferrer" href="http://www.movable-type.co.uk/scripts/latlong-gridref.html">www.movable-type.co.uk/scripts/latlong-gridref.html</a>, used under a <a target="_blank" rel="noopener noreferrer" href="https://creativecommons.org/licenses/by/3.0/">Creative Commons Attribution 3.0</a> (CC-BY) License.</p> '
+ ' <p>Photos provided by Geograph are copyright their respective owners - hover mouse over thumbnails or click through for attribution details. They may be re-used under a <a target="_blank" rel="noopener noreferrer" href="https://creativecommons.org/licenses/by-sa/2.0/">Creative Commons Attribution-ShareAlike 2.0</a> (CC-BY-SA) License.</p> '
+ ' </div> '
+ ' </div> '
+ '</section> '
+ '<div class="leaflet-control-gme"> '
+ ' <a href="#" class="gme-button gme-button-wide gme-button-l gme-text" rel="back" title="Cancel">Cancel</a><button type="button" class="gme-button gme-button-wide" id="GME_default" title="Reset to defaults">Defaults</button><button type="button" class="gme-button gme-button-wide gme-button-r" id="GME_set" title="Confirm settings">Save</button> '
+ '</div>',
customInfo: ''
+ '<p>Custom mapsources can be added by supplying entering a <a rel="external" href="http://www.json.org/">JSON</a> configuration string that tells GME what to call the map, where to find it, and how it is set up. e.g.</p> '
+ '<p><code>{"alt":"OS NPE (GB only)","tileUrl":"https://ooc.openstreetmap.org/npe/{z}/{x}/{y}.png", "minZoom":6, "maxZoom": 15, "attribution": "OpenStreetMap NPE"}</code></p> '
+ '<p>The <code>"alt"</code> and <code>"tileUrl"</code> parameters are mandatory. <code>"tileUrl"</code> can contain {x}, {y} and {z} for Google-style coordinate systems (also works with TMS systems like Eniro, but needs the <code>"scheme":"tms"</code> parameter), or {q} for Bing-style quadkeys. GME can also connect with WMS servers, in which case a <code>"layers"</code> parameter is required.</p> '
+ '<p>The other parameters are the same as those used by the <a rel="external" href="http://leafletjs.com/reference-versions.html">Leaflet API</a>, with the addition of a <code>"overlay":true</code> option, that makes the mapsource appear as a selectable overlay.</p> '
+ '<ul><li><a rel="external" href="http://geo.inge.org.uk/gme_config.htm">Detailed documentation</a></li><li><a rel="external" href="http://geo.inge.org.uk/gme_maps.htm">More mapsource examples</a></li></ul>',
search: ''
+ '<input type="text" placeholder="Address, Coordinates, GC Code, Zoom, Grif Ref" id="SearchBox_Text" class="h-10 box-border bg-white border border-solid border-green-500 rounded-tr-none rounded-br-none border-r-0 m-0 py-2.5 px-3 w-full"/> '
+ '<button id="SearchBox_OS" title="Search" class="h-10 box-border bg-green-500 bg-[url(\'/images/icons/search.png\')] bg-no-repeat bg-center border-none rounded-l-none rounded-r-[3px] text-transparent cursor-pointer absolute top-0 right-0 indent-[9999px] overflow-clip w-14 hover:bg-legacy-sea active:bg-legacy-sea focus:bg-legacy-sea">Search</button> '
+ '<div class="GME_search_results hidden"> '
+ ' <h3 class="GME_search_heading">GeoNames search results</h3> '
+ ' <ul class="GME_search_list"></ul> '
+ ' <p>Or try the <a class="GME_link_GSSearch" href="#">Geocaching.com</a> search.</p> '
+ '</div> '
+ '<div class="GME_search_info"></div>'
},
script: {
common: function() {
var that = this, callbackCount = 0, load_count = 0, JSONP;
var ctoc = false;
var ctocActiv = false;
var ctocPath = '<path d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 0 1 0 1.5h-1.5a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-1.5a.75.75 0 0 1 1.5 0v1.5A1.75 1.75 0 0 1 9.25 16h-7.5A1.75 1.75 0 0 1 0 14.25Z"></path><path d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0 1 14.25 11h-7.5A1.75 1.75 0 0 1 5 9.25Zm1.75-.25a.25.25 0 0 0-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 0 0 .25-.25v-7.5a.25.25 0 0 0-.25-.25Z"></path>';
function setEnv() {
// The script waits for the Leaflet API to load, and will abort if it does not find it after a minute.
var maxTries = 60,
wait = 1000;
switch (gmeConfig.env.page) {
case "seek":
if (typeof $ === "function") {
gmeInit(gmeConfig.env.init);
load();
return;
}
break;
case "hide":
maxTries = Infinity;
wait = 3000;
if (window.map !== null && window.map !== undefined && typeof L === "object" && typeof $ === "function") {
gmeInit(gmeConfig.env.init);
window.setTimeout(load,500);
return;
}
break;
case "type":
if (window.map !== null && window.map !== undefined && typeof L === "object" && typeof $ === "function") {
gmeInit(gmeConfig.env.init);
load();
reload();
$(".cache-type-selector button").click(reload);
return;
}
break;
case "maps":
// Wait for the map to load and the default map selector to be added.
if (typeof L === "object" && typeof $ === "function" && window.MapSettings && window.MapSettings.Map && window.MapSettings.Map._loaded && $(".leaflet-control-layers").length > 0) {
gmeInit(gmeConfig.env.init);
window.setTimeout(load,500);
return;
}
break;
default:
if (typeof L === "object" && typeof $ === "function") {
gmeInit(gmeConfig.env.init);
window.setTimeout(load,500);
return;
}
break;
}
if (load_count < maxTries) {
window.setTimeout(setEnv, wait);
load_count++;
console.log("GME: Waiting for map API to load: " + load_count + "...");
}
}
function gmeInit(scriptArray) {
// Init routines that need either JQuery or Leaflet API, so must be run from load() rather than on script insertion.
var initScripts = {
"config": function() {
if (gmeConfig.env.storage) {
setConfig();
$("#GME_set").bind("click", storeSettings);
$("#GME_default").bind("click", setDefault);
$("#GME_custom_add").bind("click", addCustom);
$("#GME_custom_export").bind("click", exportCustom);
// Build config link in settings menu for old design or if GClh is running.
$("li.li-user ul").append("<li class='li-settings'><a class='icon-settings' id='gme-config-link' href='#GME_config' title='Configure Geocaching Map Enhancements extension'>Geocaching Map Enhancements</a></li>");
// Build config link in settings menu for new design.
function checkForUserNew(waitCount) {
if ($('.toggle-user-menu')[0] && !$('.gme_toggle-user-menu')[0]) {
$('.toggle-user-menu')[0].addEventListener("click", function() {
function checkForSettingsNew(waitCount) {
if ($('ul.menu-user')[0] && !$('#gme-config-link-new')[0]) {
$('ul.menu-user').append("<li class='li-settings'><a class='icon-settings' id='gme-config-link-new' href='#GME_config' title='Configure Geocaching Map Enhancements extension'>Geocaching Map Enhancements</a></li>");
if ($('#logout-form button')[0]) {
$('#gme-config-link-new').addClass($('#logout-form button').attr('class'));
}
} else {waitCount++; if (waitCount <= 50) setTimeout(function(){checkForSettingsNew(waitCount);}, 100);}
}
checkForSettingsNew(0);
});
} else {waitCount++; if (waitCount <= 100) setTimeout(function(){checkForUserNew(waitCount);}, 100);}
}
checkForUserNew(0);
}
},
"drop": function() {
$.fn.filterNode = function(name) {
return this.find("*").filter(function() {
return this.nodeName === name;
});
};
L.GME_dropHandler = L.Control.extend(dropHandlerObj);
},
"map": function() {
bounds_GB = new L.LatLngBounds(new L.LatLng(49,-9.5),new L.LatLng(62,2.3));
bounds_IE = new L.LatLngBounds(new L.LatLng(51.2,-12.2),new L.LatLng(55.73,-5.366));
bounds_NI = new L.LatLngBounds(new L.LatLng(54,-8.25),new L.LatLng(55.73,-5.25));
bounds_CI = new L.LatLngBounds(new L.LatLng(49.1,-2.8),new L.LatLng(49.8,-1.8));
bounds_DE = new L.LatLngBounds(new L.LatLng(47.24941,5.95459),new L.LatLng(55.14121,14.89746));
L.GME_DistLine = L.Polyline.extend(polylineObj);
L.GME_QuadkeyLayer = L.TileLayer.extend(quadkeyLayerObj);
L.GME_complexLayer = L.TileLayer.extend(complexLayerObj);
L.GME_genericLayer = genericLayerFn;
},
"widget": function() {
L.GME_Widget = L.Control.extend(widgetControlObj);
L.GME_FollowMyLocationControl = L.Control.extend(locationControlObj);
L.GME_ZoomWarning = L.Control.extend(zoomWarningObj);
if (L.LatLng.prototype.toUrl === undefined) {
L.LatLng.prototype.toUrl = function() {return this.lat.toFixed(6) + "," + this.lng.toFixed(6); };
}
if ($.fancybox === undefined) {
console.info("GME: Fetching Fancybox.");
$("head").append("<link rel='stylesheet' type='text/css' href='https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.css'><script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.js'></script>");
}
}
},
j;
for (j = 0; j < scriptArray.length; j++) {
if (initScripts.hasOwnProperty(scriptArray[j]) && typeof initScripts[scriptArray[j]] === "function") {
initScripts[scriptArray[j]]();
}
}
console.log("GME: Init: " + scriptArray.join());
}
function b64encode(str) {
if (typeof window.btoa === "function") {
return btoa(encodeURIComponent(str));
} else {
return encodeURIComponent(str);
}
}
function b64decode(str) {
if (typeof window.atob === "function") {
return decodeURIComponent(window.atob(str));
} else {
return decodeURIComponent(str);
}
}
function DMM(ll) {
var latDeg = ll.lat < 0 ? Math.ceil(ll.lat) : Math.floor(ll.lat),
lngDeg = ll.lng < 0 ? Math.ceil(ll.lng) : Math.floor(ll.lng);
return (ll.lat < 0 ? "S" : "N") + Math.abs(latDeg) + " " + (60 * Math.abs((ll.lat - latDeg))).toFixed(3) + (ll.lng < 0 ? " W" : " E") + Math.abs(lngDeg) + " " + (60 * Math.abs((ll.lng - lngDeg))).toFixed(3);
}
function formatDistance(dist, setDec = false) {
var formatted = 0;
if (that.parameters.measure === "metric") {
if (dist <= 1000) {
formatted = Math.round(dist) + " m";
} else if (that.parameters.decimals > -1 && setDec) {
formatted = (dist/1000).toFixed(that.parameters.decimals) + " km";
} else if (dist > 10000) {
formatted = (dist/1000).toFixed(0) + " km";
} else {
formatted = (dist/1000).toFixed(1) + " km";
}
} else {
if (dist <= 1609.344) {
formatted = Math.round(dist * 3.2808) + " ft";
} else if (that.parameters.decimals > -1 && setDec) {
formatted = (dist/1609.344).toFixed(that.parameters.decimals) + " mi";
} else if (dist > 16093.44) {
formatted = (dist/1609.344).toFixed(0) + " mi";
} else {
formatted = (dist/1609.344).toFixed(1) + " mi";
}
}
return formatted;
}
function htmlEntities(text) {
return text
.replace(/&/g, "&")
.replace(/\"/g, """)
.replace(/'/g, "'")
.replace(/</g, "<")
.replace(/>/g, ">");
}
function validCoords(c1, c2) {
var lat, lng;
if (c1 === undefined) {
return false;
}
if (c1.hasOwnProperty("lat") && c1.hasOwnProperty("lng")) {
lat = c1.lat;
lng = c1.lng;
} else {
if (c2 !== undefined) {
lat = c1;
lng = c2;
}
}
if (lat !== null && lng !== null && !isNaN(+lat) && !isNaN(+lng) && lat >= -90 && lat <= 90) {
return true;
}
return false;
}
function parseCoords(text) {
var lat=0, lng=0, num=0,
c = text.replace(/[^\-SsWw0-9\.\s]/g," ").trim().match(/^([S\-])?\s*(\d{1,2}(\.\d*){0,1}|\.\d*)(\s+(\d{0,2}(\.\d*){0,1})){0,1}(\s+(\d{0,2}(\.\d*){0,1})){0,1}\s*([S\-])?\s+([W\-])?\s*(\d{1,3}(\.\d*){0,1}|\.\d*)(\s+(\d{0,2}(\.\d*){0,1})){0,1}(\s+(\d{0,2}(\.\d*){0,1})){0,1}\s*([W\-])?$/i);
if (c) {
num = (c[2]?1:0) + (c[5]?1:0) + (c[8]?1:0) + (c[12]?1:0) + (c[15]?1:0) + (c[18]?1:0);
switch(num) {
case 6:
break;
case 4:
if (c[15] === undefined) {c[15] = c[12]; c[12] = c[8]; c[8] = undefined;}
break;
case 2:
if (c[12] === undefined && c[5]) {c[12] = c[5]; c[5] = undefined;}
break;
default:
alert("Couldnt understand coordinates");
return false;
}
if (c[2] !== undefined) {lat = +c[2];}
if (c[5] !== undefined) {lat += c[5]/60;}
if (c[8] !== undefined) {lat += c[8]/3600;}
if (c[1] !== undefined || c[10] !== undefined) {lat *= -1;}
if (c[12] !== undefined) {lng = +c[12];}
if (c[15] !== undefined) {lng += c[15]/60;}
if (c[18] !== undefined) {lng += c[18]/3600;}
if (c[11] !== undefined || c[20] !== undefined) {lng *= -1;}
}
if (validCoords(lat, lng)) {
return {lat:lat,lng:lng};
}
alert("Invalid coordinates");
return false;
}
function getHomeCoords() {
var c, h = document.getElementById("ctl00_ContentBody_lnkPrintDirectionsSimple");
if (window.MapSettings && MapSettings.User && validCoords(MapSettings.User.Home)) {
return new L.LatLng(MapSettings.User.Home.lat, MapSettings.User.Home.lng);
}
if (validCoords(window.homeLat, window.homeLon)) {
return new L.LatLng(window.homeLat, window.homeLon);
}
// Nur notwendig im Listing für Drag & Drop ausgehend vom Cache Typ und im Zusammenhang mit Directions Links zu Parking Area und Trailhead.
if (h && h.href) {
c = h.href.match(/(?:saddr=)(-?\d{1,2}\.\d*),(-?\d{1,3}\.\d*)/);
if (c !== null && c.length === 3 && validCoords(c[1], c[2])) {
return new L.LatLng(c[1], c[2]);
}
}
return false;
}
function validURL(url) {
return (/^(http|https|ftp)\:\/\/([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(\/($|[a-zA-Z0-9\.\,\?'\\\+&%\$#\=~_\-]+))*$/).test(url);
}
if (window.console === undefined) {
var logFn = function(text) {};
window.console = {
error: logFn,
log: logFn,
info: logFn,
warn: logFn
};
}
if (gmeConfig.env.xhr) {
JSONP = function(url, id) {
console.log("GME: Using GM_xhr to fetch " + url);
var s = document.getElementById("gme_jsonp_node");
if (!s) {
s = document.createElement("script");
s.id = "gme_jsonp_node";
document.documentElement.firstChild.appendChild(s);
}
s.type = "text/x-gme-jsonp";
s.text = url;
s.setAttribute("data-gme-callback", id);
document.dispatchEvent(new Event("GME_XHR_event"));
};
document.addEventListener("GME_XHR_callback", function(e) {
var s = document.getElementById("gme_jsonp_node"),
callback = s.getAttribute("data-gme-callback");
if (typeof window[callback] === "function") {
try {
window[callback](JSON.parse(s.text));
} catch(e) {
console.error("GME: Error processing JSON callback " + callback + ": " + e);
}
} else {
console.error("GME: Unexpected request to JSON callback handler: Couldn't find callback function " + callback);
}
return false;
});
} else {
JSONP = function(url, id) {
console.log("GME: Using JSONP to fetch " + url);
if (validURL(url)) {
var s = document.createElement("script");
s.type = "text/javascript";
if (id) {s.id = id;}
s.src = url;
document.documentElement.firstChild.appendChild(s);
}
};
}
gmeConfig.env.home = getHomeCoords();
that.parameters = gmeConfig.parameters;
that.getVersion = function() {return gmeConfig.parameters.version;};
that.getGeograph = function(coords) {
var callprefix = "GME_geograph_callback", call, host = "";
function searchLink(coords) {
// URIs for website search pages.
if (coords === undefined) {return false;}
var host = "";
if (bounds_GB.contains(coords) || bounds_IE.contains(coords)) {
host = "https://geograph.org.uk/";
}
if (bounds_CI.contains(coords)) {
host = "https://www.geograph.org.gg/";
}
if (bounds_DE.contains(coords)) {
host = "https://geo-en.hlipp.de/";
}
return host?[host,"search.php?location=", coords.toUrl()].join(""):false;
}
function makeCallback(callname) {callbackCount++; return function(json) {
var html, i, p;
if (json.items && json.items.length>0) {
html = ["<h3>Geograph images near ", DMM(coords), "</h3><p>"].join("");
for (i = json.items.length-1; i >= 0; i--) {
p = json.items[i];
html += ["<a target='_blank' rel='noopener noreferrer' href='",encodeURI(p.link),"' style='margin-right:0.5em;' title='", htmlEntities(p.title) + " by " + htmlEntities(p.author), "'>",p.thumbTag,"</a>"].join("");
}
html += ["</p><p><a target='_blank' rel='noopener noreferrer' href='",searchLink(coords),"'>Search for more photos nearby on Geograph</a></p><p style='font-size:90%;'>Geograph photos are copyrighted by their owners and available under a <a href='https://creativecommons.org/licenses/by-sa/2.0/'>Creative Commons licence</a>. Hover mouse over thumbnails for more details, or click through for full images.</p>"].join("");
$.fancybox(html);
} else {
$.fancybox(["<p>No photos found nearby. <a target='_blank' rel='noopener noreferrer' href='",searchLink(coords),"'>Search on Geograph</a></p>"].join(""));
}
$("#"+callname).remove();
if (window[callname] !== undefined) {delete window[callname];}
};}
if (validCoords(coords) && that.isGeographAvailable(coords)) {
if (!bounds_CI.contains(coords) && (bounds_GB.contains(coords) || bounds_IE.contains(coords))) {
host = "https://api.geograph.org.uk/";
call = callprefix + callbackCount;
window[call] = makeCallback(call);
JSONP(host + "syndicator.php?key=geo.inge.org.uk&location=" + coords.toUrl() + "&format=JSON&callback=" + call, call);
} else {
window.open(searchLink(coords), "_blank");
}
} else {
console.error("GME: Bad coordinates to getGeograph.");
}
};
that.getHeight = function(coords) {
var callprefix = "GME_height_callback",call;
function makeCallback(callname) {callbackCount++; return function(json) {
if (typeof json.astergdem === "number" && typeof json.lat === "number" && typeof json.lng === "number") {
var h, m;
if (json.astergdem === -9999) {
m = "<p><strong>Spot Height</strong><br/>(Ocean)</p>";
} else {
h = that.parameters.measure === "metric" ? json.astergdem + " m" : Math.round(json.astergdem*3.2808) + " ft";
m = ["<p><strong>Spot Height</strong><br/>Approx ",h," above sea level</p>"].join("");
}
$.fancybox(m);
}
$("#"+callname).remove();
if (window[callname] !== undefined) {delete window[callname];}
};}
if (validCoords(coords)) {
call = callprefix + callbackCount;
window[call] = makeCallback(call);
JSONP(["http://api.geonames.org/astergdemJSON?lat=",coords.lat,"&lng=",coords.lng,"&username=gme&callback=",call].join(""), call);
} else {
console.error("GME: Bad coordinates to getHeight.");
}
};
that.isGeographAvailable = function(coords) {
return bounds_GB.contains(coords) || bounds_DE.contains(coords) || bounds_IE.contains(coords) || bounds_CI.contains(coords);
};
that.isInUK = function(coords) {
if (bounds_GB.contains(coords)) {
if (bounds_IE.contains(coords)) {
if (bounds_NI.contains(coords)) {
return true;
}
return false;
}
return true;
}
return false;
};
if (gmeConfig.env.geolocation) {
that.seekHere = function() {
function hereCallback(pos) {
that.seekByLatLng({lat:pos.coords.latitude, lng:pos.coords.longitude});
$("#GME_hereSub").val("Go");
}
function hereError(err) {
if (err.code === 2) {
alert("Current location not available");
}
if (err.code === 3) {
alert("Timed out finding current location");
}
$("#GME_hereSub").val("Go");
}
$("#GME_hereSub").val("Waiting for location...");
navigator.geolocation.getCurrentPosition(hereCallback, hereError, {timeout: 60000, maximumAge: 30000});
return false;
};
}
that.seekByLatLng = function(latlng) {
if (validCoords(latlng)) {
var url = ["https://www.geocaching.com/seek/nearest.aspx?origin_lat=",latlng.lat,"&origin_long=",latlng.lng, that.parameters.filterFinds?"&f=1":""].join("");
window.open(url, "_blank");
} else {
console.error("GME: Invalid coordinates for search.");
}
};
document.addEventListener('copy', function(e){
if (!ctocActiv) return;
e.preventDefault();
if (ctoc) e.clipboardData.setData('text/plain', ctoc);
ctoc = false;
ctocActiv = false;
});
},
config: function() {
function addSources(json) {
function setSrc(src) {
if (src.alt && src.tileUrl) {
var m = that.parameters.maps.concat(src);
that.parameters.maps = m;
return 1;
}
alert("Map source must include at least \"alt\" and \"tileUrl\" parameters");
return 0;
}
var i,updated=0;
if (json.length === undefined) {
updated += setSrc(json);
} else {
for (i = 0; i < json.length; i++) {
updated += setSrc(json[i]);
}
}
if (updated > 0) {
setConfig();
$("#gme-tab-maps")[0].checked = true;
}
}
function addCustom() {
try{
var n = JSON.parse(document.getElementById("GME_map_custom").value);
addSources(n);
} catch(e) {
alert("Map source string must be valid JSON.");
return;
}
}
function exportCustom() {
if (!$('#gme_fancybox')[0] && $('head')[0] && document.location.pathname.match(/^\/map/)) {
$('head').append('<style id ="gme_fancybox" type="text/css">#fancybox-overlay, #fancybox-wrap {z-index: 2502;}</style>');
}
$.fancybox($("<p/>").text(JSON.stringify(that.parameters.maps)).html());
}
function setDefault() {
if (localStorage.GME_custom) {delete localStorage.GME_custom;}
if (localStorage.GME_parameters) {delete localStorage.GME_parameters;}
if (localStorage.GME_cache) {delete localStorage.GME_cache;}
refresh();
}
function refresh(config) {
var dest = "https://www.geocaching.com/map/#",
mapLink = document.getElementById("map_linkto"),
uri;
if (config) {
dest += "GME_config";
}
if (mapLink) {
uri = mapLink.value;
if (uri) {
dest += uri.replace(/^http:\/\/coord.info\/map/, "");
}
document.location.href = dest;
} else {
document.location.hash = "";
}
window.location.reload(false);
return false;
}
function setConfig() {
var i, mapfields = "", mapfields_del = "", mapselect = "", alt = "", overlay, sel, allMaps = that.parameters.maps;
for (i = 0; i < allMaps.length; i++) {
alt = allMaps[i].alt;
overlay = allMaps[i].overlay;
if (!overlay) {mapselect += "<option value='" + htmlEntities(alt) + "'>" + htmlEntities(alt) + "</option>";}
mapfields += "<li><label><input type='checkbox' " + (allMaps[i].ignore ? "" : "checked='checked' ") + "name='" + htmlEntities(alt) + "' id='checkbox-" + i + "' /> " + htmlEntities(alt) + (overlay ? " (Overlay)" : "") + "</label></li>";
}
if (allMaps.length > 0) {
for (i = 0; i < allMaps.length; i++) {
alt = allMaps[i].alt;
mapfields_del += "<li><label><input type='checkbox' name='" + htmlEntities(alt) + "' id='checkbox-del-" + i + "' /> " + htmlEntities(alt) + (allMaps[i].overlay ? " (Overlay)" : "") + "</label></li>";
}
} else {
mapfields_del = "< No custom maps installed >";
}
$("#GME_mapfields").html(mapfields);
$("#GME_mapfields_del").html(mapfields_del);
$("#GME_map_default").html(mapselect);
sel = $("#GME_map_default").children();
for (i = sel.length - 1; i > -1; i--) {
if (sel[i].value === that.parameters.defaultMap) {
sel[i].selected = "selected";
}
}
$("#GME_filterFinds").attr("checked", that.parameters.filterFinds);
$("#GME_osgbSearch").attr("checked", that.parameters.osgbSearch);
$("#GME_follow").attr("checked", that.parameters.follow);
$("#GME_labelStyle").val(that.parameters.labels);
$("#GME_measure").val(that.parameters.measure);
$("#GME_decimals").val(that.parameters.decimals);
$("#GME_brightness").val(that.parameters.brightness * 100);
$("#GME_version").html(that.parameters.version);
}
function storeSettings() {
var i, j, list;
that.parameters.defaultMap = $("#GME_map_default")[0].value;
list = $("#GME_mapfields input");
for (i = list.length - 1; i >= 0; i--) {
for (j = that.parameters.maps.length - 1; j >= 0; j--) {
if (that.parameters.maps[j].alt === list[i].name) {
that.parameters.maps[j].ignore = !list[i].checked;
}
}
}
for (j = that.parameters.maps.length - 1; j >= 0; j--) {
if (that.parameters.maps[j].alt === that.parameters.defaultMap) {
that.parameters.maps[j].ignore = false;
}
}
list = $("#GME_mapfields_del input");
for (i = list.length - 1; i >= 0; i--) {
if (list[i].checked === true) {
for (j = that.parameters.maps.length - 1; j >= 0; j--) {
if (that.parameters.maps[j].alt === list[i].name) {
that.parameters.maps.splice(j,1);
break;
}
}
}
}
that.parameters.brightness = $("#GME_brightness").val() / 100;
that.parameters.filterFinds = $("#GME_filterFinds")[0].checked ? true : false;
that.parameters.follow = $("#GME_follow")[0].checked ? true : false;
that.parameters.labels = $("#GME_labelStyle")[0].value;
that.parameters.measure = $("#GME_measure")[0].value;
that.parameters.decimals = $("#GME_decimals")[0].value;
that.parameters.osgbSearch = $("#GME_osgbSearch")[0].checked? true : false;
localStorage.setItem("GME_parameters", JSON.stringify(that.parameters));
refresh();
}
},
cssTransitionsFix: function() {
// Work around bug that breaks JQuery Mobile dialog boxes in Opera 12.
if (window.$ && $.support) {
$.support.cssTransitions = false;
}
},
dist: function() {
// Im Cache Listing durch Klick auf "Check distance from here" entsteht der Bug. Deaktiviert wegen Bug. Das Coding wird ansonsten aber auch
// für die Minimap benötigt.
// $("#lblDistFromHome").parent().append("<br/><span id='gme-dist'><a href='#' id='gme-dist-link'>Check distance from here</a></span>");
$("#gme-dist-link").click(function() {
// Bug: Uncaught ReferenceError: LatLon is not defined. Im Original 0.8.2 auch bereits defekt.
var there = new LatLon(mapLatLng.lat, mapLatLng.lng),
rose = [[22.5,67.5,112.5,157.5,202.5,247.5,292.5,337.5],["N","NE","E","SE","S","SW","W","NW"]],
watcher;
function found(pos) {
var here = new LatLon(pos.coords.latitude, pos.coords.longitude),
bearing = here.bearingTo(there),
dir = "N", i;
for (i = 0; i < 8; i++) {
if (bearing < rose[0][i]) {
dir = rose[1][i];
break;
}
}
$("#gme-dist").html("<img style='vertical-align:text-bottom' alt='" + dir + "' src='/images/icons/compass/" + dir + ".gif'> " + dir + " " + formatDistance(here.distanceTo(there)*1000) + " from here at bearing " + Math.round(bearing) + "°");
}
function lost() {
if (watcher) {
navigator.geolocation.clearWatch(watcher);
}
alert("GME: Couldn't detect your location.\nDisable FollowMe mode in Geocaching Map Enhancements if this error pops up repeatedly.");
}
if (that.parameters.follow) {
watcher = navigator.geolocation.watchPosition(found, lost, {timeout: 60000, maximumAge: 30000});
} else {
navigator.geolocation.getCurrentPosition(found, lost, {timeout: 60000, maximumAge: 30000});
}
return false;
});
},
drag: function() {
that.dragStart = function(event) {
function GME_formatLOC(wpts) {
return wpts ? ['<?xml version="1.0" encoding="UTF-8"?>\n<loc version="1.0" src="Geocaching Map Enhancements v' + that.getVersion() + '">' + wpts.join('\n') + '</loc>'].join('\n'):null;
}
function GME_formatLOC_wpt(id, desc, coords, type, link) {
if (id && desc && coords) {
var t="Geocache",
l=link ? ('\n\t<link text="' + link.desc + '">' + link.href + '</link>') : "";
switch(type) {
case "Original Coordinates": t=type; break;
case 217: t="Parking Area"; break;
case 218: t="Question to Answer"; break;
case 219: t="Stages of a Multicache"; break;
case 220: t="Final Location"; break;
case 221: t="Trailhead"; break;
case 452: t="Reference Point"; break;
}
return ('<waypoint>\n\t<name id="' + id + '"><![CDATA[' + desc + ']]></name>\n\t<coord lat="' + coords.lat + '" lon="' + coords.lng + '"/>\n\t<type>' + t + '</type>' + l + '\n</waypoint>');
}
console.error("GME: Missing cache data - id:", id , "desc:", desc, "coords:", coords);
return null;
}
var c, dataURI, dt, i, locfmt,
id = $("#ctl00_ContentBody_CoordInfoLinkControl1_uxCoordInfoCode")[0].innerHTML,
loc = [GME_formatLOC_wpt(id, cache_coords.primary[0].name, cache_coords.primary[0], cache_coords.primary[0].type,{desc:"Cache Details",href:"https://coord.info/"+id})];
for (i = cache_coords.additional.length-1; i >= 0; i--) {
c = cache_coords.additional[i];
loc.push(GME_formatLOC_wpt(c.pf + id.slice(2), [c.name,$("#awpt_"+c.pf).parent().parent().next().children()[2].innerHTML.trim()].join(" "), c, c.type));
}
if (cache_coords.primary[0].isUserDefined) {
loc.push(GME_formatLOC_wpt("GO"+id.slice(2), cache_coords.primary[0].name, {lat:cache_coords.primary[0].oldLatLng[0], lng:cache_coords.primary[0].oldLatLng[1]}, "Original Coordinates",{desc:"Cache Details",href:"https://coord.info/"+id}));
}
locfmt = GME_formatLOC(loc);
dataURI = "data:application/xml-loc," + encodeURIComponent(locfmt);
dt = event.originalEvent.dataTransfer;
if (window.DataTransfer !== undefined && dt.constructor === window.DataTransfer) {
dt.setData("application/gme-cache-coords", JSON.stringify(cache_coords));
dt.setData("application/xml-loc", locfmt);
dt.setData("text/x-moz-url", dataURI + "\nGME_waypoints.loc");
dt.setData("DownloadURL", "application/xml-loc:GME_waypoints.loc:" + dataURI);
}
dt.setData("text/uri-list", dataURI);
dt.setData("Text", locfmt);
dt.effectAllowed = "copy";
dt.setDragImage($('a[aria-label="About geocache types"]')[0],0,0);
};
},
drop: function() {
var dropHandlerObj = {
onAdd: function(map) {
var container = $(map.getContainer());
this._map = map;
container.on("drop", this.drop(map));
container.on("dragover", this.dragOver);
return document.createElement("div");
},
onRemove: function(map) {
var container = $(map.getContainer());
container.off("drop", this.drop(map));
container.off("dragover", this.dragOver);
},
drop: function(map) {return function(e) {
function typeToIcon(t) {
var j, type = t;
for (j = wptTypes.length - 1; j >= 0; j--) {
type = type.replace(wptTypes[j][0],wptTypes[j][1]);
}
return type;
}
function parseLOC(text) {
var i, l, w, t, len, lat, lng, name, points = {primary:[], additional:[]}, wpts = $($.parseXML(text)).find("waypoint");
for (i = 0, len = wpts.length; i < len; i++) {
w = $(wpts[i]);
lat = w.find("coord").attr("lat");
lng = w.find("coord").attr("lon");
name = w.find("name").attr("id") + ": " + w.find("name").text().trim();
if (isNaN(+lat) || isNaN(+lng) || lat < -90 || lat > 90) {return false;}
t = w.find("type").text();
if (/Geocache/i.test(t)) {
points.primary.push({lat:lat, lng:lng, name:name, type:2});
} else {
l = points.primary.length;
if (l && /Original Coordinates/i.test(t)) {
points.primary[l-1].oldLatLng = [lat, lng];
points.primary[l-1].isUserDefined = true;
} else {
points.additional.push({lat:lat, lng:lng, name:name, type:typeToIcon(t)});
}
}
}
return(points.additional.length + points.primary.length > 0)?points:false;
}
function readLOC(e) {
var data = e.target.result, pts = parseLOC(data);
if (pts) {
console.info("GME: Received LOC file.");
GME_displayPoints(pts, map, "dragdrop");
}
}