@raruto/leaflet-elevation 1.8.9 → 1.9.2

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.8.9",
3
+ "version": "1.9.2",
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/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.5.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.8.9/libs/leaflet-distance-marker.min.js',
20
+ __LDISTANCEM: 'https://unpkg.com/@raruto/leaflet-elevation@1.9.2/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
@@ -345,12 +345,16 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
345
345
 
346
346
  // "alt" property is generated inside "leaflet"
347
347
  if ("alt" in point) point.meta.ele = point.alt;
348
-
348
+
349
349
  // "coordinateProperties" property is generated inside "@tmcw/toGeoJSON"
350
- if (properties && properties.coordinateProperties) {
351
- let props = properties.coordinateProperties;
352
- if("times" in props) point.meta.time = new Date(Date.parse(props.times[i]));
353
- if("heart" in props) point.meta.hr = parseInt(props.heart[i]);
350
+ let props = (properties && properties.coordinateProperties) || properties;
351
+ if (props) {
352
+ if("coordTimes" in props) point.meta.time = new Date(Date.parse(props.coordTimes[i]));
353
+ else if("times" in props) point.meta.time = new Date(Date.parse(props.times[i]));
354
+ else if("time" in props) point.meta.time = new Date(Date.parse((typeof props.time === 'object' ? props.time[i] : props.time)));
355
+ if ("heartRates" in props) point.meta.hr = parseInt(props.heartRates[i]);
356
+ else if("heartRate" in props) point.meta.hr = parseInt((typeof props.heartRate === 'object' ? props.heartRate[i] : props.heartRate));
357
+ else if("heart" in props) point.meta.hr = parseInt((typeof props.heart === 'object' ? props.heart[i] : props.heart));
354
358
  // TODO: ask to "@tmcw/toGeoJSON" for "cadence" and "temperature" implementation
355
359
  }
356
360
 
@@ -396,17 +400,6 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
396
400
  if (marker) this._markers.addLayer(marker)
397
401
  },
398
402
 
399
- _bindPopup: function(marker) {
400
- let popup = marker._popup;
401
- if (popup) {
402
- popup.options.className = 'elevation-popup';
403
- if (popup._content) {
404
- popup._content = decodeURI(popup._content);
405
- popup.bindTooltip(popup._content, { direction: 'auto', sticky: true, opacity: 1, className: 'elevation-tooltip' }).openTooltip();
406
- }
407
- }
408
- },
409
-
410
403
  /**
411
404
  * Initialize "L.AlmostOver" integration
412
405
  */
@@ -750,10 +743,11 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
750
743
  }
751
744
  let marker = L.marker(latlng, { icon: wptIcons[sym] });
752
745
  if ([true, 'markers'].includes(wptLabels) && (name || desc)) {
753
- marker.bindPopup("<b>" + name + "</b>" + (desc.length > 0 ? '<br>' + desc : '')).openPopup();
746
+ let content = decodeURI("<b>" + name + "</b>" + (desc.length > 0 ? '<br>' + desc : ''));
747
+ marker.bindPopup(content, { className: 'elevation-popup', keepInView: true }).openPopup();
748
+ marker.bindTooltip(content, { className: 'elevation-tooltip', direction: 'auto', sticky: true, opacity: 1 }).openTooltip();
754
749
  }
755
750
  control._addMarker(marker);
756
- control._bindPopup(marker);
757
751
  control.fire('waypoint_added', { point: marker, element: latlng, properties: prop });
758
752
  return marker;
759
753
  }
@@ -1143,12 +1137,13 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
1143
1137
  this._summary._container.innerHTML += '<span class="download"><a href="#">' + L._('Download') + '</a></span>'
1144
1138
  _.select('.download a', this._summary._container).onclick = (e) => {
1145
1139
  e.preventDefault();
1146
- if (e.downloadLink == 'modal' && typeof CustomEvent === "function") {
1147
- document.dispatchEvent(new CustomEvent("eletrack_download", { detail: e }));
1148
- } else if (e.downloadLink == 'link' || e.downloadLink === true) {
1149
- e.confirm();
1140
+ let event = { downloadLink: this.options.downloadLink, confirm: _.saveFile.bind(this, this._downloadURL) };
1141
+ if (this.options.downloadLink == 'modal' && typeof CustomEvent === "function") {
1142
+ document.dispatchEvent(new CustomEvent("eletrack_download", { detail: event }));
1143
+ } else if (this.options.downloadLink == 'link' || this.options.downloadLink === true) {
1144
+ event.confirm();
1150
1145
  }
1151
- this._fireEvt('eletrack_download', { downloadLink: this.options.downloadLink, confirm: _.saveFile.bind(this, this._downloadURL) });
1146
+ this._fireEvt('eletrack_download', event);
1152
1147
  };
1153
1148
  };
1154
1149
  },
package/src/options.js CHANGED
@@ -69,7 +69,7 @@ export var Options = {
69
69
  wptIcons: {
70
70
  '': L.divIcon({
71
71
  className: 'elevation-waypoint-marker',
72
- html: '<i class="elevation-waypoint-icon"></i>',
72
+ html: '<i class="elevation-waypoint-icon default"></i>',
73
73
  iconSize: [30, 30],
74
74
  iconAnchor: [8, 30],
75
75
  }),