@raruto/leaflet-elevation 2.0.0 → 2.0.3
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 +2 -1
- package/dist/leaflet-elevation.css +3 -1
- package/dist/leaflet-elevation.js +148 -189
- package/dist/leaflet-elevation.js.map +1 -1
- package/dist/leaflet-elevation.min.css +1 -1
- package/dist/leaflet-elevation.min.js +1 -1
- package/dist/leaflet-elevation.min.js.map +1 -1
- package/libs/leaflet-distance-marker.js +97 -92
- package/libs/leaflet-distance-marker.min.js +1 -1
- package/package.json +1 -1
- package/src/{chart.js → components/chart.js} +78 -54
- package/src/{components.js → components/d3.js} +74 -16
- package/src/{marker.js → components/marker.js} +1 -1
- package/src/{summary.js → components/summary.js} +0 -0
- package/src/control.js +141 -184
- package/src/handlers/altitude.js +4 -1
- package/src/handlers/heart.js +2 -2
- package/src/index.css +3 -1
- package/src/utils.js +5 -5
- package/src/handlers/acceleration.min.js +0 -1
- package/src/handlers/altitude.min.js +0 -1
- package/src/handlers/distance.min.js +0 -1
- package/src/handlers/slope.min.js +0 -1
- package/src/handlers/speed.min.js +0 -1
- package/src/handlers/time.min.js +0 -1
package/README.md
CHANGED
|
@@ -241,6 +241,7 @@ var map = L.map('map', {
|
|
|
241
241
|
- https://wordpress.org/plugins/extensions-leaflet-map/
|
|
242
242
|
- https://github.com/der-stefan/OpenTopoMap
|
|
243
243
|
- https://gpx.n-peloton.fr/
|
|
244
|
+
- https://walkaholic.me/map
|
|
244
245
|
|
|
245
246
|
</details>
|
|
246
247
|
|
|
@@ -251,7 +252,7 @@ _Related: [Leaflet-UI presets](https://github.com/raruto/leaflet-ui), [QGIS Inte
|
|
|
251
252
|
**Compatibile with:**
|
|
252
253
|
[](http://leafletjs.com/reference.html)
|
|
253
254
|
[](https://www.npmjs.com/package/d3)
|
|
254
|
-
[](https://www.npmjs.com/package/@tmcw/togeojson)
|
|
255
256
|
|
|
256
257
|
|
|
257
258
|
---
|
|
@@ -60,6 +60,7 @@
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
.elevation-control.elevation .axis text,
|
|
63
|
+
.elevation-control.elevation .legend text,
|
|
63
64
|
.elevation-control.elevation .point text {
|
|
64
65
|
fill: #000;
|
|
65
66
|
font-weight: 700;
|
|
@@ -246,7 +247,7 @@
|
|
|
246
247
|
.leaflet-elevation-pane .height-focus,
|
|
247
248
|
.leaflet-overlay-pane .height-focus {
|
|
248
249
|
stroke: #000;
|
|
249
|
-
fill: var(--ele-area, #FFF);
|
|
250
|
+
fill: var(--ele-circle, var(--ele-area, #FFF));
|
|
250
251
|
}
|
|
251
252
|
|
|
252
253
|
.leaflet-elevation-pane .height-focus.line,
|
|
@@ -341,6 +342,7 @@
|
|
|
341
342
|
--ele-area: #3366CC;
|
|
342
343
|
--ele-alpha: 0.45;
|
|
343
344
|
--ele-stroke: #4682B4;
|
|
345
|
+
--ele-circle: #fff;
|
|
344
346
|
}
|
|
345
347
|
|
|
346
348
|
.elevation-detached .lightblue-theme.elevation-control.elevation .area {
|
|
@@ -135,11 +135,11 @@
|
|
|
135
135
|
* Loop and extract GPX Extensions handled by "@tmcw/toGeoJSON" (eg. "coordinateProperties" > "times")
|
|
136
136
|
*/
|
|
137
137
|
function coordPropsToMeta(coordProps, name, parser) {
|
|
138
|
-
return coordProps && (({props, point, id}) => {
|
|
138
|
+
return coordProps && (({props, point, id, isMulti }) => {
|
|
139
139
|
if (props) {
|
|
140
140
|
for (const key of coordProps) {
|
|
141
141
|
if (key in props) {
|
|
142
|
-
point.meta[name] = (parser || parseInt).call(this, props[key], id);
|
|
142
|
+
point.meta[name] = (parser || parseInt).call(this, (isMulti ? props[key][isMulti] : props[key]), id);
|
|
143
143
|
break;
|
|
144
144
|
}
|
|
145
145
|
}
|
|
@@ -186,9 +186,9 @@
|
|
|
186
186
|
/**
|
|
187
187
|
* Alias for some leaflet core functions
|
|
188
188
|
*/
|
|
189
|
-
const { on, off }
|
|
190
|
-
const { throttle } = L.Util;
|
|
191
|
-
const { hasClass }
|
|
189
|
+
const { on, off } = L.DomEvent;
|
|
190
|
+
const { throttle, wrapNum } = L.Util;
|
|
191
|
+
const { hasClass } = L.DomUtil;
|
|
192
192
|
|
|
193
193
|
/**
|
|
194
194
|
* Limit floating point precision
|
|
@@ -236,6 +236,7 @@
|
|
|
236
236
|
on: on,
|
|
237
237
|
off: off,
|
|
238
238
|
throttle: throttle,
|
|
239
|
+
wrapNum: wrapNum,
|
|
239
240
|
hasClass: hasClass,
|
|
240
241
|
round: round,
|
|
241
242
|
clamp: clamp,
|
|
@@ -337,10 +338,10 @@
|
|
|
337
338
|
__LGEOMUTIL: 'https://unpkg.com/leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js',
|
|
338
339
|
__LALMOSTOVER: 'https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js',
|
|
339
340
|
__LDISTANCEM: '../libs/leaflet-distance-marker.min.js',
|
|
341
|
+
__LCHART: '../src/components/chart.js',
|
|
342
|
+
__LMARKER: '../src/components/marker.js',
|
|
343
|
+
__LSUMMARY: '../src/components/summary.js',
|
|
340
344
|
__modulesFolder: '../src/handlers/',
|
|
341
|
-
__LCHART: '../src/chart.js',
|
|
342
|
-
__LMARKER: '../src/marker.js',
|
|
343
|
-
__LSUMMARY: '../src/summary.js',
|
|
344
345
|
|
|
345
346
|
/*
|
|
346
347
|
* Add data to the diagram either from GPX or GeoJSON and update the axis domain and data
|
|
@@ -348,9 +349,7 @@
|
|
|
348
349
|
addData: function(d, layer) {
|
|
349
350
|
this.import(this.__D3)
|
|
350
351
|
.then(() => {
|
|
351
|
-
|
|
352
|
-
layer = d;
|
|
353
|
-
}
|
|
352
|
+
layer = layer ?? (d.on && d);
|
|
354
353
|
this._addData(d);
|
|
355
354
|
this._addLayer(layer);
|
|
356
355
|
this._fireEvt("eledata_added", { data: d, layer: layer, track_info: this.track_info });
|
|
@@ -619,51 +618,44 @@
|
|
|
619
618
|
return;
|
|
620
619
|
}
|
|
621
620
|
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
this._addGeoJSONData(geom.coordinates);
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
break;
|
|
635
|
-
|
|
636
|
-
default:
|
|
637
|
-
return console.warn('Unsopperted GeoJSON feature geometry type:' + geom.type);
|
|
621
|
+
// Standard GeoJSON
|
|
622
|
+
if (d.type === "FeatureCollection" ) {
|
|
623
|
+
return each(d.features, feature => this._addData(feature));
|
|
624
|
+
} else if (d.type === "Feature") {
|
|
625
|
+
let geom = d.geometry;
|
|
626
|
+
if (geom) {
|
|
627
|
+
switch (geom.type) {
|
|
628
|
+
case 'LineString': return this._addGeoJSONData(geom.coordinates, d.properties);
|
|
629
|
+
case 'MultiLineString': return each(geom.coordinates, (coords, i) => this._addGeoJSONData(coords, d.properties, i));
|
|
630
|
+
case 'Point':
|
|
631
|
+
default: return console.warn('Unsopperted GeoJSON feature geometry type:' + geom.type);
|
|
632
|
+
}
|
|
638
633
|
}
|
|
639
634
|
}
|
|
640
|
-
if (d.type === "FeatureCollection") {
|
|
641
|
-
each(d.features, feature => this._addData(feature));
|
|
642
|
-
}
|
|
643
635
|
|
|
644
|
-
|
|
645
|
-
* Extended GeoJSON --> rely on leaflet implementation
|
|
646
|
-
*/
|
|
636
|
+
// Fallback for leaflet layers (eg. L.Gpx)
|
|
647
637
|
if (d._latlngs) {
|
|
648
|
-
this._addGeoJSONData(d._latlngs, d.feature && d.feature.properties);
|
|
638
|
+
return this._addGeoJSONData(d._latlngs, d.feature && d.feature.properties);
|
|
649
639
|
}
|
|
640
|
+
|
|
650
641
|
},
|
|
651
642
|
|
|
652
643
|
/*
|
|
653
644
|
* Parsing of GeoJSON data lines and their elevation in z-coordinate
|
|
654
645
|
*/
|
|
655
|
-
_addGeoJSONData: function(coords, properties) {
|
|
646
|
+
_addGeoJSONData: function(coords, properties, nestingLevel) {
|
|
647
|
+
|
|
648
|
+
// "coordinateProperties" property is generated inside "@tmcw/toGeoJSON"
|
|
649
|
+
let props = (properties && properties.coordinateProperties) || properties;
|
|
650
|
+
|
|
656
651
|
coords.forEach((point, i) => {
|
|
657
652
|
|
|
658
653
|
// GARMIN_EXTENSIONS = ["hr", "cad", "atemp", "wtemp", "depth", "course", "bearing"];
|
|
659
654
|
point.meta = point.meta ?? { time: null, ele: null };
|
|
660
655
|
|
|
661
|
-
// "coordinateProperties" property is generated inside "@tmcw/toGeoJSON"
|
|
662
|
-
let props = (properties && properties.coordinateProperties) || properties;
|
|
663
|
-
|
|
664
656
|
point.prev = (attr) => (attr ? this._data[i > 0 ? i - 1 : 0][attr] : this._data[i > 0 ? i - 1 : 0]);
|
|
665
657
|
|
|
666
|
-
this.fire("elepoint_init", { point: point, props: props, id: i });
|
|
658
|
+
this.fire("elepoint_init", { point: point, props: props, id: i, isMulti: nestingLevel });
|
|
667
659
|
|
|
668
660
|
this._addPoint(
|
|
669
661
|
point.lat ?? point[1],
|
|
@@ -703,10 +695,12 @@
|
|
|
703
695
|
if (layer && this.options.distanceMarkers && this.options.distanceMarkers.lazy) {
|
|
704
696
|
layer.on('add remove', ({target, type}) => L.DistanceMarkers && target instanceof L.Polyline && target[type + 'DistanceMarkers']());
|
|
705
697
|
}
|
|
698
|
+
return layer;
|
|
706
699
|
},
|
|
707
700
|
|
|
708
701
|
_addMarker: function(marker) {
|
|
709
702
|
if (marker) this._markers.addLayer(marker);
|
|
703
|
+
return marker;
|
|
710
704
|
},
|
|
711
705
|
|
|
712
706
|
/**
|
|
@@ -922,10 +916,6 @@
|
|
|
922
916
|
.on('margins_updated', this._resizeChart, this);
|
|
923
917
|
|
|
924
918
|
|
|
925
|
-
this.fire("elechart_axis");
|
|
926
|
-
|
|
927
|
-
if (this.options.legend) this.fire("elechart_legend");
|
|
928
|
-
|
|
929
919
|
this.fire("elechart_init");
|
|
930
920
|
|
|
931
921
|
map
|
|
@@ -1038,7 +1028,7 @@
|
|
|
1038
1028
|
*/
|
|
1039
1029
|
_loadModules: function(handlers) {
|
|
1040
1030
|
// First map known classnames (eg. "Altitude" --> L.Control.Elevation.Altitude)
|
|
1041
|
-
handlers = handlers.map((h) => typeof h === 'string' && typeof
|
|
1031
|
+
handlers = handlers.map((h) => typeof h === 'string' && typeof Elevation[h] !== "undefined" ? Elevation[h] : h);
|
|
1042
1032
|
// Then load optional classes and custom imports (eg. "Cadence" --> import('../src/handlers/cadence.js'))
|
|
1043
1033
|
Promise.
|
|
1044
1034
|
all(
|
|
@@ -1049,8 +1039,8 @@
|
|
|
1049
1039
|
.then((m) => {
|
|
1050
1040
|
each(m, (exported) => {
|
|
1051
1041
|
let fn = Object.keys(exported)[0];
|
|
1052
|
-
if (fn && typeof
|
|
1053
|
-
handlers[fn] =
|
|
1042
|
+
if (fn && typeof Elevation[fn] === "undefined" ) {
|
|
1043
|
+
handlers[fn] = Elevation[fn] = exported[fn];
|
|
1054
1044
|
|
|
1055
1045
|
}
|
|
1056
1046
|
});
|
|
@@ -1062,65 +1052,48 @@
|
|
|
1062
1052
|
* Simple GeoJSON data loader (L.GeoJSON).
|
|
1063
1053
|
*/
|
|
1064
1054
|
_loadLayer: function(geojson) {
|
|
1065
|
-
let
|
|
1055
|
+
let { polyline, theme, waypoints, wptIcons, wptLabels, distanceMarkers } = this.options;
|
|
1056
|
+
let style = L.extend({}, polyline);
|
|
1057
|
+
|
|
1058
|
+
if (theme) {
|
|
1059
|
+
style.className += ' ' + theme;
|
|
1060
|
+
}
|
|
1066
1061
|
|
|
1067
|
-
|
|
1062
|
+
if (geojson.name) {
|
|
1063
|
+
this.track_info.name = geojson.name;
|
|
1064
|
+
}
|
|
1068
1065
|
|
|
1069
1066
|
let layer = L.geoJson(geojson, {
|
|
1070
|
-
distanceMarkers:
|
|
1071
|
-
style:
|
|
1072
|
-
let style = L.extend({}, control.options.polyline);
|
|
1073
|
-
if (control.options.theme) {
|
|
1074
|
-
style.className += ' ' + control.options.theme;
|
|
1075
|
-
}
|
|
1076
|
-
return style;
|
|
1077
|
-
},
|
|
1067
|
+
distanceMarkers: distanceMarkers,
|
|
1068
|
+
style: style,
|
|
1078
1069
|
pointToLayer: (feature, latlng) => {
|
|
1079
|
-
if (
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
latlng: latlng,
|
|
1090
|
-
label: ([true, 'dots'].includes(wptLabels) ? name : '')
|
|
1091
|
-
});
|
|
1092
|
-
}
|
|
1093
|
-
|
|
1094
|
-
// Handle map waypoints (markers)
|
|
1095
|
-
if ([true, 'markers'].includes(control.options.waypoints) && wptIcons != false) {
|
|
1096
|
-
// generate and cache appropriate icon symbol
|
|
1097
|
-
if (!wptIcons.hasOwnProperty(sym)) {
|
|
1098
|
-
wptIcons[sym] = L.divIcon(
|
|
1099
|
-
L.extend({}, wptIcons[""].options, { html: '<i class="elevation-waypoint-icon ' + sym + '"></i>' } )
|
|
1100
|
-
);
|
|
1070
|
+
if (waypoints) {
|
|
1071
|
+
let { desc, name, sym } = feature.properties;
|
|
1072
|
+
desc = desc || '';
|
|
1073
|
+
name = name || '';
|
|
1074
|
+
// Handle chart waypoints (dots)
|
|
1075
|
+
if ([true, 'dots'].includes(waypoints)) {
|
|
1076
|
+
this._registerCheckPoint({
|
|
1077
|
+
latlng: latlng,
|
|
1078
|
+
label : ([true, 'dots'].includes(wptLabels) ? name : '')
|
|
1079
|
+
});
|
|
1101
1080
|
}
|
|
1102
|
-
|
|
1103
|
-
if ([true, 'markers'].includes(
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1081
|
+
// Handle map waypoints (markers)
|
|
1082
|
+
if ([true, 'markers'].includes(waypoints) && wptIcons != false) {
|
|
1083
|
+
return this._registerMarker({
|
|
1084
|
+
latlng : latlng,
|
|
1085
|
+
sym : (sym ?? name).replace(' ', '-').replace('"', '').replace("'", '').toLowerCase(),
|
|
1086
|
+
content: [true, 'markers'].includes(wptLabels) && (name || desc) && decodeURI("<b>" + name + "</b>" + (desc.length > 0 ? '<br>' + desc : ''))
|
|
1087
|
+
});
|
|
1107
1088
|
}
|
|
1108
|
-
control._addMarker(marker);
|
|
1109
|
-
control.fire('waypoint_added', { point: marker, element: latlng, properties: prop });
|
|
1110
|
-
return marker;
|
|
1111
1089
|
}
|
|
1112
1090
|
},
|
|
1113
|
-
onEachFeature: (feature, layer) =>
|
|
1114
|
-
if (feature.geometry && feature.geometry.type != 'Point') {
|
|
1115
|
-
control.addData(layer);
|
|
1116
|
-
control.track_info = L.extend({}, control.track_info, { name: geojson.name });
|
|
1117
|
-
}
|
|
1118
|
-
},
|
|
1091
|
+
onEachFeature: (feature, layer) => feature.geometry && feature.geometry.type != 'Point' && this.addData(feature, layer),
|
|
1119
1092
|
});
|
|
1120
1093
|
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1094
|
+
this.import(this.__D3).then(() => {
|
|
1095
|
+
this._initMapIntegrations(this, layer);
|
|
1096
|
+
this._fireEvt("eledata_loaded", { data: geojson, layer: layer, name: this.track_info.name, track_info: this.track_info });
|
|
1124
1097
|
});
|
|
1125
1098
|
|
|
1126
1099
|
return layer;
|
|
@@ -1250,8 +1223,7 @@
|
|
|
1250
1223
|
geojson = this._parseFromGeoJSONString(data.toString());
|
|
1251
1224
|
}
|
|
1252
1225
|
if (geojson) {
|
|
1253
|
-
geojson = this.
|
|
1254
|
-
geojson = this._prepareAdditionalProperties(geojson);
|
|
1226
|
+
geojson.name = geojson.name || (this._downloadURL || '').split('/').pop().split('#')[0].split('?')[0];
|
|
1255
1227
|
}
|
|
1256
1228
|
resolve(geojson);
|
|
1257
1229
|
})
|
|
@@ -1279,37 +1251,6 @@
|
|
|
1279
1251
|
return geojson;
|
|
1280
1252
|
},
|
|
1281
1253
|
|
|
1282
|
-
/**
|
|
1283
|
-
* Extend GeoJSON properties (name, time, ...)
|
|
1284
|
-
*/
|
|
1285
|
-
_prepareAdditionalProperties: function(geojson) {
|
|
1286
|
-
if (!geojson.name && this._downloadURL) {
|
|
1287
|
-
geojson.name = this._downloadURL.split('/').pop().split('#')[0].split('?')[0];
|
|
1288
|
-
}
|
|
1289
|
-
return geojson;
|
|
1290
|
-
},
|
|
1291
|
-
|
|
1292
|
-
/**
|
|
1293
|
-
* Just a temporary fix for MultiLineString data (trk > trkseg + trkseg),
|
|
1294
|
-
* just split them into seperate LineStrings (trk > trkseg, trk > trkseg)
|
|
1295
|
-
*
|
|
1296
|
-
* @link https://github.com/Raruto/leaflet-elevation/issues/56
|
|
1297
|
-
*/
|
|
1298
|
-
_prepareMultiLineStrings: function(geojson) {
|
|
1299
|
-
geojson.features.forEach(feauture => {
|
|
1300
|
-
if (feauture.geometry.type == "MultiLineString") {
|
|
1301
|
-
feauture.geometry.coordinates.forEach(coords => {
|
|
1302
|
-
geojson.features.push({
|
|
1303
|
-
geometry: { type: 'LineString', coordinates: coords },
|
|
1304
|
-
properties: feauture.properties,
|
|
1305
|
-
type: 'Feature'
|
|
1306
|
-
});
|
|
1307
|
-
});
|
|
1308
|
-
}
|
|
1309
|
-
});
|
|
1310
|
-
return geojson.features.filter(feauture => feauture.geometry.type != "MultiLineString");
|
|
1311
|
-
},
|
|
1312
|
-
|
|
1313
1254
|
/**
|
|
1314
1255
|
* Add chart profile to diagram
|
|
1315
1256
|
*/
|
|
@@ -1427,60 +1368,79 @@
|
|
|
1427
1368
|
return this._registerHandler(props.call(this));
|
|
1428
1369
|
}
|
|
1429
1370
|
|
|
1371
|
+
let {
|
|
1372
|
+
name,
|
|
1373
|
+
attr,
|
|
1374
|
+
required,
|
|
1375
|
+
skipNull,
|
|
1376
|
+
deltaMax,
|
|
1377
|
+
clampRange,
|
|
1378
|
+
decimals,
|
|
1379
|
+
meta,
|
|
1380
|
+
unit,
|
|
1381
|
+
coordinateProperties,
|
|
1382
|
+
coordPropsToMeta: coordPropsToMeta$1,
|
|
1383
|
+
pointToAttr,
|
|
1384
|
+
onPointAdded,
|
|
1385
|
+
stats,
|
|
1386
|
+
statsName,
|
|
1387
|
+
grid,
|
|
1388
|
+
scale,
|
|
1389
|
+
path,
|
|
1390
|
+
tooltip,
|
|
1391
|
+
summary
|
|
1392
|
+
} = props;
|
|
1393
|
+
|
|
1430
1394
|
// eg. "altitude" == true
|
|
1431
|
-
if (this.options[
|
|
1395
|
+
if (this.options[name] || required) {
|
|
1432
1396
|
|
|
1433
1397
|
this._registerDataAttribute({
|
|
1434
|
-
name
|
|
1435
|
-
attr
|
|
1436
|
-
skipNull
|
|
1437
|
-
deltaMax
|
|
1438
|
-
clampRange
|
|
1439
|
-
decimals
|
|
1440
|
-
coordPropsToMeta: coordPropsToMeta(
|
|
1441
|
-
pointToAttr
|
|
1442
|
-
onPointAdded
|
|
1443
|
-
stats
|
|
1444
|
-
statsName
|
|
1398
|
+
name,
|
|
1399
|
+
attr,
|
|
1400
|
+
skipNull,
|
|
1401
|
+
deltaMax,
|
|
1402
|
+
clampRange,
|
|
1403
|
+
decimals,
|
|
1404
|
+
coordPropsToMeta: coordPropsToMeta(coordinateProperties, meta || name, coordPropsToMeta$1),
|
|
1405
|
+
pointToAttr,
|
|
1406
|
+
onPointAdded,
|
|
1407
|
+
stats,
|
|
1408
|
+
statsName,
|
|
1445
1409
|
});
|
|
1446
1410
|
|
|
1447
|
-
if (
|
|
1448
|
-
|
|
1449
|
-
this._registerAxisGrid(props.grid);
|
|
1411
|
+
if (grid) {
|
|
1412
|
+
this._registerAxisGrid(L.extend({ name }, grid));
|
|
1450
1413
|
}
|
|
1451
1414
|
|
|
1452
|
-
if (this.options[
|
|
1453
|
-
if (
|
|
1454
|
-
|
|
1455
|
-
props.scale.label = props.scale.label || props.unit;
|
|
1456
|
-
this._registerAxisScale(props.scale);
|
|
1457
|
-
}
|
|
1458
|
-
if (props.path) {
|
|
1459
|
-
props.path.name = props.path.name || props.name;
|
|
1460
|
-
this._registerAreaPath(props.path);
|
|
1461
|
-
}
|
|
1415
|
+
if (this.options[name] !== "summary") {
|
|
1416
|
+
if (scale) this._registerAxisScale(L.extend({ name, label: unit }, scale));
|
|
1417
|
+
if (path) this._registerAreaPath(L.extend({ name }, path));
|
|
1462
1418
|
}
|
|
1463
1419
|
|
|
1464
|
-
if (props.tooltips) {
|
|
1465
|
-
each(props.tooltips, t => {
|
|
1466
|
-
if (t) {
|
|
1467
|
-
t.name = t.name || props.name;
|
|
1468
|
-
this._registerTooltip(t);
|
|
1469
|
-
}
|
|
1470
|
-
});
|
|
1471
|
-
} else if (props.tooltip) {
|
|
1472
|
-
props.tooltip.name = props.tooltip.name || props.name;
|
|
1473
|
-
this._registerTooltip(props.tooltip);
|
|
1420
|
+
if (tooltip || props.tooltips) {
|
|
1421
|
+
each([tooltip, ...(props.tooltips || [])], t => t && this._registerTooltip(L.extend({ name }, t)));
|
|
1474
1422
|
}
|
|
1475
1423
|
|
|
1476
|
-
if (
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
}
|
|
1480
|
-
this._registerSummary(props.summary);
|
|
1424
|
+
if (summary) {
|
|
1425
|
+
each(summary, (s, k) => summary[k] = L.extend({ unit }, s));
|
|
1426
|
+
this._registerSummary(summary);
|
|
1481
1427
|
}
|
|
1482
1428
|
}
|
|
1483
1429
|
},
|
|
1430
|
+
|
|
1431
|
+
_registerMarker({latlng, sym, content}) {
|
|
1432
|
+
let { wptIcons } = this.options;
|
|
1433
|
+
// generate and cache appropriate icon symbol
|
|
1434
|
+
if (!wptIcons.hasOwnProperty(sym)) {
|
|
1435
|
+
wptIcons[sym] = L.divIcon(L.extend({}, wptIcons[""].options, { html: '<i class="elevation-waypoint-icon ' + sym + '"></i>' } ));
|
|
1436
|
+
}
|
|
1437
|
+
let marker = L.marker(latlng, { icon: wptIcons[sym] });
|
|
1438
|
+
if (content) {
|
|
1439
|
+
marker.bindPopup(content, { className: 'elevation-popup', keepInView: true }).openPopup();
|
|
1440
|
+
marker.bindTooltip(content, { className: 'elevation-tooltip', direction: 'auto', sticky: true, opacity: 1 }).openTooltip();
|
|
1441
|
+
}
|
|
1442
|
+
return this._addMarker(marker)
|
|
1443
|
+
},
|
|
1484
1444
|
|
|
1485
1445
|
/**
|
|
1486
1446
|
* Add chart or marker tooltip info
|
|
@@ -1563,7 +1523,6 @@
|
|
|
1563
1523
|
_updateChart: function() {
|
|
1564
1524
|
if (this._chart && this._container) {
|
|
1565
1525
|
this.fire("elechart_axis");
|
|
1566
|
-
this.fire("elechart_area");
|
|
1567
1526
|
|
|
1568
1527
|
this._chart.update({ data: this._data, options: this.options });
|
|
1569
1528
|
|
|
@@ -1611,27 +1570,27 @@
|
|
|
1611
1570
|
* Update chart summary.
|
|
1612
1571
|
*/
|
|
1613
1572
|
_updateSummary: function() {
|
|
1614
|
-
if (
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
this.
|
|
1573
|
+
if (this._summary) {
|
|
1574
|
+
this._summary.reset();
|
|
1575
|
+
if (this.options.summary) {
|
|
1576
|
+
this.fire("elechart_summary");
|
|
1577
|
+
this._summary.update();
|
|
1578
|
+
}
|
|
1579
|
+
if (this.options.downloadLink && this._downloadURL) { // TODO: generate dynamically file content instead of using static file urls.
|
|
1580
|
+
this._summary._container.innerHTML += '<span class="download"><a href="#">' + L._('Download') + '</a></span>';
|
|
1581
|
+
select('.download a', this._summary._container).onclick = ({preventDefault}) => {
|
|
1582
|
+
preventDefault();
|
|
1583
|
+
let event = { downloadLink: this.options.downloadLink, confirm: saveFile.bind(this, this._downloadURL) };
|
|
1584
|
+
if (this.options.downloadLink == 'modal' && typeof CustomEvent === "function") {
|
|
1585
|
+
document.dispatchEvent(new CustomEvent("eletrack_download", { detail: event }));
|
|
1586
|
+
} else if (this.options.downloadLink == 'link' || this.options.downloadLink === true) {
|
|
1587
|
+
event.confirm();
|
|
1588
|
+
}
|
|
1589
|
+
this.fire('eletrack_download', event);
|
|
1590
|
+
};
|
|
1591
|
+
}
|
|
1621
1592
|
}
|
|
1622
|
-
|
|
1623
|
-
this._summary._container.innerHTML += '<span class="download"><a href="#">' + L._('Download') + '</a></span>';
|
|
1624
|
-
select('.download a', this._summary._container).onclick = ({preventDefault}) => {
|
|
1625
|
-
preventDefault();
|
|
1626
|
-
let event = { downloadLink: this.options.downloadLink, confirm: saveFile.bind(this, this._downloadURL) };
|
|
1627
|
-
if (this.options.downloadLink == 'modal' && typeof CustomEvent === "function") {
|
|
1628
|
-
document.dispatchEvent(new CustomEvent("eletrack_download", { detail: event }));
|
|
1629
|
-
} else if (this.options.downloadLink == 'link' || this.options.downloadLink === true) {
|
|
1630
|
-
event.confirm();
|
|
1631
|
-
}
|
|
1632
|
-
this.fire('eletrack_download', event);
|
|
1633
|
-
};
|
|
1634
|
-
} },
|
|
1593
|
+
},
|
|
1635
1594
|
|
|
1636
1595
|
|
|
1637
1596
|
/**
|