@raruto/leaflet-elevation 2.3.4 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +325 -323
- package/dist/leaflet-elevation.js +1619 -1575
- package/dist/leaflet-elevation.js.map +1 -1
- package/dist/leaflet-elevation.min.js +1 -1
- package/dist/leaflet-elevation.min.js.map +1 -1
- package/libs/leaflet-gpxgroup.js +346 -340
- package/libs/leaflet-gpxgroup.min.js +1 -1
- package/libs/leaflet-hotline.js +456 -456
- package/package.json +74 -74
- package/src/components/chart.js +783 -783
- package/src/components/d3.js +649 -641
- package/src/components/marker.js +96 -96
- package/src/control.js +1335 -1332
- package/src/handlers/labels.js +45 -0
- package/src/handlers/lineargradient.js +122 -0
- package/src/handlers/runner.js +109 -0
- package/src/handlers/time.js +102 -102
- package/src/options.js +88 -88
- package/src/utils.js +203 -163
package/README.md
CHANGED
|
@@ -1,323 +1,325 @@
|
|
|
1
|
-
# leaflet-elevation.js
|
|
2
|
-
|
|
3
|
-
[](https://www.npmjs.com/package/@raruto/leaflet-elevation)
|
|
4
|
-
[](LICENSE)
|
|
5
|
-
|
|
6
|
-
A Leaflet plugin that allows to add elevation profiles using d3js
|
|
7
|
-
|
|
8
|
-
<p align="center">
|
|
9
|
-
<a href="https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hoverable-tracks.html"><img src="https://raruto.github.io/img/leaflet-elevation.png" alt="Leaflet elevation viewer" /></a>
|
|
10
|
-
</p>
|
|
11
|
-
|
|
12
|
-
---
|
|
13
|
-
|
|
14
|
-
_For a working example see one of the following demos:_
|
|
15
|
-
|
|
16
|
-
- [loading .gpx file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation.html)
|
|
17
|
-
- [loading .geojson file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_geojson-data.html)
|
|
18
|
-
- [loading .kml file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_kml-data.html)
|
|
19
|
-
- [loading .tcx file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_tcx-data.html)
|
|
20
|
-
- [loading a local .gpx file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_upload-gpx.html)
|
|
21
|
-
- [loading data from a textarea](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_string-data.html)
|
|
22
|
-
- [loading individual .geojson tracks](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_geojson-group.html)
|
|
23
|
-
- [loading individual .gpx tracks](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_toggable-tracks.html)
|
|
24
|
-
- [loading multiple .gpx tracks (hover to toggle)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hoverable-tracks.html)
|
|
25
|
-
- [loading multiple .gpx tracks (click to toggle)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_toggable-charts.html)
|
|
26
|
-
- [loading multiple maps](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_multiple-maps.html)
|
|
27
|
-
- [translating plugin labels](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_i18n-strings.html)
|
|
28
|
-
- [
|
|
29
|
-
- [using
|
|
30
|
-
- [using .gpx
|
|
31
|
-
- [using .
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
- [autohide
|
|
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
|
-
npm
|
|
212
|
-
npm run
|
|
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
|
-
import
|
|
270
|
-
import '
|
|
271
|
-
import '
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
- https://
|
|
295
|
-
- https://
|
|
296
|
-
- https://
|
|
297
|
-
- https://
|
|
298
|
-
- https://
|
|
299
|
-
- https://
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
[](https://www.npmjs.com/package/@raruto/leaflet-elevation)
|
|
4
|
+
[](LICENSE)
|
|
5
|
+
|
|
6
|
+
A Leaflet plugin that allows to add elevation profiles using d3js
|
|
7
|
+
|
|
8
|
+
<p align="center">
|
|
9
|
+
<a href="https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hoverable-tracks.html"><img src="https://raruto.github.io/img/leaflet-elevation.png" alt="Leaflet elevation viewer" /></a>
|
|
10
|
+
</p>
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
_For a working example see one of the following demos:_
|
|
15
|
+
|
|
16
|
+
- [loading .gpx file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation.html)
|
|
17
|
+
- [loading .geojson file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_geojson-data.html)
|
|
18
|
+
- [loading .kml file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_kml-data.html)
|
|
19
|
+
- [loading .tcx file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_tcx-data.html)
|
|
20
|
+
- [loading a local .gpx file](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_upload-gpx.html)
|
|
21
|
+
- [loading data from a textarea](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_string-data.html)
|
|
22
|
+
- [loading individual .geojson tracks](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_geojson-group.html)
|
|
23
|
+
- [loading individual .gpx tracks](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_toggable-tracks.html)
|
|
24
|
+
- [loading multiple .gpx tracks (hover to toggle)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hoverable-tracks.html)
|
|
25
|
+
- [loading multiple .gpx tracks (click to toggle)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_toggable-charts.html)
|
|
26
|
+
- [loading multiple maps](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_multiple-maps.html)
|
|
27
|
+
- [translating plugin labels](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_i18n-strings.html)
|
|
28
|
+
- [rotating chart labels](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_chart_labels.html)
|
|
29
|
+
- [using custom colors](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_custom-theme.html)
|
|
30
|
+
- [using .gpx extensions (cadence, heart, pace)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_extended-ui.html)
|
|
31
|
+
- [using .gpx waypoint icons](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_gpx-waypoints.html)
|
|
32
|
+
- [using .geojson waypoint icons](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_geojson-waypoints.html)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
<br/>
|
|
36
|
+
|
|
37
|
+
- [autohide map](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hidden-map.html)
|
|
38
|
+
- [autohide chart](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hidden-chart.html)
|
|
39
|
+
- [clear button](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_clear-button.html)
|
|
40
|
+
- [collapsible button](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_close-button.html)
|
|
41
|
+
- [custom summary](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_custom-summary.html)
|
|
42
|
+
- [edge scale control](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_edge-scale.html)
|
|
43
|
+
- [follow marker](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_follow-marker.html)
|
|
44
|
+
- [layer almostover](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_almost-over.html)
|
|
45
|
+
- [linear gradient](https://raruto.github.io/leaflet-elevation/examples/leaflet-linear-gradient.html)
|
|
46
|
+
- [slope chart](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_slope-chart.html)
|
|
47
|
+
- [speed chart](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_speed-chart.html)
|
|
48
|
+
- [walking marker](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_dynamic-runner.html)
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
<blockquote>
|
|
53
|
+
<p align="center">
|
|
54
|
+
<em>Initially based on the <a href="http://mrmufflon.github.io/Leaflet.Elevation/">work</a> of <strong>Felix “MrMufflon” Bache</strong></em>
|
|
55
|
+
</p>
|
|
56
|
+
</blockquote>
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## How to use
|
|
61
|
+
|
|
62
|
+
1. **include CSS & JavaScript**
|
|
63
|
+
```html
|
|
64
|
+
<head>
|
|
65
|
+
...
|
|
66
|
+
<style> html, body, #map, #elevation-div { height: 100%; width: 100%; padding: 0; margin: 0; } #map { height: 75%; } #elevation-div { height: 25%; font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif; } </style>
|
|
67
|
+
|
|
68
|
+
<!-- leaflet-ui -->
|
|
69
|
+
<script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
|
|
70
|
+
<script src="https://unpkg.com/leaflet-ui@0.6.0/dist/leaflet-ui.js"></script>
|
|
71
|
+
|
|
72
|
+
<!-- leaflet-elevation -->
|
|
73
|
+
<link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation/dist/leaflet-elevation.css" />
|
|
74
|
+
<script src="https://unpkg.com/@raruto/leaflet-elevation/dist/leaflet-elevation.js"></script>
|
|
75
|
+
...
|
|
76
|
+
</head>
|
|
77
|
+
```
|
|
78
|
+
2. **choose the div container used for the slippy map**
|
|
79
|
+
```html
|
|
80
|
+
<body>
|
|
81
|
+
...
|
|
82
|
+
<div id="map"></div>
|
|
83
|
+
...
|
|
84
|
+
</body>
|
|
85
|
+
```
|
|
86
|
+
3. **create your first simple “leaflet-elevation” slippy map**
|
|
87
|
+
```html
|
|
88
|
+
<script>
|
|
89
|
+
// Full list options at "leaflet-elevation.js"
|
|
90
|
+
var elevation_options = {
|
|
91
|
+
|
|
92
|
+
// Default chart colors: theme lime-theme, magenta-theme, ...
|
|
93
|
+
theme: "lightblue-theme",
|
|
94
|
+
|
|
95
|
+
// Chart container outside/inside map container
|
|
96
|
+
detached: true,
|
|
97
|
+
|
|
98
|
+
// if (detached), the elevation chart container
|
|
99
|
+
elevationDiv: "#elevation-div",
|
|
100
|
+
|
|
101
|
+
// if (!detached) autohide chart profile on chart mouseleave
|
|
102
|
+
autohide: false,
|
|
103
|
+
|
|
104
|
+
// if (!detached) initial state of chart profile control
|
|
105
|
+
collapsed: false,
|
|
106
|
+
|
|
107
|
+
// if (!detached) control position on one of map corners
|
|
108
|
+
position: "topright",
|
|
109
|
+
|
|
110
|
+
// Toggle close icon visibility
|
|
111
|
+
closeBtn: true,
|
|
112
|
+
|
|
113
|
+
// Autoupdate map center on chart mouseover.
|
|
114
|
+
followMarker: true,
|
|
115
|
+
|
|
116
|
+
// Autoupdate map bounds on chart update.
|
|
117
|
+
autofitBounds: true,
|
|
118
|
+
|
|
119
|
+
// Chart distance/elevation units.
|
|
120
|
+
imperial: false,
|
|
121
|
+
|
|
122
|
+
// [Lat, Long] vs [Long, Lat] points. (leaflet default: [Lat, Long])
|
|
123
|
+
reverseCoords: false,
|
|
124
|
+
|
|
125
|
+
// Acceleration chart profile: true || "summary" || "disabled" || false
|
|
126
|
+
acceleration: false,
|
|
127
|
+
|
|
128
|
+
// Slope chart profile: true || "summary" || "disabled" || false
|
|
129
|
+
slope: false,
|
|
130
|
+
|
|
131
|
+
// Speed chart profile: true || "summary" || "disabled" || false
|
|
132
|
+
speed: false,
|
|
133
|
+
|
|
134
|
+
// Altitude chart profile: true || "summary" || "disabled" || false
|
|
135
|
+
altitude: true,
|
|
136
|
+
|
|
137
|
+
// Display time info: true || "summary" || false
|
|
138
|
+
time: true,
|
|
139
|
+
|
|
140
|
+
// Display distance info: true || "summary" || false
|
|
141
|
+
distance: true,
|
|
142
|
+
|
|
143
|
+
// Summary track info style: "inline" || "multiline" || false
|
|
144
|
+
summary: 'multiline',
|
|
145
|
+
|
|
146
|
+
// Download link: "link" || false || "modal"
|
|
147
|
+
downloadLink: 'link',
|
|
148
|
+
|
|
149
|
+
// Toggle chart ruler filter
|
|
150
|
+
ruler: true,
|
|
151
|
+
|
|
152
|
+
// Toggle chart legend filter
|
|
153
|
+
legend: true,
|
|
154
|
+
|
|
155
|
+
// Toggle "leaflet-almostover" integration
|
|
156
|
+
almostOver: true,
|
|
157
|
+
|
|
158
|
+
// Toggle "leaflet-distance-markers" integration
|
|
159
|
+
distanceMarkers: false,
|
|
160
|
+
|
|
161
|
+
// Toggle "leaflet-edgescale" integration
|
|
162
|
+
edgeScale: false,
|
|
163
|
+
|
|
164
|
+
// Toggle "leaflet-hotline" integration
|
|
165
|
+
hotline: true,
|
|
166
|
+
|
|
167
|
+
// Display track datetimes: true || false
|
|
168
|
+
timestamps: false,
|
|
169
|
+
|
|
170
|
+
// Display track waypoints: true || "markers" || "dots" || false
|
|
171
|
+
waypoints: true,
|
|
172
|
+
|
|
173
|
+
// Toggle custom waypoint icons: true || { associative array of <sym> tags } || false
|
|
174
|
+
wptIcons: {
|
|
175
|
+
'': L.divIcon({
|
|
176
|
+
className: 'elevation-waypoint-marker',
|
|
177
|
+
html: '<i class="elevation-waypoint-icon"></i>',
|
|
178
|
+
iconSize: [30, 30],
|
|
179
|
+
iconAnchor: [8, 30],
|
|
180
|
+
}),
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
// Toggle waypoint labels: true || "markers" || "dots" || false
|
|
184
|
+
wptLabels: true,
|
|
185
|
+
|
|
186
|
+
// Render chart profiles as Canvas or SVG Paths
|
|
187
|
+
preferCanvas: true,
|
|
188
|
+
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// Instantiate map (leaflet-ui).
|
|
192
|
+
var map = L.map('map', { mapTypeId: 'terrain', center: [41.4583, 12.7059], zoom: 5 });
|
|
193
|
+
|
|
194
|
+
// Instantiate elevation control.
|
|
195
|
+
var controlElevation = L.control.elevation(elevation_options).addTo(map);
|
|
196
|
+
|
|
197
|
+
// Load track from url (allowed data types: "*.geojson", "*.gpx", "*.tcx")
|
|
198
|
+
controlElevation.load("https://raruto.github.io/leaflet-elevation/examples/via-emilia.gpx");
|
|
199
|
+
|
|
200
|
+
</script>
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
### Build Guide
|
|
204
|
+
|
|
205
|
+
Within your local development environment:
|
|
206
|
+
|
|
207
|
+
```shell
|
|
208
|
+
git clone git@github.com:Raruto/leaflet-elevation.git
|
|
209
|
+
cd ./leaflet-elevation
|
|
210
|
+
|
|
211
|
+
npm i # install dependencies
|
|
212
|
+
npm run dev # start dev server at: http://localhost:8080
|
|
213
|
+
npm run build # generate "dist" files (once)
|
|
214
|
+
npm run test # test all "*.spec.js" files (once)
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
After that you can start developing inside the `src` and `test` folders (eg. open "http://localhost:8080/test" in your browser to preview changes). Check also [CONTRIBUTING.md](.github/CONTRIBUTING.md) file for some information about it.
|
|
218
|
+
|
|
219
|
+
### FAQ
|
|
220
|
+
|
|
221
|
+
<details>
|
|
222
|
+
<summary>1. How can I change the color of the elevation plot?</summary><br>
|
|
223
|
+
|
|
224
|
+
There are multiple options to achieve this:
|
|
225
|
+
|
|
226
|
+
* You could either use some default presets (see: theme: "lightblue-theme" option in readme file and the following file `leaflet-elevation.css` for some other default "*-theme" names).
|
|
227
|
+
* check out [this example](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_custom-theme.html)
|
|
228
|
+
* Or add the following lines for custom colors.
|
|
229
|
+
```css
|
|
230
|
+
.elevation-control .area {
|
|
231
|
+
fill: red;
|
|
232
|
+
}
|
|
233
|
+
.elevation-control .background {
|
|
234
|
+
background-color: white;
|
|
235
|
+
```
|
|
236
|
+
</details>
|
|
237
|
+
|
|
238
|
+
<details>
|
|
239
|
+
<summary>2. How to enable/disable the leaflet user interface customizations?</summary><br>
|
|
240
|
+
|
|
241
|
+
These customizations are actually part of the [leaflet-ui](https://github.com/Raruto/leaflet-ui) and can be toggled on/off using e.g. the following options:
|
|
242
|
+
```js
|
|
243
|
+
var map = L.map('map', {
|
|
244
|
+
center: [41.4583, 12.7059], // needs value to initialize
|
|
245
|
+
zoom: 5, // needs value to initialize
|
|
246
|
+
mapTypeId: 'topo',
|
|
247
|
+
mapTypeIds: ['osm', 'terrain', 'satellite', 'topo'],
|
|
248
|
+
gestureHandling: false, // zoom with Cmd + Scroll
|
|
249
|
+
zoomControl: true, // plus minus buttons
|
|
250
|
+
pegmanControl: false,
|
|
251
|
+
locateControl: false,
|
|
252
|
+
fullscreenControl: true,
|
|
253
|
+
layersControl: true,
|
|
254
|
+
minimapControl: false,
|
|
255
|
+
editInOSMControl: false,
|
|
256
|
+
loadingControl: false,
|
|
257
|
+
searchControl: false,
|
|
258
|
+
disableDefaultUI: false,
|
|
259
|
+
printControl: false,
|
|
260
|
+
});
|
|
261
|
+
```
|
|
262
|
+
</details>
|
|
263
|
+
|
|
264
|
+
<details> <summary>3. How can I import this library as ES module?</summary>
|
|
265
|
+
|
|
266
|
+
Usually, when working with a js bundler like [Vite](https://vitest.dev/) or [Webpack](https://webpack.js.org/), you need to provide to this library the full path to some dynamically imported files from the [`srcFolder`](./src/):
|
|
267
|
+
|
|
268
|
+
```js
|
|
269
|
+
import './your-custom-style.css';
|
|
270
|
+
import 'leaflet/dist/leaflet.css';
|
|
271
|
+
import L from 'leaflet';
|
|
272
|
+
import '@raruto/leaflet-elevation/src/index.js';
|
|
273
|
+
import '@raruto/leaflet-elevation/src/index.css';
|
|
274
|
+
|
|
275
|
+
const map = L.map('map', {
|
|
276
|
+
center: [41.4583, 12.7059]
|
|
277
|
+
zoom: 5,
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const controlElevation = L.control.elevation({
|
|
281
|
+
// CHANGE ME: with your own http server folder (eg. "http://custom-server/public/path/to/leaflet-elevation/src/")
|
|
282
|
+
srcFolder: 'http://unpkg.com/@raruto/leaflet-elevation/src/'
|
|
283
|
+
}).addTo(map);
|
|
284
|
+
|
|
285
|
+
// Load track from url (allowed data types: "*.geojson", "*.gpx", "*.tcx")
|
|
286
|
+
controlElevation.load("https://raruto.github.io/leaflet-elevation/examples/via-emilia.gpx");
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
</details>
|
|
290
|
+
|
|
291
|
+
<details>
|
|
292
|
+
<summary>4. Some real world projects based on this plugin?</summary><br>
|
|
293
|
+
|
|
294
|
+
- https://parcours.scasb.org/
|
|
295
|
+
- https://velocat.ru/velo/phpBB3/map.php
|
|
296
|
+
- https://plugins.qgis.org/plugins/track_profile_2_web/
|
|
297
|
+
- https://wordpress.org/plugins/os-datahub-maps/
|
|
298
|
+
- https://wordpress.org/plugins/extensions-leaflet-map/
|
|
299
|
+
- https://github.com/der-stefan/OpenTopoMap
|
|
300
|
+
- https://gpx.n-peloton.fr/
|
|
301
|
+
- https://walkaholic.me/map
|
|
302
|
+
|
|
303
|
+
</details>
|
|
304
|
+
|
|
305
|
+
_Related: [Leaflet-UI presets](https://github.com/raruto/leaflet-ui), [QGIS Integration](https://github.com/faunalia/trackprofile2web)_
|
|
306
|
+
|
|
307
|
+
### Changelog
|
|
308
|
+
|
|
309
|
+
All notable changes to this project are documented in the [releases](https://github.com/Raruto/leaflet-elevation/releases) page.
|
|
310
|
+
|
|
311
|
+
---
|
|
312
|
+
|
|
313
|
+
**Compatibile with:**
|
|
314
|
+
[](http://leafletjs.com/reference.html)
|
|
315
|
+
[](https://www.npmjs.com/package/d3)
|
|
316
|
+
[](https://www.npmjs.com/package/@tmcw/togeojson)
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
---
|
|
320
|
+
|
|
321
|
+
**Contributors:** [MrMufflon](https://github.com/MrMufflon/Leaflet.Elevation), [HostedDinner](https://github.com/HostedDinner/Leaflet.Elevation), [ADoroszlai](http://ADoroszlai.github.io/joebed/), [Raruto](https://github.com/Raruto/leaflet-elevation)
|
|
322
|
+
|
|
323
|
+
---
|
|
324
|
+
|
|
325
|
+
**License:** GPL-3.0+
|