@raruto/leaflet-elevation 2.1.1 → 2.2.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 +6 -6
- package/dist/leaflet-elevation.js +7 -19
- 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/package.json +1 -1
- package/src/components/chart.js +1 -1
- package/src/control.js +5 -17
- package/src/handlers/pace.js +65 -0
- package/src/options.js +2 -2
- package/spec/index.js +0 -2
- package/spec/index.min.js +0 -1
- package/spec/mock.js +0 -26
- package/spec/mock.min.js +0 -1
- package/spec/utils.test.js +0 -41
- package/spec/utils.test.min.js +0 -1
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ _For a working example see one of the following demos:_
|
|
|
26
26
|
- [loading multiple maps](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_multiple-maps.html)
|
|
27
27
|
- [translating plugin labels](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_i18n-strings.html)
|
|
28
28
|
- [using custom colors](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_custom-theme.html)
|
|
29
|
-
- [using .gpx extensions (cadence
|
|
29
|
+
- [using .gpx extensions (cadence, heart, pace)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_extended-ui.html)
|
|
30
30
|
- [using .gpx waypoint icons](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_gpx-waypoints.html)
|
|
31
31
|
- [using .geojson waypoint icons](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_geojson-waypoints.html)
|
|
32
32
|
|
|
@@ -124,15 +124,15 @@ _For a working example see one of the following demos:_
|
|
|
124
124
|
// Speed chart profile: true || "summary" || "disabled" || false
|
|
125
125
|
speed: false,
|
|
126
126
|
|
|
127
|
+
// Altitude chart profile: true || "summary" || "disabled" || false
|
|
128
|
+
altitude: true,
|
|
129
|
+
|
|
127
130
|
// Display time info: true || "summary" || false
|
|
128
|
-
time:
|
|
131
|
+
time: true,
|
|
129
132
|
|
|
130
|
-
// Display distance info: true || "summary"
|
|
133
|
+
// Display distance info: true || "summary" || false
|
|
131
134
|
distance: true,
|
|
132
135
|
|
|
133
|
-
// Display altitude info: true || "summary"
|
|
134
|
-
altitude: true,
|
|
135
|
-
|
|
136
136
|
// Summary track info style: "inline" || "multiline" || false
|
|
137
137
|
summary: 'multiline',
|
|
138
138
|
|
|
@@ -218,7 +218,7 @@
|
|
|
218
218
|
followMarker: true,
|
|
219
219
|
imperial: false,
|
|
220
220
|
legend: true,
|
|
221
|
-
handlers: [],
|
|
221
|
+
handlers: ["Distance", "Time", "Altitude", "Slope", "Speed", "Acceleration"],
|
|
222
222
|
hotline: 'elevation',
|
|
223
223
|
marker: 'elevation-line',
|
|
224
224
|
markerIcon: L.divIcon({
|
|
@@ -247,7 +247,7 @@
|
|
|
247
247
|
summary: 'inline',
|
|
248
248
|
slope: false,
|
|
249
249
|
speed: false,
|
|
250
|
-
time:
|
|
250
|
+
time: true,
|
|
251
251
|
timeFactor: 3600,
|
|
252
252
|
timestamps: false,
|
|
253
253
|
trkStart: L.circleMarker([0,0], { className: 'start-marker', radius: 6, weight: 2, color: '#fff', fillColor: '#00d800', fillOpacity: 1, interactive: false }),
|
|
@@ -516,17 +516,7 @@
|
|
|
516
516
|
|
|
517
517
|
if (!this.eleDiv) this.eleDiv = container;
|
|
518
518
|
|
|
519
|
-
|
|
520
|
-
"Distance",
|
|
521
|
-
"Time",
|
|
522
|
-
"Altitude",
|
|
523
|
-
"Slope",
|
|
524
|
-
"Speed",
|
|
525
|
-
"Acceleration",
|
|
526
|
-
...this.options.handlers
|
|
527
|
-
].filter(m => false !== this.options[typeof m == "string" && m.toLowerCase()]);
|
|
528
|
-
|
|
529
|
-
this._loadModules(modules).then(() => { // Inject here required modules (data handlers)
|
|
519
|
+
this._loadModules(this.options.handlers).then(() => { // Inject here required modules (data handlers)
|
|
530
520
|
this._initChart(container);
|
|
531
521
|
this._initButton(container);
|
|
532
522
|
this._initSummary(container);
|
|
@@ -1014,14 +1004,12 @@
|
|
|
1014
1004
|
// First map known classnames (eg. "Altitude" --> L.Control.Elevation.Altitude)
|
|
1015
1005
|
handlers = handlers.map((h) => typeof h === 'string' && typeof Elevation[h] !== "undefined" ? Elevation[h] : h);
|
|
1016
1006
|
// Then load optional classes and custom imports (eg. "Cadence" --> import('../src/handlers/cadence.js'))
|
|
1017
|
-
let modules = handlers
|
|
1018
|
-
.filter(h => typeof h === 'string' || h instanceof Promise)
|
|
1019
|
-
.map(file => file instanceof Promise ? file : this.import(this.__modulesFolder + file.toLowerCase() + '.js'));
|
|
1007
|
+
let modules = handlers.map(file => (typeof file === 'string' && this.import(this.__modulesFolder + file.toLowerCase() + '.js')) || (file instanceof Promise && file) || Promise.resolve());
|
|
1020
1008
|
return Promise.all(modules).then((m) => {
|
|
1021
|
-
each(m, (exported) => {
|
|
1022
|
-
let fn = Object.keys(exported)[0];
|
|
1009
|
+
each(m, (exported, i) => {
|
|
1010
|
+
let fn = exported && Object.keys(exported)[0];
|
|
1023
1011
|
if (fn) {
|
|
1024
|
-
handlers[
|
|
1012
|
+
handlers[i] = Elevation[fn] = (Elevation[fn] ?? exported[fn]);
|
|
1025
1013
|
}
|
|
1026
1014
|
});
|
|
1027
1015
|
each(handlers, h => ["function", "object"].includes(typeof h) && this._registerHandler(h));
|