@raruto/leaflet-elevation 2.3.4 → 2.5.0
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/README.md +325 -323
- package/dist/leaflet-elevation.js +1619 -1575
- 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-gpxgroup.js +346 -340
- package/libs/leaflet-gpxgroup.min.js +1 -1
- package/libs/leaflet-hotline.js +456 -456
- package/package.json +74 -74
- package/src/components/chart.js +783 -783
- package/src/components/d3.js +649 -641
- package/src/components/marker.js +96 -96
- package/src/control.js +1335 -1332
- package/src/handlers/labels.js +45 -0
- package/src/handlers/lineargradient.js +122 -0
- package/src/handlers/runner.js +109 -0
- package/src/handlers/time.js +102 -102
- package/src/options.js +88 -88
- package/src/utils.js +203 -163
package/src/components/marker.js
CHANGED
|
@@ -1,96 +1,96 @@
|
|
|
1
|
-
import * as D3 from './d3.js';
|
|
2
|
-
|
|
3
|
-
const _ = L.Control.Elevation.Utils;
|
|
4
|
-
|
|
5
|
-
export var Marker = L.Class.extend({
|
|
6
|
-
|
|
7
|
-
initialize(options, control) {
|
|
8
|
-
this.options = options;
|
|
9
|
-
this.control = control
|
|
10
|
-
|
|
11
|
-
switch(this.options.marker) {
|
|
12
|
-
case 'elevation-line':
|
|
13
|
-
// this._container = d3.create("g").attr("class", "height-focus-group");
|
|
14
|
-
break;
|
|
15
|
-
case 'position-marker':
|
|
16
|
-
// this._marker = L.circleMarker([0, 0], { pane: 'overlayPane', radius: 6, fillColor: '#fff', fillOpacity:1, color: '#000', weight:1, interactive: false });
|
|
17
|
-
this._marker = L.marker([0, 0], { icon: this.options.markerIcon, zIndexOffset: 1000000, interactive: false });
|
|
18
|
-
break;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
this._labels = {};
|
|
22
|
-
|
|
23
|
-
return this;
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
addTo(map) {
|
|
27
|
-
this._map = map;
|
|
28
|
-
switch(this.options.marker) {
|
|
29
|
-
case 'elevation-line': this._container = d3.select(map.getPane('elevationPane')).select("svg > g").call(D3.PositionMarker({})); break;
|
|
30
|
-
case 'position-marker': this._marker.addTo(map, { pane: 'overlayPane' }); break;
|
|
31
|
-
}
|
|
32
|
-
return this;
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Update position marker ("leaflet-marker").
|
|
37
|
-
*/
|
|
38
|
-
update(props) {
|
|
39
|
-
if (props) this._props = props;
|
|
40
|
-
else props = this._props;
|
|
41
|
-
|
|
42
|
-
if(!props) return;
|
|
43
|
-
|
|
44
|
-
if (props.options) this.options = props.options;
|
|
45
|
-
if (!this._map) this.addTo(props.map);
|
|
46
|
-
|
|
47
|
-
this._latlng = props.item.latlng;
|
|
48
|
-
|
|
49
|
-
switch(this.options.marker) {
|
|
50
|
-
case 'elevation-line':
|
|
51
|
-
if (this._container) {
|
|
52
|
-
let point = this._map.latLngToLayerPoint(this._latlng);
|
|
53
|
-
point = L.extend({}, props.item, this._map._rotate ? this._map.rotatedPointToMapPanePoint(point) : point);
|
|
54
|
-
|
|
55
|
-
let yMax = (this.control._height() / props.yCoordMax * point[this.options.yAttr]);
|
|
56
|
-
|
|
57
|
-
if(!isFinite(yMax) || isNaN(yMax)) yMax = 0;
|
|
58
|
-
|
|
59
|
-
this._container.classed("leaflet-hidden", false);
|
|
60
|
-
this._container.call(D3.PositionMarker({
|
|
61
|
-
theme : this.options.theme,
|
|
62
|
-
xCoord: point.x,
|
|
63
|
-
yCoord: point.y,
|
|
64
|
-
length: point.y - yMax, // normalized Y
|
|
65
|
-
labels: this._labels,
|
|
66
|
-
item: point,
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
break;
|
|
70
|
-
case 'position-marker':
|
|
71
|
-
_.removeClass(this._marker.getElement(), 'leaflet-hidden');
|
|
72
|
-
this._marker.setLatLng(this._latlng);
|
|
73
|
-
break;
|
|
74
|
-
}
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
/*
|
|
78
|
-
* Hides the position/height indicator marker drawn onto the map
|
|
79
|
-
*/
|
|
80
|
-
remove() {
|
|
81
|
-
this._props = null;
|
|
82
|
-
switch(this.options.marker) {
|
|
83
|
-
case 'elevation-line': this._container && this._container.classed("leaflet-hidden", true); break;
|
|
84
|
-
case 'position-marker': _.addClass(this._marker.getElement(), 'leaflet-hidden'); break;
|
|
85
|
-
}
|
|
86
|
-
},
|
|
87
|
-
|
|
88
|
-
getLatLng() {
|
|
89
|
-
return this._latlng;
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
_registerTooltip(props) {
|
|
93
|
-
this._labels[props.name] = props;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
});
|
|
1
|
+
import * as D3 from './d3.js';
|
|
2
|
+
|
|
3
|
+
const _ = L.Control.Elevation.Utils;
|
|
4
|
+
|
|
5
|
+
export var Marker = L.Class.extend({
|
|
6
|
+
|
|
7
|
+
initialize(options, control) {
|
|
8
|
+
this.options = options;
|
|
9
|
+
this.control = control
|
|
10
|
+
|
|
11
|
+
switch(this.options.marker) {
|
|
12
|
+
case 'elevation-line':
|
|
13
|
+
// this._container = d3.create("g").attr("class", "height-focus-group");
|
|
14
|
+
break;
|
|
15
|
+
case 'position-marker':
|
|
16
|
+
// this._marker = L.circleMarker([0, 0], { pane: 'overlayPane', radius: 6, fillColor: '#fff', fillOpacity:1, color: '#000', weight:1, interactive: false });
|
|
17
|
+
this._marker = L.marker([0, 0], { icon: this.options.markerIcon, zIndexOffset: 1000000, interactive: false });
|
|
18
|
+
break;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
this._labels = {};
|
|
22
|
+
|
|
23
|
+
return this;
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
addTo(map) {
|
|
27
|
+
this._map = map;
|
|
28
|
+
switch(this.options.marker) {
|
|
29
|
+
case 'elevation-line': this._container = d3.select(map.getPane('elevationPane')).select("svg > g").call(D3.PositionMarker({})); break;
|
|
30
|
+
case 'position-marker': this._marker.addTo(map, { pane: 'overlayPane' }); break;
|
|
31
|
+
}
|
|
32
|
+
return this;
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Update position marker ("leaflet-marker").
|
|
37
|
+
*/
|
|
38
|
+
update(props) {
|
|
39
|
+
if (props) this._props = props;
|
|
40
|
+
else props = this._props;
|
|
41
|
+
|
|
42
|
+
if (!props) return;
|
|
43
|
+
|
|
44
|
+
if (props.options) this.options = props.options;
|
|
45
|
+
if (!this._map) this.addTo(props.map);
|
|
46
|
+
|
|
47
|
+
this._latlng = props.item.latlng;
|
|
48
|
+
|
|
49
|
+
switch(this.options.marker) {
|
|
50
|
+
case 'elevation-line':
|
|
51
|
+
if (this._container) {
|
|
52
|
+
let point = this._map.latLngToLayerPoint(this._latlng);
|
|
53
|
+
point = L.extend({}, props.item, this._map._rotate ? this._map.rotatedPointToMapPanePoint(point) : point);
|
|
54
|
+
|
|
55
|
+
let yMax = (this.control._height() / props.yCoordMax * point[this.options.yAttr]);
|
|
56
|
+
|
|
57
|
+
if (!isFinite(yMax) || isNaN(yMax)) yMax = 0;
|
|
58
|
+
|
|
59
|
+
this._container.classed("leaflet-hidden", false);
|
|
60
|
+
this._container.call(D3.PositionMarker({
|
|
61
|
+
theme : this.options.theme,
|
|
62
|
+
xCoord: point.x,
|
|
63
|
+
yCoord: point.y,
|
|
64
|
+
length: point.y - yMax, // normalized Y
|
|
65
|
+
labels: this._labels,
|
|
66
|
+
item: point,
|
|
67
|
+
}));
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
case 'position-marker':
|
|
71
|
+
_.removeClass(this._marker.getElement(), 'leaflet-hidden');
|
|
72
|
+
this._marker.setLatLng(this._latlng);
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
/*
|
|
78
|
+
* Hides the position/height indicator marker drawn onto the map
|
|
79
|
+
*/
|
|
80
|
+
remove() {
|
|
81
|
+
this._props = null;
|
|
82
|
+
switch(this.options.marker) {
|
|
83
|
+
case 'elevation-line': this._container && this._container.classed("leaflet-hidden", true); break;
|
|
84
|
+
case 'position-marker': _.addClass(this._marker.getElement(), 'leaflet-hidden'); break;
|
|
85
|
+
}
|
|
86
|
+
},
|
|
87
|
+
|
|
88
|
+
getLatLng() {
|
|
89
|
+
return this._latlng;
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
_registerTooltip(props) {
|
|
93
|
+
this._labels[props.name] = props;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
});
|