@raruto/leaflet-elevation 2.2.0 → 2.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raruto/leaflet-elevation",
3
- "version": "2.2.0",
3
+ "version": "2.2.3",
4
4
  "description": "A Leaflet plugin that allows to add elevation profiles using d3js",
5
5
  "type": "module",
6
6
  "main": "dist/leaflet-elevation.min.js",
@@ -23,9 +23,11 @@
23
23
  "javascript",
24
24
  "elevation",
25
25
  "highchart",
26
+ "kml",
26
27
  "altitude",
27
28
  "gpx",
28
- "gps-visualizer"
29
+ "gps-visualizer",
30
+ "tcx"
29
31
  ],
30
32
  "author": {
31
33
  "name": "Felix “MrMufflon” Bache",
package/src/control.js CHANGED
@@ -23,6 +23,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
23
23
  __LMARKER: '../src/components/marker.js',
24
24
  __LSUMMARY: '../src/components/summary.js',
25
25
  __modulesFolder: '../src/handlers/',
26
+ __btnIcon: '../images/elevation.svg',
26
27
 
27
28
  /*
28
29
  * Add data to the diagram either from GPX or GeoJSON and update the axis domain and data
@@ -30,10 +31,14 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
30
31
  addData: function(d, layer) {
31
32
  this.import(this.__D3)
32
33
  .then(() => {
33
- layer = layer ?? (d.on && d);
34
- this._addData(d);
35
- this._addLayer(layer);
36
- this._fireEvt("eledata_added", { data: d, layer: layer, track_info: this.track_info });
34
+ if (this._modulesLoaded) {
35
+ layer = layer ?? (d.on && d);
36
+ this._addData(d);
37
+ this._addLayer(layer);
38
+ this._fireEvt("eledata_added", { data: d, layer: layer, track_info: this.track_info });
39
+ } else {
40
+ this.once('modules_loaded', () => this.addData(d,layer));
41
+ }
37
42
  });
38
43
  },
39
44
 
@@ -238,6 +243,8 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
238
243
  this._initSummary(container);
239
244
  this._initMarker(map);
240
245
  this._initLayer(map);
246
+ this._modulesLoaded = true;
247
+ this.fire('modules_loaded');
241
248
  });
242
249
 
243
250
  this.fire('add');
@@ -306,7 +313,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
306
313
  if (geom) {
307
314
  switch (geom.type) {
308
315
  case 'LineString': return this._addGeoJSONData(geom.coordinates, d.properties);
309
- case 'MultiLineString': return _.each(geom.coordinates, (coords, i) => this._addGeoJSONData(coords, d.properties, i));
316
+ case 'MultiLineString': return _.each(geom.coordinates, (coords, i) => this._addGeoJSONData(coords, d.properties, i));
310
317
  case 'Point':
311
318
  default: return console.warn('Unsopperted GeoJSON feature geometry type:' + geom.type);
312
319
  }
@@ -687,6 +694,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
687
694
  _.on(link, 'click', L.DomEvent.stop);
688
695
  _.on(link, 'click', this._toggle, this);
689
696
  _.on(link, 'focus', this._toggle, this);
697
+ fetch(this.__btnIcon).then(r => r.ok && r.text().then(img => link.innerHTML = img));
690
698
  }
691
699
  },
692
700
 
@@ -1019,7 +1027,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
1019
1027
  if (props.stats) {
1020
1028
  for (const key in props.stats) {
1021
1029
  let sname = (props.statsName || attr) + (key != '' ? '_' : '');
1022
- this.track_info[sname + key] = props.stats[key].call(this, curr[attr], this.track_info[sname + key], index);
1030
+ this.track_info[sname + key] = props.stats[key].call(this, curr[attr], this.track_info[sname + key], this._data.length);
1023
1031
  }
1024
1032
  }
1025
1033
 
package/src/index.css CHANGED
@@ -146,7 +146,6 @@
146
146
  }
147
147
 
148
148
  .elevation-toggle-icon {
149
- background: var(--ele-toggle-bg, var(--ele-icon, url(../images/elevation-lime.svg)) no-repeat center center);
150
149
  background-color: #fff;
151
150
  right: 5px;
152
151
  top: 5px;
@@ -246,7 +245,7 @@
246
245
 
247
246
  .elevation-expanded {
248
247
  --ele-close-btn: inline-block;
249
- --ele-toggle-bg: transparent;
248
+ --ele-toggle-bg: none;
250
249
  --ele-toggle-pos: absolute;
251
250
  --ele-toggle-size: 20px;
252
251
  }
@@ -270,8 +269,8 @@
270
269
  --ele-area: #9CC222;
271
270
  --ele-grid: #CCC;
272
271
  --ele-brush: rgba(99, 126, 11, 0.4);
273
- --ele-icon: url(../images/elevation-lime.svg);
274
272
  --ele-poly: #566B13;
273
+ --ele-line: #70ab00;
275
274
  }
276
275
 
277
276
  /* STEELBLUE THEME //////////////////////////////////////////////// */
@@ -279,7 +278,7 @@
279
278
  --ele-axis: #0D1821;
280
279
  --ele-area: #4682B4;
281
280
  --ele-brush: rgba(23, 74, 117, 0.4);
282
- --ele-icon: url(../images/elevation-steelblue.svg);
281
+ --ele-line: #174A75;
283
282
  }
284
283
 
285
284
  /* PURPLE THEME /////////////////////////////////////////////////// */
@@ -287,7 +286,7 @@
287
286
  --ele-bg: rgba(115, 44, 123, 0.2);
288
287
  --ele-area: #732C7B;
289
288
  --ele-brush: rgba(74, 14, 80, 0.4);
290
- --ele-icon: url(../images/elevation-purple.svg);
289
+ --ele-line: #732c7b;
291
290
  }
292
291
 
293
292
  /* YELLOW THEME /////////////////////////////////////////////////// */
@@ -312,6 +311,7 @@
312
311
  --ele-alpha: 0.45;
313
312
  --ele-stroke: #4682B4;
314
313
  --ele-circle: #fff;
314
+ --ele-line: #000;
315
315
  }
316
316
 
317
317
  .elevation-detached.lightblue-theme .area {
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 26 26"><defs/><path fill="#addb55" fill-opacity=".8" d="M23.1 20.8l-4.2-8-3.9-.2-2.7 1.8-2.4-5.5-5.2 6.2v5.7" opacity=".9"/><path fill="none" stroke="#70ab00" stroke-width="1.5" d="M4.7 14.8h1.1l4.3-6.2 2.5 5.6 2.5-2.3 3.7.2 4 8.3v.4"/><path fill="none" stroke="#737373" stroke-linecap="square" d="M3.4 5v19.8M24.7 22.4H.9"/></svg>
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 26 26"><defs/><path fill="#b659c1" fill-opacity=".8" d="M23.1 20.8l-4.2-8-3.9-.2-2.7 1.8-2.4-5.5-5.2 6.2v5.7" opacity=".9"/><path fill="none" stroke="#732c7b" stroke-width="1.5" d="M4.7 14.8h1.1l4.3-6.2 2.5 5.6 2.5-2.3 3.7.2 4 8.3v.4"/><path fill="none" stroke="#737373" stroke-linecap="square" d="M3.4 5v19.8M24.7 22.4H.9"/></svg>
@@ -1 +0,0 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" width="26" height="26" viewBox="0 0 26 26"><defs/><path fill="#4682b4" fill-opacity=".8" d="M23.1 20.8l-4.2-8-3.9-.2-2.7 1.8-2.4-5.5-5.2 6.2v5.7" opacity=".9"/><path fill="none" stroke="#174a75" stroke-width="1.5" d="M4.7 14.8h1.1l4.3-6.2 2.5 5.6 2.5-2.3 3.7.2 4 8.3v.4"/><path fill="none" stroke="#737373" stroke-linecap="square" d="M3.4 5v19.8M24.7 22.4H.9"/></svg>