@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/README.md CHANGED
@@ -63,7 +63,7 @@ _For a working example see one of the following demos:_
63
63
 
64
64
  <!-- leaflet-ui -->
65
65
  <script src="https://unpkg.com/leaflet@1.7.1/dist/leaflet.js"></script>
66
- <script src="https://unpkg.com/leaflet-ui@0.5.4/dist/leaflet-ui.js"></script>
66
+ <script src="https://unpkg.com/leaflet-ui@0.5.5/dist/leaflet-ui.js"></script>
67
67
 
68
68
  <!-- leaflet-elevation -->
69
69
  <link rel="stylesheet" href="https://unpkg.com/@raruto/leaflet-elevation/dist/leaflet-elevation.css" />
@@ -196,7 +196,7 @@ git clone git@github.com:Raruto/leaflet-elevation.git
196
196
  cd ./leaflet-elevation
197
197
 
198
198
  npm i # install dependencies
199
- npm run dev # auto-generate "dist" files
199
+ npm run watch # auto-generate "dist" files
200
200
  npm run build # generate "dist" files (once)
201
201
  npm run test # test "spec" files (once)
202
202
  ```
@@ -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
  }
@@ -271,8 +270,8 @@
271
270
  --ele-area: #9CC222;
272
271
  --ele-grid: #CCC;
273
272
  --ele-brush: rgba(99, 126, 11, 0.4);
274
- --ele-icon: url(../images/elevation-lime.svg);
275
273
  --ele-poly: #566B13;
274
+ --ele-line: #70ab00;
276
275
  }
277
276
 
278
277
  /* STEELBLUE THEME //////////////////////////////////////////////// */
@@ -281,7 +280,7 @@
281
280
  --ele-axis: #0D1821;
282
281
  --ele-area: #4682B4;
283
282
  --ele-brush: rgba(23, 74, 117, 0.4);
284
- --ele-icon: url(../images/elevation-steelblue.svg);
283
+ --ele-line: #174A75;
285
284
  }
286
285
 
287
286
  /* PURPLE THEME /////////////////////////////////////////////////// */
@@ -290,7 +289,7 @@
290
289
  --ele-bg: rgba(115, 44, 123, 0.2);
291
290
  --ele-area: #732C7B;
292
291
  --ele-brush: rgba(74, 14, 80, 0.4);
293
- --ele-icon: url(../images/elevation-purple.svg);
292
+ --ele-line: #732c7b;
294
293
  }
295
294
 
296
295
  /* YELLOW THEME /////////////////////////////////////////////////// */
@@ -319,6 +318,7 @@
319
318
  --ele-alpha: 0.45;
320
319
  --ele-stroke: #4682B4;
321
320
  --ele-circle: #fff;
321
+ --ele-line: #000;
322
322
  }
323
323
 
324
324
  .elevation-detached.lightblue-theme .area {
@@ -307,6 +307,7 @@
307
307
  __LMARKER: '../src/components/marker.js',
308
308
  __LSUMMARY: '../src/components/summary.js',
309
309
  __modulesFolder: '../src/handlers/',
310
+ __btnIcon: '../images/elevation.svg',
310
311
 
311
312
  /*
312
313
  * Add data to the diagram either from GPX or GeoJSON and update the axis domain and data
@@ -314,10 +315,14 @@
314
315
  addData: function(d, layer) {
315
316
  this.import(this.__D3)
316
317
  .then(() => {
317
- layer = layer ?? (d.on && d);
318
- this._addData(d);
319
- this._addLayer(layer);
320
- this._fireEvt("eledata_added", { data: d, layer: layer, track_info: this.track_info });
318
+ if (this._modulesLoaded) {
319
+ layer = layer ?? (d.on && d);
320
+ this._addData(d);
321
+ this._addLayer(layer);
322
+ this._fireEvt("eledata_added", { data: d, layer: layer, track_info: this.track_info });
323
+ } else {
324
+ this.once('modules_loaded', () => this.addData(d,layer));
325
+ }
321
326
  });
322
327
  },
323
328
 
@@ -522,6 +527,8 @@
522
527
  this._initSummary(container);
523
528
  this._initMarker(map);
524
529
  this._initLayer(map);
530
+ this._modulesLoaded = true;
531
+ this.fire('modules_loaded');
525
532
  });
526
533
 
527
534
  this.fire('add');
@@ -590,7 +597,7 @@
590
597
  if (geom) {
591
598
  switch (geom.type) {
592
599
  case 'LineString': return this._addGeoJSONData(geom.coordinates, d.properties);
593
- case 'MultiLineString': return each(geom.coordinates, (coords, i) => this._addGeoJSONData(coords, d.properties, i));
600
+ case 'MultiLineString': return each(geom.coordinates, (coords, i) => this._addGeoJSONData(coords, d.properties, i));
594
601
  case 'Point':
595
602
  default: return console.warn('Unsopperted GeoJSON feature geometry type:' + geom.type);
596
603
  }
@@ -971,6 +978,7 @@
971
978
  on(link, 'click', L.DomEvent.stop);
972
979
  on(link, 'click', this._toggle, this);
973
980
  on(link, 'focus', this._toggle, this);
981
+ fetch(this.__btnIcon).then(r => r.ok && r.text().then(img => link.innerHTML = img));
974
982
  }
975
983
  },
976
984
 
@@ -1302,7 +1310,7 @@
1302
1310
  if (props.stats) {
1303
1311
  for (const key in props.stats) {
1304
1312
  let sname = (props.statsName || attr) + (key != '' ? '_' : '');
1305
- this.track_info[sname + key] = props.stats[key].call(this, curr[attr], this.track_info[sname + key], index);
1313
+ this.track_info[sname + key] = props.stats[key].call(this, curr[attr], this.track_info[sname + key], this._data.length);
1306
1314
  }
1307
1315
  }
1308
1316