@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raruto/leaflet-elevation",
3
- "version": "1.7.4",
3
+ "version": "1.7.5",
4
4
  "description": "A Leaflet plugin that allows to add elevation profiles using d3js",
5
5
  "main": "dist/leaflet-elevation.min.js",
6
6
  "module": "src/index.js",
package/src/components.js CHANGED
@@ -161,7 +161,7 @@ export const HeightFocusMarker = ({
161
161
 
162
162
  export const LegendItem = ({
163
163
  name,
164
- label,
164
+ label,
165
165
  width,
166
166
  height,
167
167
  margins = {},
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.3/libs/leaflet-distance-marker.min.js',
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
- let distanceMarkers = (
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
- let wptIcons = control.options.wptIcons;
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
- // Handle waypoint lables (markers and dots)
103
- if (!wptLabels) {
104
- name = '';
105
- desc = '';
106
- }
107
-
108
- // Handle chart waypoints (dots)
109
- if ([true, "dots"].includes(control.options.waypoints)) {
110
- control._registerCheckPoint({latlng: latlng, label: name}, true);
111
- }
112
-
113
- // Handle map waypoints (markers)
114
- if ([true, "markers"].includes(control.options.waypoints) && wptIcons != false) {
115
- // generate and cache appropriate icon symbol
116
- if (!wptIcons.hasOwnProperty(sym)) {
117
- wptIcons[sym] = L.divIcon(
118
- L.extend({}, wptIcons[""].options, { html: '<i class="elevation-waypoint-icon ' + sym + '"></i>' } )
119
- );
120
- }
121
- let marker = L.marker(latlng, { icon: wptIcons[sym] });
122
- if (name || desc) {
123
- marker.bindPopup("<b>" + name + "</b>" + (desc.length > 0 ? '<br>' + desc : '')).openPopup();
124
- }
125
- control._addMarker(marker);
126
- control.fire('waypoint_added', { point: marker, element: latlng, properties: prop });
127
- return marker;
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
- layer.on('add remove', (e) => {
156
- let path = e.target;
157
- if (L.DistanceMarkers && path instanceof L.Polyline) {
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
- if (removeClassName) removeClass(targetNode, removeClassName);
336
- if (addClassName) addClass(targetNode, addClassName);
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
- return style(targetNode, name, conditional ? value : '');
343
+ return style(targetNode, name, conditional ? value : '');
346
344
  }
347
345
 
348
346
  export function toggleEvent(leafletElement, eventName, handler, conditional) {