@raruto/leaflet-elevation 2.0.5 → 2.0.6

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.
@@ -261,6 +261,7 @@
261
261
  imperial: false,
262
262
  legend: true,
263
263
  handlers: [],
264
+ hotline: 'elevation',
264
265
  marker: 'elevation-line',
265
266
  markerIcon: L.divIcon({
266
267
  className: 'elevation-position-marker',
@@ -337,6 +338,7 @@
337
338
  __TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@4.6.0/dist/togeojson.umd.js',
338
339
  __LGEOMUTIL: 'https://unpkg.com/leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js',
339
340
  __LALMOSTOVER: 'https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js',
341
+ __LHOTLINE: '../libs/leaflet-hotline.min.js',
340
342
  __LDISTANCEM: '../libs/leaflet-distance-marker.min.js',
341
343
  __LCHART: '../src/components/chart.js',
342
344
  __LMARKER: '../src/components/marker.js',
@@ -739,6 +741,37 @@
739
741
  }
740
742
  },
741
743
 
744
+ _initHotLine: function(map, layer) {
745
+ if (this.options.hotline) {
746
+ let prop = typeof this.options.hotline == 'string' ? this.options.hotline : 'elevation';
747
+ this.import(this.__LHOTLINE)
748
+ .then(() => {
749
+ this._hotline = L.featureGroup();
750
+ layer.setStyle({opacity: 0});
751
+ layer.eachLayer((trkseg) => {
752
+ if(trkseg.feature.geometry.type != "Point") {
753
+ let geo = L.geoJson(trkseg.toGeoJSON(), { coordsToLatLng: (coords) => L.latLng(coords[0], coords[1], coords[2])});
754
+ L.hotline(geo.toGeoJSON().features[0].geometry.coordinates, {
755
+ min: isFinite(this.track_info[prop + '_min']) ? this.track_info[prop + '_min'] : 0,
756
+ max: isFinite(this.track_info[prop + '_max']) ? this.track_info[prop + '_max'] : 1,
757
+ palette: {
758
+ 0.0: '#008800',
759
+ 0.5: '#ffff00',
760
+ 1.0: '#ff0000'
761
+ },
762
+ weight: 5,
763
+ outlineColor: '#000000',
764
+ outlineWidth: 1
765
+ }).addTo(this._hotline);
766
+ }
767
+ });
768
+ if (map) {
769
+ this._hotline.addTo(map);
770
+ }
771
+ });
772
+ }
773
+ },
774
+
742
775
  /**
743
776
  * Initialize "L.AlmostOver" and "L.DistanceMarkers"
744
777
  */
@@ -752,6 +785,7 @@
752
785
  control._circleMarkers.addTo(map);
753
786
  map.once('layeradd', (e) => control.options.autofitBounds && control.fitBounds(layer.getBounds()));
754
787
  if (!L.Browser.mobile) {
788
+ control._initHotLine(map, layer);
755
789
  control._initAlmostOverHandler(map, layer);
756
790
  control._initDistanceMarkers(map, layer);
757
791
  } else if (control.options.polyline) {
@@ -767,6 +801,7 @@
767
801
  */
768
802
  _collapse: function() {
769
803
  replaceClass(this._container, 'elevation-expanded', 'elevation-collapsed');
804
+ if (this._map) this._map.invalidateSize();
770
805
  },
771
806
 
772
807
  /*
@@ -774,6 +809,7 @@
774
809
  */
775
810
  _expand: function() {
776
811
  replaceClass(this._container, 'elevation-collapsed', 'elevation-expanded');
812
+ if (this._map) this._map.invalidateSize();
777
813
  },
778
814
 
779
815
  /**