@raruto/leaflet-elevation 2.2.1 → 2.2.4

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.
@@ -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 {
@@ -290,6 +290,9 @@
290
290
  L._ = L.i18n = (string, data) => string;
291
291
  }
292
292
 
293
+ // Prevent CORS issues for relative locations (dynamic import)
294
+ const baseURL = ((document.currentScript && document.currentScript.src) || (({ url: (typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('leaflet-elevation.js', document.baseURI).href)) }) && (typeof document === 'undefined' && typeof location === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('leaflet-elevation.js', document.baseURI).href)))).split("/").slice(0,-1).join("/") + '/';
295
+
293
296
  const Elevation = L.Control.Elevation = L.Control.extend({
294
297
 
295
298
  includes: L.Evented ? L.Evented.prototype : L.Mixin.Events,
@@ -307,6 +310,7 @@
307
310
  __LMARKER: '../src/components/marker.js',
308
311
  __LSUMMARY: '../src/components/summary.js',
309
312
  __modulesFolder: '../src/handlers/',
313
+ __btnIcon: '../images/elevation.svg',
310
314
 
311
315
  /*
312
316
  * Add data to the diagram either from GPX or GeoJSON and update the axis domain and data
@@ -314,10 +318,14 @@
314
318
  addData: function(d, layer) {
315
319
  this.import(this.__D3)
316
320
  .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 });
321
+ if (this._modulesLoaded) {
322
+ layer = layer ?? (d.on && d);
323
+ this._addData(d);
324
+ this._addLayer(layer);
325
+ this._fireEvt("eledata_added", { data: d, layer: layer, track_info: this.track_info });
326
+ } else {
327
+ this.once('modules_loaded', () => this.addData(d,layer));
328
+ }
321
329
  });
322
330
  },
323
331
 
@@ -494,7 +502,9 @@
494
502
  case this.__LGEOMUTIL: condition = typeof L.GeometryUtil !== 'object'; break;
495
503
  case this.__LALMOSTOVER: condition = typeof L.Handler.AlmostOver !== 'function'; break;
496
504
  case this.__LDISTANCEM: condition = typeof L.DistanceMarkers !== 'function'; break;
505
+ case this.__LHOTLINE: condition = typeof L.Hotline !== 'function'; break;
497
506
  }
507
+ src = (src.startsWith('../') || src.startsWith('./') ? baseURL : '') + src;
498
508
  return condition !== false ? import(src) : Promise.resolve();
499
509
  },
500
510
 
@@ -522,6 +532,8 @@
522
532
  this._initSummary(container);
523
533
  this._initMarker(map);
524
534
  this._initLayer(map);
535
+ this._modulesLoaded = true;
536
+ this.fire('modules_loaded');
525
537
  });
526
538
 
527
539
  this.fire('add');
@@ -590,7 +602,7 @@
590
602
  if (geom) {
591
603
  switch (geom.type) {
592
604
  case 'LineString': return this._addGeoJSONData(geom.coordinates, d.properties);
593
- case 'MultiLineString': return each(geom.coordinates, (coords, i) => this._addGeoJSONData(coords, d.properties, i));
605
+ case 'MultiLineString': return each(geom.coordinates, (coords, i) => this._addGeoJSONData(coords, d.properties, i));
594
606
  case 'Point':
595
607
  default: return console.warn('Unsopperted GeoJSON feature geometry type:' + geom.type);
596
608
  }
@@ -971,6 +983,7 @@
971
983
  on(link, 'click', L.DomEvent.stop);
972
984
  on(link, 'click', this._toggle, this);
973
985
  on(link, 'focus', this._toggle, this);
986
+ fetch(this.__btnIcon).then(r => r.ok && r.text().then(img => link.innerHTML = img));
974
987
  }
975
988
  },
976
989