@raruto/leaflet-elevation 2.4.0 → 2.5.1

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.
@@ -74,8 +74,8 @@
74
74
  ctx.moveTo(0, 0);
75
75
  let p = new Path2D(path.attr('d'));
76
76
 
77
- ctx.strokeStyle = path.attr('stroke');
78
- ctx.fillStyle = path.attr('fill');
77
+ ctx.strokeStyle = path.__strokeStyle || path.attr('stroke');
78
+ ctx.fillStyle = path.__fillStyle || path.attr('fill');
79
79
  ctx.lineWidth = 1.25;
80
80
  ctx.globalCompositeOperation = 'source-over';
81
81
 
@@ -206,7 +206,7 @@
206
206
  }
207
207
  }
208
208
 
209
- var _ = /*#__PURE__*/Object.freeze({
209
+ var _ = {
210
210
  __proto__: null,
211
211
  Colors: Colors,
212
212
  addClass: addClass,
@@ -244,7 +244,7 @@
244
244
  toggleStyle: toggleStyle,
245
245
  wrapDelta: wrapDelta,
246
246
  wrapNum: wrapNum
247
- });
247
+ };
248
248
 
249
249
  var Options = {
250
250
  autofitBounds: true,
@@ -346,7 +346,7 @@
346
346
  __mileFactor: 0.621371, // 1 km = (0.621371 mi)
347
347
  __footFactor: 3.28084, // 1 m = (3.28084 ft)
348
348
  __D3: 'https://unpkg.com/d3@7.8.4/dist/d3.min.js',
349
- __TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@5.6.0/dist/togeojson.umd.js',
349
+ __TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@5.6.2/dist/togeojson.umd.js',
350
350
  __LGEOMUTIL: 'https://unpkg.com/leaflet-geometryutil@0.10.1/src/leaflet.geometryutil.js',
351
351
  __LALMOSTOVER: 'https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js',
352
352
  __LHOTLINE: '../libs/leaflet-hotline.min.js',
@@ -546,6 +546,9 @@
546
546
  * Javascript scripts downloader (lazy loader)
547
547
  */
548
548
  import(src, condition) {
549
+ if (Array.isArray(src)) {
550
+ return Promise.all(src.map(m => this.import(m)));
551
+ }
549
552
  switch(src) {
550
553
  case this.__D3: condition = typeof d3 !== 'object'; break;
551
554
  case this.__TOGEOJSON: condition = typeof toGeoJSON !== 'object'; break;
@@ -733,38 +736,36 @@
733
736
  * Initialize "L.AlmostOver" integration
734
737
  */
735
738
  _initAlmostOverHandler(map, layer) {
736
- return (map && this.options.almostOver && !L.Browser.mobile) ? Promise.all([
737
- this.import(this.__LGEOMUTIL),
738
- this.import(this.__LALMOSTOVER)
739
- ]).then(() => {
740
- map.addHandler('almostOver', L.Handler.AlmostOver);
741
- if (L.GeometryUtil && map.almostOver && map.almostOver.enabled()) {
742
- map.almostOver.addLayer(layer);
743
- map
744
- .on('almost:move', this._onMouseMoveLayer, this)
745
- .on('almost:out', this._onMouseOut, this);
746
- this.once('eledata_clear', () => {
747
- map.almostOver.removeLayer(layer);
739
+ return (map && this.options.almostOver && !L.Browser.mobile) ? this.import([this.__LGEOMUTIL, this.__LALMOSTOVER])
740
+ .then(() => {
741
+ map.addHandler('almostOver', L.Handler.AlmostOver);
742
+ if (L.GeometryUtil && map.almostOver && map.almostOver.enabled()) {
743
+ map.almostOver.addLayer(layer);
748
744
  map
749
- .off('almost:move', this._onMouseMoveLayer, this)
750
- .off('almost:out', this._onMouseOut, this);
751
- });
752
- }
753
- }) : Promise.resolve();
745
+ .on('almost:move', this._onMouseMoveLayer, this)
746
+ .on('almost:out', this._onMouseOut, this);
747
+ this.once('eledata_clear', () => {
748
+ map.almostOver.removeLayer(layer);
749
+ map
750
+ .off('almost:move', this._onMouseMoveLayer, this)
751
+ .off('almost:out', this._onMouseOut, this);
752
+ });
753
+ }
754
+ }) : Promise.resolve();
754
755
  },
755
756
 
756
757
  /**
757
758
  * Initialize "L.DistanceMarkers" integration
758
759
  */
759
760
  _initDistanceMarkers() {
760
- return this.options.distanceMarkers ? Promise.all([this.import(this.__LGEOMUTIL), this.import(this.__LDISTANCEM)]) : Promise.resolve();
761
+ return this.options.distanceMarkers ? this.import([this.__LGEOMUTIL, this.__LDISTANCEM]) : Promise.resolve();
761
762
  },
762
763
 
763
764
  /**
764
765
  * Initialize "L.Control.EdgeScale" integration
765
766
  */
766
767
  _initEdgeScale(map) {
767
- return this.options.edgeScale ? Promise.all([this.import(this.__LEDGESCALE)])
768
+ return this.options.edgeScale ? this.import(this.__LEDGESCALE)
768
769
  .then(() => {
769
770
  map.edgeScaleControl = map.edgeScaleControl || L.control.edgeScale('boolean' !== typeof this.options.edgeScale ? this.options.edgeScale : {}).addTo(map);
770
771
  }) : Promise.resolve();
@@ -775,7 +776,7 @@
775
776
  return this.options.hotline ? this.import(this.__LHOTLINE)
776
777
  .then(() => {
777
778
  layer.eachLayer((trkseg) => {
778
- if(trkseg.feature.geometry.type != "Point") {
779
+ if (trkseg.feature.geometry.type != "Point") {
779
780
  let geo = L.geoJson(trkseg.toGeoJSON(), { coordsToLatLng: (coords) => L.latLng(coords[0], coords[1], coords[2] * (this.options.altitudeFactor || 1))});
780
781
  let line = L.hotline(geo.toGeoJSON().features[0].geometry.coordinates, {
781
782
  renderer: L.Hotline.renderer(),
@@ -950,10 +951,9 @@
950
951
  if (opts._maxWidth > clientWidth) opts.width = clientWidth - 30;
951
952
  }
952
953
 
953
- Promise.all([
954
- this.import(this.__D3),
955
- this.import(this.__LCHART)
956
- ]).then((m) => {
954
+ this
955
+ .import([this.__D3, this.__LCHART])
956
+ .then((m) => {
957
957
 
958
958
  let chart = this._chart = new (m[1] || Elevation).Chart(opts, this);
959
959
 
@@ -1021,13 +1021,11 @@
1021
1021
  if (this._renderer) this._renderer.remove();
1022
1022
  this._renderer = L.svg({ pane: "elevationPane" }).addTo(this._map); // default leaflet svg renderer
1023
1023
 
1024
- Promise.all([
1025
- this.import(this.__D3),
1026
- this.import(this.__LMARKER)
1027
- ]).then((m) => {
1028
- this._marker = new (m[1] || Elevation).Marker(this.options, this);
1029
- this.fire("elechart_marker");
1030
- });
1024
+ this.import([this.__D3, this.__LMARKER])
1025
+ .then((m) => {
1026
+ this._marker = new (m[1] || Elevation).Marker(this.options, this);
1027
+ this.fire("elechart_marker");
1028
+ });
1031
1029
  },
1032
1030
 
1033
1031
  /**
@@ -1161,7 +1159,7 @@
1161
1159
  },
1162
1160
 
1163
1161
  _onKeyDown({key}) {
1164
- if(!this.options.detached && key === "Escape"){
1162
+ if (!this.options.detached && key === "Escape"){
1165
1163
  this._collapse();
1166
1164
  } },
1167
1165