@raruto/leaflet-elevation 2.3.2 → 2.3.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.
- package/dist/leaflet-elevation.js +94 -85
- 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 +1 -1
- package/package.json +1 -1
- package/src/components/chart.js +33 -33
- package/src/components/marker.js +6 -6
- package/src/components/summary.js +6 -6
- package/src/control.js +94 -85
|
@@ -320,7 +320,7 @@
|
|
|
320
320
|
/*
|
|
321
321
|
* Add data to the diagram either from GPX or GeoJSON and update the axis domain and data
|
|
322
322
|
*/
|
|
323
|
-
addData
|
|
323
|
+
addData(d, layer) {
|
|
324
324
|
this.import(this.__D3)
|
|
325
325
|
.then(() => {
|
|
326
326
|
if (this._modulesLoaded) {
|
|
@@ -337,7 +337,7 @@
|
|
|
337
337
|
/**
|
|
338
338
|
* Adds the control to the given map.
|
|
339
339
|
*/
|
|
340
|
-
addTo
|
|
340
|
+
addTo(map) {
|
|
341
341
|
if (this.options.detached) {
|
|
342
342
|
let parent = select(this.options.elevationDiv);
|
|
343
343
|
let eleDiv = this.onAdd(map);
|
|
@@ -351,12 +351,13 @@
|
|
|
351
351
|
/*
|
|
352
352
|
* Reset data and display
|
|
353
353
|
*/
|
|
354
|
-
clear
|
|
354
|
+
clear() {
|
|
355
355
|
if (this._marker) this._marker.remove();
|
|
356
356
|
if (this._chart) this._clearChart();
|
|
357
357
|
if (this._layers) this._clearLayers(this._layers);
|
|
358
358
|
if (this._markers) this._clearLayers(this._markers);
|
|
359
359
|
if (this._circleMarkers) this._circleMarkers.remove();
|
|
360
|
+
if (this._hotline) this._hotline.eachLayer(l => l.options.renderer.remove()); // hotfix for: https://github.com/Raruto/leaflet-elevation/issues/233
|
|
360
361
|
if (this._hotline) this._clearLayers(this._hotline);
|
|
361
362
|
|
|
362
363
|
this._data = [];
|
|
@@ -367,7 +368,7 @@
|
|
|
367
368
|
this._updateChart();
|
|
368
369
|
},
|
|
369
370
|
|
|
370
|
-
_clearChart
|
|
371
|
+
_clearChart() {
|
|
371
372
|
if (this._events && this._events.elechart_updated) {
|
|
372
373
|
this._events.elechart_updated.forEach(({fn, ctx}) => this.off('elechart_updated', fn, ctx));
|
|
373
374
|
}
|
|
@@ -377,7 +378,7 @@
|
|
|
377
378
|
}
|
|
378
379
|
},
|
|
379
380
|
|
|
380
|
-
_clearLayers
|
|
381
|
+
_clearLayers(l) {
|
|
381
382
|
l = l || this._layers;
|
|
382
383
|
if (l && l.eachLayer) {
|
|
383
384
|
l.eachLayer(f => f.remove());
|
|
@@ -404,7 +405,7 @@
|
|
|
404
405
|
/**
|
|
405
406
|
* Disable chart brushing.
|
|
406
407
|
*/
|
|
407
|
-
disableBrush
|
|
408
|
+
disableBrush() {
|
|
408
409
|
this._chart._brushEnabled = false;
|
|
409
410
|
this._resetDrag();
|
|
410
411
|
},
|
|
@@ -412,14 +413,14 @@
|
|
|
412
413
|
/**
|
|
413
414
|
* Enable chart brushing.
|
|
414
415
|
*/
|
|
415
|
-
enableBrush
|
|
416
|
+
enableBrush() {
|
|
416
417
|
this._chart._brushEnabled = true;
|
|
417
418
|
},
|
|
418
419
|
|
|
419
420
|
/**
|
|
420
421
|
* Disable chart zooming.
|
|
421
422
|
*/
|
|
422
|
-
disableZoom
|
|
423
|
+
disableZoom() {
|
|
423
424
|
this._chart._zoomEnabled = false;
|
|
424
425
|
this._chart._resetZoom();
|
|
425
426
|
},
|
|
@@ -427,40 +428,40 @@
|
|
|
427
428
|
/**
|
|
428
429
|
* Enable chart zooming.
|
|
429
430
|
*/
|
|
430
|
-
enableZoom
|
|
431
|
+
enableZoom() {
|
|
431
432
|
this._chart._zoomEnabled = true;
|
|
432
433
|
},
|
|
433
434
|
|
|
434
435
|
/**
|
|
435
436
|
* Sets a map view that contains the given geographical bounds.
|
|
436
437
|
*/
|
|
437
|
-
fitBounds
|
|
438
|
+
fitBounds(bounds) {
|
|
438
439
|
bounds = bounds || this.getBounds();
|
|
439
440
|
if (this._map && bounds.isValid()) this._map.fitBounds(bounds);
|
|
440
441
|
},
|
|
441
442
|
|
|
442
|
-
getBounds
|
|
443
|
+
getBounds(data) {
|
|
443
444
|
return L.latLngBounds((data || this._data).map((d) => d.latlng));
|
|
444
445
|
},
|
|
445
446
|
|
|
446
447
|
/**
|
|
447
448
|
* Get default zoom level (followMarker: true).
|
|
448
449
|
*/
|
|
449
|
-
getZFollow
|
|
450
|
+
getZFollow() {
|
|
450
451
|
return this.options.zFollow;
|
|
451
452
|
},
|
|
452
453
|
|
|
453
454
|
/**
|
|
454
455
|
* Hide current elevation chart profile.
|
|
455
456
|
*/
|
|
456
|
-
hide
|
|
457
|
+
hide() {
|
|
457
458
|
style(this._container, "display", "none");
|
|
458
459
|
},
|
|
459
460
|
|
|
460
461
|
/**
|
|
461
462
|
* Initialize chart control "options" and "container".
|
|
462
463
|
*/
|
|
463
|
-
initialize
|
|
464
|
+
initialize(opts) {
|
|
464
465
|
|
|
465
466
|
// opts = L.setOptions(this, opts);
|
|
466
467
|
|
|
@@ -503,7 +504,7 @@
|
|
|
503
504
|
/**
|
|
504
505
|
* Javascript scripts downloader (lazy loader)
|
|
505
506
|
*/
|
|
506
|
-
import
|
|
507
|
+
import(src, condition) {
|
|
507
508
|
switch(src) {
|
|
508
509
|
case this.__D3: condition = typeof d3 !== 'object'; break;
|
|
509
510
|
case this.__TOGEOJSON: condition = typeof toGeoJSON !== 'object'; break;
|
|
@@ -519,7 +520,7 @@
|
|
|
519
520
|
/**
|
|
520
521
|
* Load elevation data (GPX, GeoJSON, KML or TCX).
|
|
521
522
|
*/
|
|
522
|
-
load
|
|
523
|
+
load(data) {
|
|
523
524
|
this._parseFromString(data).then( geojson => geojson ? this._loadLayer(geojson) : this._loadFile(data));
|
|
524
525
|
},
|
|
525
526
|
|
|
@@ -527,7 +528,7 @@
|
|
|
527
528
|
* Create container DOM element and related event listeners.
|
|
528
529
|
* Called on control.addTo(map).
|
|
529
530
|
*/
|
|
530
|
-
onAdd
|
|
531
|
+
onAdd(map) {
|
|
531
532
|
this._map = map;
|
|
532
533
|
|
|
533
534
|
let container = this._container = create("div", "elevation-control " + this.options.theme + " " + (this.options.detached ? 'elevation-detached' : 'leaflet-control'), this.options.detached ? { id: 'elevation-' + randomId() } : {});
|
|
@@ -553,7 +554,7 @@
|
|
|
553
554
|
* Clean up control code and related event listeners.
|
|
554
555
|
* Called on control.remove().
|
|
555
556
|
*/
|
|
556
|
-
onRemove
|
|
557
|
+
onRemove(map) {
|
|
557
558
|
this._container = null;
|
|
558
559
|
|
|
559
560
|
map
|
|
@@ -576,28 +577,28 @@
|
|
|
576
577
|
/**
|
|
577
578
|
* Redraws the chart control. Sometimes useful after screen resize.
|
|
578
579
|
*/
|
|
579
|
-
redraw
|
|
580
|
+
redraw() {
|
|
580
581
|
this._resizeChart();
|
|
581
582
|
},
|
|
582
583
|
|
|
583
584
|
/**
|
|
584
585
|
* Set default zoom level (followMarker: true).
|
|
585
586
|
*/
|
|
586
|
-
setZFollow
|
|
587
|
+
setZFollow(zoom) {
|
|
587
588
|
this.options.zFollow = zoom;
|
|
588
589
|
},
|
|
589
590
|
|
|
590
591
|
/**
|
|
591
592
|
* Hide current elevation chart profile.
|
|
592
593
|
*/
|
|
593
|
-
show
|
|
594
|
+
show() {
|
|
594
595
|
style(this._container, "display", "block");
|
|
595
596
|
},
|
|
596
597
|
|
|
597
598
|
/*
|
|
598
599
|
* Parsing data either from GPX or GeoJSON and update the diagram data
|
|
599
600
|
*/
|
|
600
|
-
_addData
|
|
601
|
+
_addData(d) {
|
|
601
602
|
if (!d) {
|
|
602
603
|
return;
|
|
603
604
|
}
|
|
@@ -627,7 +628,7 @@
|
|
|
627
628
|
/*
|
|
628
629
|
* Parsing of GeoJSON data lines and their elevation in z-coordinate
|
|
629
630
|
*/
|
|
630
|
-
_addGeoJSONData
|
|
631
|
+
_addGeoJSONData(coords, properties, nestingLevel) {
|
|
631
632
|
|
|
632
633
|
// "coordinateProperties" property is generated inside "@tmcw/toGeoJSON"
|
|
633
634
|
let props = (properties && properties.coordinateProperties) || properties;
|
|
@@ -658,7 +659,7 @@
|
|
|
658
659
|
/*
|
|
659
660
|
* Parse and push a single (x, y, z) point to current elevation profile.
|
|
660
661
|
*/
|
|
661
|
-
_addPoint
|
|
662
|
+
_addPoint(x, y, z) {
|
|
662
663
|
if (this.options.reverseCoords) {
|
|
663
664
|
[x, y] = [y, x];
|
|
664
665
|
}
|
|
@@ -673,7 +674,7 @@
|
|
|
673
674
|
this.fire("eledata_updated", { index: this._data.length - 1 });
|
|
674
675
|
},
|
|
675
676
|
|
|
676
|
-
_addLayer
|
|
677
|
+
_addLayer(layer) {
|
|
677
678
|
if (layer) this._layers.addLayer(layer);
|
|
678
679
|
// Postpone adding the distance markers (lazy: true)
|
|
679
680
|
if (layer && this.options.distanceMarkers && this.options.distanceMarkers.lazy) {
|
|
@@ -682,7 +683,7 @@
|
|
|
682
683
|
return layer;
|
|
683
684
|
},
|
|
684
685
|
|
|
685
|
-
_addMarker
|
|
686
|
+
_addMarker(marker) {
|
|
686
687
|
if (marker) this._markers.addLayer(marker);
|
|
687
688
|
return marker;
|
|
688
689
|
},
|
|
@@ -690,7 +691,7 @@
|
|
|
690
691
|
/**
|
|
691
692
|
* Initialize "L.AlmostOver" integration
|
|
692
693
|
*/
|
|
693
|
-
_initAlmostOverHandler
|
|
694
|
+
_initAlmostOverHandler(map, layer) {
|
|
694
695
|
return (map && this.options.almostOver && !L.Browser.mobile) ? Promise.all([
|
|
695
696
|
this.import(this.__LGEOMUTIL),
|
|
696
697
|
this.import(this.__LALMOSTOVER)
|
|
@@ -699,8 +700,14 @@
|
|
|
699
700
|
if (L.GeometryUtil && map.almostOver && map.almostOver.enabled()) {
|
|
700
701
|
map.almostOver.addLayer(layer);
|
|
701
702
|
map
|
|
702
|
-
.on('almost:move',
|
|
703
|
-
.on('almost:out',
|
|
703
|
+
.on('almost:move', this._onMouseMoveLayer, this)
|
|
704
|
+
.on('almost:out', this._onMouseOut, this);
|
|
705
|
+
this.once('eledata_clear', () => {
|
|
706
|
+
map.almostOver.removeLayer(layer);
|
|
707
|
+
map
|
|
708
|
+
.off('almost:move', this._onMouseMoveLayer, this)
|
|
709
|
+
.off('almost:out', this._onMouseOut, this);
|
|
710
|
+
});
|
|
704
711
|
}
|
|
705
712
|
}) : Promise.resolve();
|
|
706
713
|
},
|
|
@@ -708,21 +715,21 @@
|
|
|
708
715
|
/**
|
|
709
716
|
* Initialize "L.DistanceMarkers" integration
|
|
710
717
|
*/
|
|
711
|
-
_initDistanceMarkers
|
|
718
|
+
_initDistanceMarkers() {
|
|
712
719
|
return this.options.distanceMarkers ? Promise.all([this.import(this.__LGEOMUTIL), this.import(this.__LDISTANCEM)]) : Promise.resolve();
|
|
713
720
|
},
|
|
714
721
|
|
|
715
722
|
/**
|
|
716
723
|
* Initialize "L.Control.EdgeScale" integration
|
|
717
724
|
*/
|
|
718
|
-
_initEdgeScale
|
|
725
|
+
_initEdgeScale(map) {
|
|
719
726
|
return this.options.edgeScale ? Promise.all([this.import(this.__LEDGESCALE)])
|
|
720
727
|
.then(() => {
|
|
721
728
|
map.edgeScaleControl = map.edgeScaleControl || L.control.edgeScale('boolean' !== typeof this.options.edgeScale ? this.options.edgeScale : {}).addTo(map);
|
|
722
729
|
}) : Promise.resolve();
|
|
723
730
|
},
|
|
724
731
|
|
|
725
|
-
_initHotLine
|
|
732
|
+
_initHotLine(layer) {
|
|
726
733
|
let prop = typeof this.options.hotline == 'string' ? this.options.hotline : 'elevation';
|
|
727
734
|
return this.options.hotline ? this.import(this.__LHOTLINE)
|
|
728
735
|
.then(() => {
|
|
@@ -756,7 +763,7 @@
|
|
|
756
763
|
/**
|
|
757
764
|
* Initialize "L.AlmostOver" and "L.DistanceMarkers"
|
|
758
765
|
*/
|
|
759
|
-
_initMapIntegrations
|
|
766
|
+
_initMapIntegrations(layer) {
|
|
760
767
|
let map = this._map;
|
|
761
768
|
if (map) {
|
|
762
769
|
if (this._data.length) {
|
|
@@ -769,8 +776,8 @@
|
|
|
769
776
|
this._initDistanceMarkers(),
|
|
770
777
|
this._initEdgeScale(map),
|
|
771
778
|
]).then(() => {
|
|
772
|
-
if
|
|
773
|
-
layer.addTo(map);
|
|
779
|
+
if (this.options.polyline) {
|
|
780
|
+
this._layers.addLayer(layer.addTo(map)); // hotfix for: https://github.com/Raruto/leaflet-elevation/issues/233
|
|
774
781
|
this._circleMarkers.addTo(map);
|
|
775
782
|
}
|
|
776
783
|
if (this.options.autofitBounds) {
|
|
@@ -786,7 +793,7 @@
|
|
|
786
793
|
/*
|
|
787
794
|
* Collapse current chart control.
|
|
788
795
|
*/
|
|
789
|
-
_collapse
|
|
796
|
+
_collapse() {
|
|
790
797
|
replaceClass(this._container, 'elevation-expanded', 'elevation-collapsed');
|
|
791
798
|
if (this._map) this._map.invalidateSize();
|
|
792
799
|
},
|
|
@@ -794,7 +801,7 @@
|
|
|
794
801
|
/*
|
|
795
802
|
* Expand current chart control.
|
|
796
803
|
*/
|
|
797
|
-
_expand
|
|
804
|
+
_expand() {
|
|
798
805
|
replaceClass(this._container, 'elevation-collapsed', 'elevation-expanded');
|
|
799
806
|
if (this._map) this._map.invalidateSize();
|
|
800
807
|
},
|
|
@@ -802,7 +809,7 @@
|
|
|
802
809
|
/**
|
|
803
810
|
* Add some basic colors to leaflet canvas renderer (preferCanvas: true).
|
|
804
811
|
*/
|
|
805
|
-
_fixCanvasPaths
|
|
812
|
+
_fixCanvasPaths() {
|
|
806
813
|
let oldProto = L.Canvas.prototype._fillStroke;
|
|
807
814
|
let control = this;
|
|
808
815
|
|
|
@@ -810,7 +817,7 @@
|
|
|
810
817
|
let color = Colors[theme] || {};
|
|
811
818
|
|
|
812
819
|
L.Canvas.include({
|
|
813
|
-
_fillStroke
|
|
820
|
+
_fillStroke(ctx, layer) {
|
|
814
821
|
if (control._layers.hasLayer(layer)) {
|
|
815
822
|
|
|
816
823
|
let options = layer.options;
|
|
@@ -841,7 +848,7 @@
|
|
|
841
848
|
*
|
|
842
849
|
* @link https://github.com/Raruto/leaflet-elevation/issues/81#issuecomment-713477050
|
|
843
850
|
*/
|
|
844
|
-
_fixTooltipSize
|
|
851
|
+
_fixTooltipSize() {
|
|
845
852
|
this.on('elechart_init', () =>
|
|
846
853
|
this.once('elechart_change elechart_hover', ({data, xCoord}) => {
|
|
847
854
|
if (this._chartEnabled) {
|
|
@@ -856,21 +863,21 @@
|
|
|
856
863
|
/*
|
|
857
864
|
* Finds a data entry for the given LatLng
|
|
858
865
|
*/
|
|
859
|
-
_findItemForLatLng
|
|
866
|
+
_findItemForLatLng(latlng) {
|
|
860
867
|
return this._data[this._chart._findIndexForLatLng(latlng)];
|
|
861
868
|
},
|
|
862
869
|
|
|
863
870
|
/*
|
|
864
871
|
* Finds a data entry for the given xDiagCoord
|
|
865
872
|
*/
|
|
866
|
-
_findItemForX
|
|
873
|
+
_findItemForX(x) {
|
|
867
874
|
return this._data[this._chart._findIndexForXCoord(x)];
|
|
868
875
|
},
|
|
869
876
|
|
|
870
877
|
/**
|
|
871
878
|
* Fires an event of the specified type.
|
|
872
879
|
*/
|
|
873
|
-
_fireEvt
|
|
880
|
+
_fireEvt(type, data, propagate) {
|
|
874
881
|
if (this.fire) this.fire(type, data, propagate);
|
|
875
882
|
if (this._map) this._map.fire(type, data, propagate);
|
|
876
883
|
},
|
|
@@ -878,7 +885,7 @@
|
|
|
878
885
|
/*
|
|
879
886
|
* Hides the position/height indicator marker drawn onto the map
|
|
880
887
|
*/
|
|
881
|
-
_hideMarker
|
|
888
|
+
_hideMarker() {
|
|
882
889
|
if (this.options.autohideMarker) {
|
|
883
890
|
this._marker.remove();
|
|
884
891
|
}
|
|
@@ -887,7 +894,7 @@
|
|
|
887
894
|
/**
|
|
888
895
|
* Generate "svg" chart (DOM element).
|
|
889
896
|
*/
|
|
890
|
-
_initChart
|
|
897
|
+
_initChart(container) {
|
|
891
898
|
let opts = this.options;
|
|
892
899
|
let map = this._map;
|
|
893
900
|
|
|
@@ -952,7 +959,7 @@
|
|
|
952
959
|
|
|
953
960
|
},
|
|
954
961
|
|
|
955
|
-
_initLayer
|
|
962
|
+
_initLayer() {
|
|
956
963
|
this._layers
|
|
957
964
|
.on('layeradd layerremove', ({layer, type}) => {
|
|
958
965
|
let node = layer.getElement && layer.getElement();
|
|
@@ -962,7 +969,7 @@
|
|
|
962
969
|
});
|
|
963
970
|
},
|
|
964
971
|
|
|
965
|
-
_initMarker
|
|
972
|
+
_initMarker(map) {
|
|
966
973
|
let pane = map.getPane('elevationPane');
|
|
967
974
|
if (!pane) {
|
|
968
975
|
pane = this._pane = map.createPane('elevationPane', map.getPane('norotatePane') || map.getPane('mapPane'));
|
|
@@ -985,7 +992,7 @@
|
|
|
985
992
|
/**
|
|
986
993
|
* Inspired by L.Control.Layers
|
|
987
994
|
*/
|
|
988
|
-
_initButton
|
|
995
|
+
_initButton(container) {
|
|
989
996
|
L.DomEvent
|
|
990
997
|
.disableClickPropagation(container)
|
|
991
998
|
.disableScrollPropagation(container);
|
|
@@ -1007,7 +1014,7 @@
|
|
|
1007
1014
|
}
|
|
1008
1015
|
},
|
|
1009
1016
|
|
|
1010
|
-
_initSummary
|
|
1017
|
+
_initSummary(container) {
|
|
1011
1018
|
this.import(this.__LSUMMARY).then((m)=>{
|
|
1012
1019
|
this._summary = new (m || Elevation).Summary({ summary: this.options.summary }, this);
|
|
1013
1020
|
|
|
@@ -1020,7 +1027,7 @@
|
|
|
1020
1027
|
/**
|
|
1021
1028
|
* Retrieve data from a remote url (HTTP).
|
|
1022
1029
|
*/
|
|
1023
|
-
_loadFile
|
|
1030
|
+
_loadFile(url) {
|
|
1024
1031
|
fetch(url)
|
|
1025
1032
|
.then((response) => response.text())
|
|
1026
1033
|
.then((data) => {
|
|
@@ -1033,7 +1040,7 @@
|
|
|
1033
1040
|
/**
|
|
1034
1041
|
* Dynamically import only required javascript modules (code splitting)
|
|
1035
1042
|
*/
|
|
1036
|
-
_loadModules
|
|
1043
|
+
_loadModules(handlers) {
|
|
1037
1044
|
// First map known classnames (eg. "Altitude" --> L.Control.Elevation.Altitude)
|
|
1038
1045
|
handlers = handlers.map((h) => typeof h === 'string' && typeof Elevation[h] !== "undefined" ? Elevation[h] : h);
|
|
1039
1046
|
// Then load optional classes and custom imports (eg. "Cadence" --> import('../src/handlers/cadence.js'))
|
|
@@ -1052,7 +1059,7 @@
|
|
|
1052
1059
|
/**
|
|
1053
1060
|
* Simple GeoJSON data loader (L.GeoJSON).
|
|
1054
1061
|
*/
|
|
1055
|
-
_loadLayer
|
|
1062
|
+
_loadLayer(geojson) {
|
|
1056
1063
|
let { polyline, theme, waypoints, wptIcons, wptLabels, distanceMarkers } = this.options;
|
|
1057
1064
|
let style = L.extend({}, polyline);
|
|
1058
1065
|
|
|
@@ -1100,14 +1107,14 @@
|
|
|
1100
1107
|
return layer;
|
|
1101
1108
|
},
|
|
1102
1109
|
|
|
1103
|
-
_onDragEnd
|
|
1110
|
+
_onDragEnd({ dragstart, dragend}) {
|
|
1104
1111
|
this._hideMarker();
|
|
1105
1112
|
this.fitBounds(L.latLngBounds([dragstart.latlng, dragend.latlng]));
|
|
1106
1113
|
|
|
1107
1114
|
this.fire("elechart_dragged");
|
|
1108
1115
|
},
|
|
1109
1116
|
|
|
1110
|
-
_onKeyDown
|
|
1117
|
+
_onKeyDown({key}) {
|
|
1111
1118
|
if(!this.options.detached && key === "Escape"){
|
|
1112
1119
|
this._collapse();
|
|
1113
1120
|
} },
|
|
@@ -1115,14 +1122,14 @@
|
|
|
1115
1122
|
/**
|
|
1116
1123
|
* Trigger mouseenter event.
|
|
1117
1124
|
*/
|
|
1118
|
-
_onMouseEnter
|
|
1125
|
+
_onMouseEnter() {
|
|
1119
1126
|
this.fire('elechart_enter');
|
|
1120
1127
|
},
|
|
1121
1128
|
|
|
1122
1129
|
/*
|
|
1123
1130
|
* Handles the moueseover the chart and displays distance and altitude level.
|
|
1124
1131
|
*/
|
|
1125
|
-
_onMouseMove
|
|
1132
|
+
_onMouseMove({xCoord}) {
|
|
1126
1133
|
if (this._chartEnabled && this._data.length) {
|
|
1127
1134
|
let item = this._findItemForX(xCoord);
|
|
1128
1135
|
if (item) {
|
|
@@ -1144,7 +1151,7 @@
|
|
|
1144
1151
|
/*
|
|
1145
1152
|
* Handles mouseover events of the data layers on the map.
|
|
1146
1153
|
*/
|
|
1147
|
-
_onMouseMoveLayer
|
|
1154
|
+
_onMouseMoveLayer({latlng}) {
|
|
1148
1155
|
if (this._data.length) {
|
|
1149
1156
|
let item = this._findItemForLatLng(latlng);
|
|
1150
1157
|
if (item) {
|
|
@@ -1162,7 +1169,7 @@
|
|
|
1162
1169
|
/*
|
|
1163
1170
|
* Handles the moueseout over the chart.
|
|
1164
1171
|
*/
|
|
1165
|
-
_onMouseOut
|
|
1172
|
+
_onMouseOut() {
|
|
1166
1173
|
if (!this.options.detached) {
|
|
1167
1174
|
this._hideMarker();
|
|
1168
1175
|
this._chart._hideDiagramIndicator();
|
|
@@ -1178,14 +1185,14 @@
|
|
|
1178
1185
|
/**
|
|
1179
1186
|
* Handles the drag event over the ruler filter.
|
|
1180
1187
|
*/
|
|
1181
|
-
_onRulerFilter
|
|
1188
|
+
_onRulerFilter({coords}) {
|
|
1182
1189
|
this._updateMapSegments(coords);
|
|
1183
1190
|
},
|
|
1184
1191
|
|
|
1185
1192
|
/**
|
|
1186
1193
|
* Toggle chart data on legend click
|
|
1187
1194
|
*/
|
|
1188
|
-
_onToggleChart
|
|
1195
|
+
_onToggleChart({ name, enabled }) {
|
|
1189
1196
|
|
|
1190
1197
|
this._chartEnabled = this._chart._hasActiveLayers();
|
|
1191
1198
|
|
|
@@ -1205,7 +1212,7 @@
|
|
|
1205
1212
|
/**
|
|
1206
1213
|
* Simple GeoJSON Parser
|
|
1207
1214
|
*/
|
|
1208
|
-
_parseFromGeoJSONString
|
|
1215
|
+
_parseFromGeoJSONString(data) {
|
|
1209
1216
|
try {
|
|
1210
1217
|
return JSON.parse(data);
|
|
1211
1218
|
} catch (e) { }
|
|
@@ -1214,7 +1221,7 @@
|
|
|
1214
1221
|
/**
|
|
1215
1222
|
* Attempt to parse raw response data (GeoJSON or XML > GeoJSON)
|
|
1216
1223
|
*/
|
|
1217
|
-
_parseFromString
|
|
1224
|
+
_parseFromString(data) {
|
|
1218
1225
|
return new Promise(resolve =>
|
|
1219
1226
|
this.import(this.__TOGEOJSON).then(() => {
|
|
1220
1227
|
let geojson;
|
|
@@ -1234,7 +1241,7 @@
|
|
|
1234
1241
|
/**
|
|
1235
1242
|
* Simple XML Parser (GPX, KML, TCX)
|
|
1236
1243
|
*/
|
|
1237
|
-
_parseFromXMLString
|
|
1244
|
+
_parseFromXMLString(data) {
|
|
1238
1245
|
if (data.indexOf("<") != 0) {
|
|
1239
1246
|
throw 'Invalid XML';
|
|
1240
1247
|
}
|
|
@@ -1255,36 +1262,38 @@
|
|
|
1255
1262
|
/**
|
|
1256
1263
|
* Add chart profile to diagram
|
|
1257
1264
|
*/
|
|
1258
|
-
_registerAreaPath
|
|
1265
|
+
_registerAreaPath(props) {
|
|
1259
1266
|
this.on("elechart_init", () => this._chart._registerAreaPath(props));
|
|
1260
1267
|
},
|
|
1261
1268
|
|
|
1262
1269
|
/**
|
|
1263
1270
|
* Add chart grid to diagram
|
|
1264
1271
|
*/
|
|
1265
|
-
_registerAxisGrid
|
|
1272
|
+
_registerAxisGrid(props) {
|
|
1266
1273
|
this.on("elechart_axis", () => this._chart._registerAxisGrid(props));
|
|
1267
1274
|
},
|
|
1268
1275
|
|
|
1269
1276
|
/**
|
|
1270
1277
|
* Add chart axis to diagram
|
|
1271
1278
|
*/
|
|
1272
|
-
_registerAxisScale
|
|
1279
|
+
_registerAxisScale(props) {
|
|
1273
1280
|
this.on("elechart_axis", () => this._chart._registerAxisScale(props));
|
|
1274
1281
|
},
|
|
1275
1282
|
|
|
1276
1283
|
/**
|
|
1277
1284
|
* Add a point of interest over the diagram
|
|
1278
1285
|
*/
|
|
1279
|
-
_registerCheckPoint
|
|
1280
|
-
|
|
1286
|
+
_registerCheckPoint(props) {
|
|
1287
|
+
const cb = () => this._chart._registerCheckPoint(props);
|
|
1288
|
+
this
|
|
1289
|
+
.on("elechart_updated", cb)
|
|
1290
|
+
.once("eledata_clear", () => this.off("elechart_updated", cb));
|
|
1281
1291
|
},
|
|
1282
1292
|
|
|
1283
|
-
|
|
1284
1293
|
/**
|
|
1285
1294
|
* Base handler for iterative track statistics (dist, time, z, slope, speed, acceleration, ...)
|
|
1286
1295
|
*/
|
|
1287
|
-
_registerDataAttribute
|
|
1296
|
+
_registerDataAttribute(props) {
|
|
1288
1297
|
|
|
1289
1298
|
// parse of "coordinateProperties" for later usage
|
|
1290
1299
|
if (props.coordPropsToMeta) {
|
|
@@ -1361,7 +1370,7 @@
|
|
|
1361
1370
|
/**
|
|
1362
1371
|
* Parse a module definition and attach related function listeners
|
|
1363
1372
|
*/
|
|
1364
|
-
_registerHandler
|
|
1373
|
+
_registerHandler(props) {
|
|
1365
1374
|
|
|
1366
1375
|
// eg. L.Control.Altitude
|
|
1367
1376
|
if (typeof props === "function") {
|
|
@@ -1444,7 +1453,7 @@
|
|
|
1444
1453
|
/**
|
|
1445
1454
|
* Add chart or marker tooltip info
|
|
1446
1455
|
*/
|
|
1447
|
-
_registerTooltip
|
|
1456
|
+
_registerTooltip(props) {
|
|
1448
1457
|
props.chart && this.on("elechart_init", () => this._chart._registerTooltip(L.extend({}, props, { value: props.chart })));
|
|
1449
1458
|
props.marker && this.on("elechart_marker", () => this._marker._registerTooltip(L.extend({}, props, { value: props.marker })));
|
|
1450
1459
|
},
|
|
@@ -1452,14 +1461,14 @@
|
|
|
1452
1461
|
/**
|
|
1453
1462
|
* Add summary info to diagram
|
|
1454
1463
|
*/
|
|
1455
|
-
_registerSummary
|
|
1464
|
+
_registerSummary(props) {
|
|
1456
1465
|
this.on('elechart_summary', () => this._summary._registerSummary(props));
|
|
1457
1466
|
},
|
|
1458
1467
|
|
|
1459
1468
|
/*
|
|
1460
1469
|
* Removes the drag rectangle and zoms back to the total extent of the data.
|
|
1461
1470
|
*/
|
|
1462
|
-
_resetDrag
|
|
1471
|
+
_resetDrag() {
|
|
1463
1472
|
this._chart._resetDrag();
|
|
1464
1473
|
this._hideMarker();
|
|
1465
1474
|
},
|
|
@@ -1467,7 +1476,7 @@
|
|
|
1467
1476
|
/**
|
|
1468
1477
|
* Resets drag, marker and bounds.
|
|
1469
1478
|
*/
|
|
1470
|
-
_resetView
|
|
1479
|
+
_resetView() {
|
|
1471
1480
|
if (this._map && this._map._isFullscreen) return;
|
|
1472
1481
|
this._resetDrag();
|
|
1473
1482
|
this._hideMarker();
|
|
@@ -1479,7 +1488,7 @@
|
|
|
1479
1488
|
/**
|
|
1480
1489
|
* Hacky way for handling chart resize. Deletes it and redraw chart.
|
|
1481
1490
|
*/
|
|
1482
|
-
_resizeChart
|
|
1491
|
+
_resizeChart() {
|
|
1483
1492
|
if (this._container && style(this._container, "display") != "none") {
|
|
1484
1493
|
let opts = this.options;
|
|
1485
1494
|
let newWidth = opts.detached ? (this.eleDiv || this._container).offsetWidth : clamp(opts._maxWidth, [0, this._map.getContainer().clientWidth - 30]);
|
|
@@ -1497,14 +1506,14 @@
|
|
|
1497
1506
|
/**
|
|
1498
1507
|
* Collapse or Expand chart control.
|
|
1499
1508
|
*/
|
|
1500
|
-
_toggle
|
|
1509
|
+
_toggle() {
|
|
1501
1510
|
hasClass(this._container, "elevation-expanded") ? this._collapse() : this._expand();
|
|
1502
1511
|
},
|
|
1503
1512
|
|
|
1504
1513
|
/**
|
|
1505
1514
|
* Update map center and zoom (followMarker: true)
|
|
1506
1515
|
*/
|
|
1507
|
-
_setMapView
|
|
1516
|
+
_setMapView(item) {
|
|
1508
1517
|
if (this._map && this.options.followMarker) {
|
|
1509
1518
|
let zoom = this._map.getZoom();
|
|
1510
1519
|
let z = this.options.zFollow;
|
|
@@ -1519,7 +1528,7 @@
|
|
|
1519
1528
|
/**
|
|
1520
1529
|
* Calculates [x, y] domain and then update chart.
|
|
1521
1530
|
*/
|
|
1522
|
-
_updateChart
|
|
1531
|
+
_updateChart() {
|
|
1523
1532
|
if (this._chart && this._container) {
|
|
1524
1533
|
this.fire("elechart_axis");
|
|
1525
1534
|
|
|
@@ -1535,7 +1544,7 @@
|
|
|
1535
1544
|
/*
|
|
1536
1545
|
* Update the position/height indicator marker drawn onto the map
|
|
1537
1546
|
*/
|
|
1538
|
-
_updateMarker
|
|
1547
|
+
_updateMarker(item) {
|
|
1539
1548
|
if (this._marker) {
|
|
1540
1549
|
this._marker.update({
|
|
1541
1550
|
map : this._map,
|
|
@@ -1549,7 +1558,7 @@
|
|
|
1549
1558
|
/**
|
|
1550
1559
|
* Fix marker rotation on rotated maps
|
|
1551
1560
|
*/
|
|
1552
|
-
_rotateMarker
|
|
1561
|
+
_rotateMarker() {
|
|
1553
1562
|
if (this._marker) {
|
|
1554
1563
|
this._marker.update();
|
|
1555
1564
|
}
|
|
@@ -1558,7 +1567,7 @@
|
|
|
1558
1567
|
/**
|
|
1559
1568
|
* Highlight track segments on the map.
|
|
1560
1569
|
*/
|
|
1561
|
-
_updateMapSegments
|
|
1570
|
+
_updateMapSegments(coords) {
|
|
1562
1571
|
this._markedSegments.setLatLngs(coords || []);
|
|
1563
1572
|
if (coords && this._map && !this._map.hasLayer(this._markedSegments)) {
|
|
1564
1573
|
this._markedSegments.addTo(this._map);
|
|
@@ -1568,7 +1577,7 @@
|
|
|
1568
1577
|
/**
|
|
1569
1578
|
* Update chart summary.
|
|
1570
1579
|
*/
|
|
1571
|
-
_updateSummary
|
|
1580
|
+
_updateSummary() {
|
|
1572
1581
|
if (this._summary) {
|
|
1573
1582
|
this._summary.reset();
|
|
1574
1583
|
if (this.options.summary) {
|
|
@@ -1595,7 +1604,7 @@
|
|
|
1595
1604
|
/**
|
|
1596
1605
|
* Calculates chart width.
|
|
1597
1606
|
*/
|
|
1598
|
-
_width
|
|
1607
|
+
_width() {
|
|
1599
1608
|
if (this._chart) return this._chart._width();
|
|
1600
1609
|
const { width, margins } = this.options;
|
|
1601
1610
|
return width - margins.left - margins.right;
|
|
@@ -1604,7 +1613,7 @@
|
|
|
1604
1613
|
/**
|
|
1605
1614
|
* Calculates chart height.
|
|
1606
1615
|
*/
|
|
1607
|
-
_height
|
|
1616
|
+
_height() {
|
|
1608
1617
|
if (this._chart) return this._chart._height();
|
|
1609
1618
|
const { height, margins } = this.options;
|
|
1610
1619
|
return height - margins.top - margins.bottom;
|