-
Notifications
You must be signed in to change notification settings - Fork 85
/
leaflet-elevation_multiple-maps.html
160 lines (136 loc) · 4.91 KB
/
leaflet-elevation_multiple-maps.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
<!DOCTYPE html>
<html>
<head>
<title>leaflet-elevation.js</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<link rel="dns-prefetch" href="https://tile.openstreetmap.org">
<link rel="dns-prefetch preconnect" href="https://unpkg.com" />
<link rel="preload" href="https://unpkg.com/[email protected]/dist/leaflet.js" as="script">
<link rel="preload" href="https://unpkg.com/[email protected]/dist/leaflet-ui.js" as="script">
<style>@import '../libs/fullpage.css';</style>
<!-- leaflet-ui -->
<script src="https://unpkg.com/[email protected]/dist/leaflet.js"></script>
<script src="https://unpkg.com/[email protected]/dist/leaflet-ui.js"></script>
<!-- leaflet-elevation -->
<link rel="stylesheet" href="https://unpkg.com/@raruto/[email protected]/dist/leaflet-elevation.min.css" />
<script src="https://unpkg.com/@raruto/[email protected]/dist/leaflet-elevation.min.js"></script>
</head>
<body style="flex-direction: row; flex-wrap: wrap; gap: 10px;">
<div id="map-1" class="leaflet-map" style="flex: calc(50% - 5px);"></div>
<div id="map-2" class="leaflet-map" style="flex: calc(50% - 5px);"></div>
<div id="map-3" class="leaflet-map" style="flex: 100%; height: 50%;"></div>
<script>
let opts = {
map: {
center: [41.4583, 12.7059],
zoom: 5,
preferCanvas: true,
rotate: true,
// bearing: 45,
rotateControl: {
closeOnZeroBearing: true
},
fullscreenControl: false,
minimapControl: false,
searchControl: false,
locateControl: false,
pegmanControl: false,
zoomControl: false,
resizerControl: false,
layersControl: false,
},
elevationControl: {
urls: {
'map-1': "https://raruto.github.io/leaflet-elevation/examples/via-emilia.gpx",
'map-2': "https://raruto.github.io/leaflet-elevation/examples/via-aurelia.gpx",
'map-3': "https://raruto.github.io/leaflet-elevation/examples/demo.tcx",
},
options: {
theme: "lightblue-theme",
collapsed: false,
autohide: false,
autofitBounds: true,
position: "bottomleft",
detached: false,
summary: "inline",
imperial: false,
// altitude: "disabled",
slope: "disabled",
speed: false,
acceleration: false,
time: "summary",
legend: true,
followMarker: true,
almostOver: true,
distanceMarkers: false,
hotline: false,
edgeScale: {
bar: true,
icon: false,
coords: false,
}
},
},
layersControl: {
options: {
collapsed: false,
},
},
};
let maps = [], charts = [];
for (const id of ['map-1', 'map-2', 'map-3']) {
opts.elevationControl.options.detached = ['map-3'].includes(id);
opts.elevationControl.options.marker = ['map-3'].includes(id) ? 'position-marker' : 'elevation-line';
let map = L.map(id, opts.map);
let controlElevation = L.control.elevation(opts.elevationControl.options).addTo(map);
let controlLayer = L.control.layers(null, null, opts.layersControl.options);
controlElevation.on('eledata_loaded', ({layer, name}) => controlLayer.addTo(map) && layer.eachLayer((trkseg) => trkseg.feature.geometry.type != "Point" && controlLayer.addOverlay(trkseg, trkseg.feature && trkseg.feature.properties && trkseg.feature.properties.name || name)));
controlElevation.load(opts.elevationControl.urls[id]);
maps.push(map);
charts.push(controlElevation);
}
</script>
<!-- i18n -->
<script>
// Register a custom locale
L.registerLocale('en:18', {
"Acceleration" : "Acceleration",
"Altitude" : "Elevation",
"Slope" : "Slope",
"Speed" : "Velocity",
"Total Length: " : "L: ",
"Max Elevation: " : "E Max: ",
"Min Elevation: " : "E Min: ",
"Avg Elevation: " : "E Avg: ",
"Total Time: " : "T: ",
"Total Ascent: " : "Asc: ",
"Total Descent: " : "Desc: ",
"Min Slope: " : "S Min: ",
"Max Slope: " : "S Max: ",
"Avg Slope: " : "S Avg: ",
"Min Speed: " : "V Min: ",
"Max Speed: " : "V Max: ",
"Avg Speed: " : "V Avg: ",
"Min Acceleration: ": "A Min: ",
"Max Acceleration: ": "A Max: ",
"Avg Acceleration: ": "A Avg: ",
});
// Enable a custom locale
// L.setLocale('en:18');
// You can also override a previously defined object
L.locales['en'] = L.extend({
"y: " : "",
"x: " : "",
"t: " : "",
"T: " : "",
"m: " : "",
"v: " : "",
"a: " : "",
}, L.locales['en']);
// Switch the language
L.setLocale('en');
</script>
<a href="https://github.com/Raruto/leaflet-elevation" class="view-on-github" style="position: fixed;top: 30px;left: calc(50% - 81px);z-index: 9999;"> <img alt="View on Github" src="https://raruto.github.io/img/view-on-github.png" title="View on Github" width="163"> </a>
</body>
</html>