@raruto/leaflet-elevation 1.7.4 → 1.7.5
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 +1 -1
- package/dist/leaflet-elevation.js +9 -14
- 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.js +1 -1
- package/src/control.js +1 -1
- package/src/utils.js +36 -38
package/package.json
CHANGED
package/src/components.js
CHANGED
package/src/control.js
CHANGED
|
@@ -17,7 +17,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
|
|
|
17
17
|
__TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@4.3.0/dist/togeojson.umd.js',
|
|
18
18
|
__LGEOMUTIL: 'https://unpkg.com/leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js',
|
|
19
19
|
__LALMOSTOVER: 'https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js',
|
|
20
|
-
__LDISTANCEM: 'https://unpkg.com/@raruto/leaflet-elevation@1.7.
|
|
20
|
+
__LDISTANCEM: 'https://unpkg.com/@raruto/leaflet-elevation@1.7.5/libs/leaflet-distance-marker.min.js',
|
|
21
21
|
|
|
22
22
|
/*
|
|
23
23
|
* Add data to the diagram either from GPX or GeoJSON and update the axis domain and data
|
package/src/utils.js
CHANGED
|
@@ -73,14 +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
|
-
|
|
83
|
-
let wptLabels = control.options.wptLabels;
|
|
82
|
+
let { wptIcons, wptLabels } = control.options;
|
|
84
83
|
|
|
85
84
|
let layer = L.geoJson(data, {
|
|
86
85
|
distanceMarkers: distanceMarkers,
|
|
@@ -99,33 +98,32 @@ export function GeoJSONLoader(data, control) {
|
|
|
99
98
|
let name = prop.name ?? '';
|
|
100
99
|
let sym = (prop.sym ?? name).replace(' ', '-').replace('"', '').replace("'", '').toLowerCase();
|
|
101
100
|
|
|
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
|
-
}
|
|
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
|
|
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;
|
|
126
|
+
}
|
|
129
127
|
},
|
|
130
128
|
onEachFeature: (feature, layer) => {
|
|
131
129
|
if (feature.geometry && feature.geometry.type == 'Point') return;
|
|
@@ -152,12 +150,12 @@ export function GeoJSONLoader(data, control) {
|
|
|
152
150
|
|
|
153
151
|
// Postpone adding the distance markers (lazy: true)
|
|
154
152
|
if(control.options.distanceMarkers && distanceMarkers.lazy) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
153
|
+
layer.on('add remove', (e) => {
|
|
154
|
+
let path = e.target;
|
|
155
|
+
if (L.DistanceMarkers && path instanceof L.Polyline) {
|
|
158
156
|
path[e.type + 'DistanceMarkers']();
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
}
|
|
158
|
+
});
|
|
161
159
|
}
|
|
162
160
|
|
|
163
161
|
control.track_info = L.extend({}, control.track_info, { type: "geojson", name: data.name });
|
|
@@ -332,8 +330,8 @@ export function toggleClass(targetNode, className, conditional) {
|
|
|
332
330
|
}
|
|
333
331
|
|
|
334
332
|
export function replaceClass(targetNode, removeClassName, addClassName) {
|
|
335
|
-
|
|
336
|
-
|
|
333
|
+
if (removeClassName) removeClass(targetNode, removeClassName);
|
|
334
|
+
if (addClassName) addClass(targetNode, addClassName);
|
|
337
335
|
}
|
|
338
336
|
|
|
339
337
|
export function style(targetNode, name, value) {
|
|
@@ -342,7 +340,7 @@ export function style(targetNode, name, value) {
|
|
|
342
340
|
}
|
|
343
341
|
|
|
344
342
|
export function toggleStyle(targetNode, name, value, conditional) {
|
|
345
|
-
|
|
343
|
+
return style(targetNode, name, conditional ? value : '');
|
|
346
344
|
}
|
|
347
345
|
|
|
348
346
|
export function toggleEvent(leafletElement, eventName, handler, conditional) {
|