@raruto/leaflet-elevation 2.0.4 → 2.0.7
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/dist/leaflet-elevation.js +42 -2
- package/dist/leaflet-elevation.js.map +1 -1
- package/dist/leaflet-elevation.min.js +1 -1
- package/dist/leaflet-elevation.min.js.map +1 -1
- package/libs/leaflet-hotline.js +457 -0
- package/libs/leaflet-hotline.min.js +1 -0
- package/package.json +1 -1
- package/src/control.js +41 -2
- package/src/options.js +1 -0
|
@@ -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,41 @@
|
|
|
739
741
|
}
|
|
740
742
|
},
|
|
741
743
|
|
|
744
|
+
_initHotLine: function(map, layer) {
|
|
745
|
+
this._hotline = L.featureGroup();
|
|
746
|
+
if (this.options.hotline) {
|
|
747
|
+
layer.on('add', () => {
|
|
748
|
+
this._hotline.eachLayer(line => {
|
|
749
|
+
this._hotline.addTo(layer._map);
|
|
750
|
+
if (line._renderer)
|
|
751
|
+
line._renderer._container.parentElement.insertBefore(line._renderer._container, line._renderer._container.parentElement.firstChild);
|
|
752
|
+
});
|
|
753
|
+
});
|
|
754
|
+
let prop = typeof this.options.hotline == 'string' ? this.options.hotline : 'elevation';
|
|
755
|
+
this.import(this.__LHOTLINE)
|
|
756
|
+
.then(() => {
|
|
757
|
+
layer.setStyle({opacity: 0});
|
|
758
|
+
layer.eachLayer((trkseg) => {
|
|
759
|
+
if(trkseg.feature.geometry.type != "Point") {
|
|
760
|
+
let geo = L.geoJson(trkseg.toGeoJSON(), { coordsToLatLng: (coords) => L.latLng(coords[0], coords[1], coords[2])});
|
|
761
|
+
L.hotline(geo.toGeoJSON().features[0].geometry.coordinates, {
|
|
762
|
+
min: isFinite(this.track_info[prop + '_min']) ? this.track_info[prop + '_min'] : 0,
|
|
763
|
+
max: isFinite(this.track_info[prop + '_max']) ? this.track_info[prop + '_max'] : 1,
|
|
764
|
+
palette: {
|
|
765
|
+
0.0: '#008800',
|
|
766
|
+
0.5: '#ffff00',
|
|
767
|
+
1.0: '#ff0000'
|
|
768
|
+
},
|
|
769
|
+
weight: 5,
|
|
770
|
+
outlineColor: '#000000',
|
|
771
|
+
outlineWidth: 1
|
|
772
|
+
}).addTo(this._hotline);
|
|
773
|
+
}
|
|
774
|
+
});
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
},
|
|
778
|
+
|
|
742
779
|
/**
|
|
743
780
|
* Initialize "L.AlmostOver" and "L.DistanceMarkers"
|
|
744
781
|
*/
|
|
@@ -752,6 +789,7 @@
|
|
|
752
789
|
control._circleMarkers.addTo(map);
|
|
753
790
|
map.once('layeradd', (e) => control.options.autofitBounds && control.fitBounds(layer.getBounds()));
|
|
754
791
|
if (!L.Browser.mobile) {
|
|
792
|
+
control._initHotLine(map, layer);
|
|
755
793
|
control._initAlmostOverHandler(map, layer);
|
|
756
794
|
control._initDistanceMarkers(map, layer);
|
|
757
795
|
} else if (control.options.polyline) {
|
|
@@ -767,6 +805,7 @@
|
|
|
767
805
|
*/
|
|
768
806
|
_collapse: function() {
|
|
769
807
|
replaceClass(this._container, 'elevation-expanded', 'elevation-collapsed');
|
|
808
|
+
if (this._map) this._map.invalidateSize();
|
|
770
809
|
},
|
|
771
810
|
|
|
772
811
|
/*
|
|
@@ -774,6 +813,7 @@
|
|
|
774
813
|
*/
|
|
775
814
|
_expand: function() {
|
|
776
815
|
replaceClass(this._container, 'elevation-collapsed', 'elevation-expanded');
|
|
816
|
+
if (this._map) this._map.invalidateSize();
|
|
777
817
|
},
|
|
778
818
|
|
|
779
819
|
/**
|
|
@@ -1562,8 +1602,8 @@
|
|
|
1562
1602
|
}
|
|
1563
1603
|
if (this.options.downloadLink && this._downloadURL) { // TODO: generate dynamically file content instead of using static file urls.
|
|
1564
1604
|
this._summary._container.innerHTML += '<span class="download"><a href="#">' + L._('Download') + '</a></span>';
|
|
1565
|
-
select('.download a', this._summary._container).onclick = (
|
|
1566
|
-
preventDefault();
|
|
1605
|
+
select('.download a', this._summary._container).onclick = (e) => {
|
|
1606
|
+
e.preventDefault();
|
|
1567
1607
|
let event = { downloadLink: this.options.downloadLink, confirm: saveFile.bind(this, this._downloadURL) };
|
|
1568
1608
|
if (this.options.downloadLink == 'modal' && typeof CustomEvent === "function") {
|
|
1569
1609
|
document.dispatchEvent(new CustomEvent("eletrack_download", { detail: event }));
|