@raruto/leaflet-elevation 1.7.2 → 1.7.6
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 +9 -3
- package/dist/leaflet-elevation.js +273 -233
- package/dist/leaflet-elevation.js.map +1 -1
- package/dist/leaflet-elevation.min.js +3 -1
- package/dist/leaflet-elevation.min.js.map +1 -1
- package/libs/leaflet-gpxgroup.js +48 -39
- package/libs/leaflet-gpxgroup.min.js +14 -13
- package/package.json +1 -1
- package/src/acceleration.js +1 -1
- package/src/altitude.js +6 -0
- package/src/chart.js +3 -24
- package/src/components.js +36 -24
- package/src/control.js +10 -6
- package/src/distance.js +5 -0
- package/src/index.js +12 -1
- package/src/marker.js +3 -20
- package/src/options.js +2 -0
- package/src/slope.js +1 -1
- package/src/speed.js +2 -2
- package/src/time.js +9 -4
- package/src/utils.js +37 -25
package/src/utils.js
CHANGED
|
@@ -73,13 +73,13 @@ export function GeoJSONLoader(data, control) {
|
|
|
73
73
|
}
|
|
74
74
|
control = control || this;
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
let distanceMarkers = (
|
|
77
77
|
control.options.distanceMarkers === true
|
|
78
78
|
? { lazy: true }
|
|
79
79
|
: L.extend({ lazy: true }, control.options.distanceMarkers)
|
|
80
80
|
);
|
|
81
81
|
|
|
82
|
-
|
|
82
|
+
let { wptIcons, wptLabels } = control.options;
|
|
83
83
|
|
|
84
84
|
let layer = L.geoJson(data, {
|
|
85
85
|
distanceMarkers: distanceMarkers,
|
|
@@ -94,24 +94,36 @@ export function GeoJSONLoader(data, control) {
|
|
|
94
94
|
if (!control.options.waypoints) return;
|
|
95
95
|
|
|
96
96
|
let prop = feature.properties;
|
|
97
|
-
let desc = prop.desc
|
|
98
|
-
let name = prop.name
|
|
99
|
-
let sym = (prop.sym
|
|
100
|
-
|
|
101
|
-
//
|
|
102
|
-
if (
|
|
103
|
-
|
|
104
|
-
|
|
97
|
+
let desc = prop.desc ?? '';
|
|
98
|
+
let name = prop.name ?? '';
|
|
99
|
+
let sym = (prop.sym ?? name).replace(' ', '-').replace('"', '').replace("'", '').toLowerCase();
|
|
100
|
+
|
|
101
|
+
// Handle chart waypoints (dots)
|
|
102
|
+
if ([true, 'dots'].includes(control.options.waypoints)) {
|
|
103
|
+
control._registerCheckPoint({
|
|
104
|
+
latlng: latlng,
|
|
105
|
+
label: ([true, 'dots'].includes(wptLabels) ? name : '')
|
|
106
|
+
},
|
|
107
|
+
true
|
|
105
108
|
);
|
|
106
109
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
+
|
|
111
|
+
// Handle map waypoints (markers)
|
|
112
|
+
if ([true, 'markers'].includes(control.options.waypoints) && wptIcons != false) {
|
|
113
|
+
// generate and cache appropriate icon symbol
|
|
114
|
+
if (!wptIcons.hasOwnProperty(sym)) {
|
|
115
|
+
wptIcons[sym] = L.divIcon(
|
|
116
|
+
L.extend({}, wptIcons[""].options, { html: '<i class="elevation-waypoint-icon ' + sym + '"></i>' } )
|
|
117
|
+
);
|
|
118
|
+
}
|
|
119
|
+
let marker = L.marker(latlng, { icon: wptIcons[sym] });
|
|
120
|
+
if ([true, 'markers'].includes(wptLabels) && (name || desc)) {
|
|
121
|
+
marker.bindPopup("<b>" + name + "</b>" + (desc.length > 0 ? '<br>' + desc : '')).openPopup();
|
|
122
|
+
}
|
|
123
|
+
control._addMarker(marker);
|
|
124
|
+
control.fire('waypoint_added', { point: marker, element: latlng, properties: prop });
|
|
125
|
+
return marker;
|
|
110
126
|
}
|
|
111
|
-
control._addMarker(marker);
|
|
112
|
-
control._registerCheckPoint({latlng: latlng, label: name}, true);
|
|
113
|
-
control.fire('waypoint_added', { point: marker, element: latlng, properties: prop });
|
|
114
|
-
return marker;
|
|
115
127
|
},
|
|
116
128
|
onEachFeature: (feature, layer) => {
|
|
117
129
|
if (feature.geometry && feature.geometry.type == 'Point') return;
|
|
@@ -138,12 +150,12 @@ export function GeoJSONLoader(data, control) {
|
|
|
138
150
|
|
|
139
151
|
// Postpone adding the distance markers (lazy: true)
|
|
140
152
|
if(control.options.distanceMarkers && distanceMarkers.lazy) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
153
|
+
layer.on('add remove', (e) => {
|
|
154
|
+
let path = e.target;
|
|
155
|
+
if (L.DistanceMarkers && path instanceof L.Polyline) {
|
|
144
156
|
path[e.type + 'DistanceMarkers']();
|
|
145
|
-
|
|
146
|
-
|
|
157
|
+
}
|
|
158
|
+
});
|
|
147
159
|
}
|
|
148
160
|
|
|
149
161
|
control.track_info = L.extend({}, control.track_info, { type: "geojson", name: data.name });
|
|
@@ -318,8 +330,8 @@ export function toggleClass(targetNode, className, conditional) {
|
|
|
318
330
|
}
|
|
319
331
|
|
|
320
332
|
export function replaceClass(targetNode, removeClassName, addClassName) {
|
|
321
|
-
|
|
322
|
-
|
|
333
|
+
if (removeClassName) removeClass(targetNode, removeClassName);
|
|
334
|
+
if (addClassName) addClass(targetNode, addClassName);
|
|
323
335
|
}
|
|
324
336
|
|
|
325
337
|
export function style(targetNode, name, value) {
|
|
@@ -328,7 +340,7 @@ export function style(targetNode, name, value) {
|
|
|
328
340
|
}
|
|
329
341
|
|
|
330
342
|
export function toggleStyle(targetNode, name, value, conditional) {
|
|
331
|
-
|
|
343
|
+
return style(targetNode, name, conditional ? value : '');
|
|
332
344
|
}
|
|
333
345
|
|
|
334
346
|
export function toggleEvent(leafletElement, eventName, handler, conditional) {
|