@raruto/leaflet-elevation 2.2.3 → 2.2.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.
- package/LICENSE +674 -674
- package/README.md +291 -285
- package/dist/leaflet-elevation.css +337 -337
- package/dist/leaflet-elevation.js +1586 -1580
- 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/images/elevation-position.svg +1 -1
- package/images/elevation-pushpin.svg +1 -1
- package/images/elevation.svg +1 -1
- package/libs/leaflet-distance-marker.css +8 -8
- package/libs/leaflet-distance-marker.js +314 -314
- package/package.json +71 -71
- package/src/components/chart.js +783 -783
- package/src/components/d3.js +641 -641
- package/src/components/marker.js +96 -96
- package/src/components/summary.js +43 -43
- package/src/control.js +1313 -1307
- package/src/handlers/acceleration.js +64 -64
- package/src/handlers/altitude.js +79 -79
- package/src/handlers/distance.js +46 -45
- package/src/handlers/heart.js +52 -52
- package/src/handlers/pace.js +65 -65
- package/src/handlers/slope.js +79 -79
- package/src/handlers/speed.js +66 -66
- package/src/handlers/time.js +102 -102
- package/src/index.css +329 -329
- package/src/index.js +42 -42
- package/src/options.js +85 -85
- package/src/utils.js +158 -158
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: function(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: function(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: function(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: function() {
|
|
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: function() {
|
|
89
|
-
return this._latlng;
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
_registerTooltip: function(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: function(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: function(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: function(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: function() {
|
|
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: function() {
|
|
89
|
+
return this._latlng;
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
_registerTooltip: function(props) {
|
|
93
|
+
this._labels[props.name] = props;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
});
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
const _ = L.Control.Elevation.Utils;
|
|
2
|
-
|
|
3
|
-
export var Summary = L.Class.extend({
|
|
4
|
-
initialize: function(opts, control) {
|
|
5
|
-
this.options = opts;
|
|
6
|
-
this.control = control;
|
|
7
|
-
this.labels = {};
|
|
8
|
-
|
|
9
|
-
let summary = this._container = _.create("div", "elevation-summary " + (opts.summary ? opts.summary + "-summary" : ''));
|
|
10
|
-
_.style(summary, 'max-width', opts.width ? opts.width + 'px' : '');
|
|
11
|
-
},
|
|
12
|
-
|
|
13
|
-
render: function() {
|
|
14
|
-
return container => container.append(() => this._container);
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
reset: function() {
|
|
18
|
-
this._container.innerHTML = '';
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
-
append: function(className, label, value) {
|
|
22
|
-
this._container.innerHTML += `<span class="${className}"><span class="summarylabel">${label}</span><span class="summaryvalue">${value}</span></span>`;
|
|
23
|
-
return this;
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
update: function() {
|
|
27
|
-
Object
|
|
28
|
-
.keys(this.labels)
|
|
29
|
-
.sort((a, b) => this.labels[a].order - this.labels[b].order) // TODO: any performance issues?
|
|
30
|
-
.forEach((i)=> {
|
|
31
|
-
let value = typeof this.labels[i].value !== "function" ? this.labels[i].value : this.labels[i].value(this.control.track_info, this.labels[i].unit || '');
|
|
32
|
-
this.append(i /*+ " order-" + this.labels[i].order*/, L._(this.labels[i].label), value, this.labels[i].order);
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
|
|
36
|
-
_registerSummary: function(data) {
|
|
37
|
-
for (let i in data) {
|
|
38
|
-
data[i].order = data[i].order ?? 1000;
|
|
39
|
-
this.labels[i] = data[i];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
});
|
|
1
|
+
const _ = L.Control.Elevation.Utils;
|
|
2
|
+
|
|
3
|
+
export var Summary = L.Class.extend({
|
|
4
|
+
initialize: function(opts, control) {
|
|
5
|
+
this.options = opts;
|
|
6
|
+
this.control = control;
|
|
7
|
+
this.labels = {};
|
|
8
|
+
|
|
9
|
+
let summary = this._container = _.create("div", "elevation-summary " + (opts.summary ? opts.summary + "-summary" : ''));
|
|
10
|
+
_.style(summary, 'max-width', opts.width ? opts.width + 'px' : '');
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
render: function() {
|
|
14
|
+
return container => container.append(() => this._container);
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
reset: function() {
|
|
18
|
+
this._container.innerHTML = '';
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
append: function(className, label, value) {
|
|
22
|
+
this._container.innerHTML += `<span class="${className}"><span class="summarylabel">${label}</span><span class="summaryvalue">${value}</span></span>`;
|
|
23
|
+
return this;
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
update: function() {
|
|
27
|
+
Object
|
|
28
|
+
.keys(this.labels)
|
|
29
|
+
.sort((a, b) => this.labels[a].order - this.labels[b].order) // TODO: any performance issues?
|
|
30
|
+
.forEach((i)=> {
|
|
31
|
+
let value = typeof this.labels[i].value !== "function" ? this.labels[i].value : this.labels[i].value(this.control.track_info, this.labels[i].unit || '');
|
|
32
|
+
this.append(i /*+ " order-" + this.labels[i].order*/, L._(this.labels[i].label), value, this.labels[i].order);
|
|
33
|
+
});
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
_registerSummary: function(data) {
|
|
37
|
+
for (let i in data) {
|
|
38
|
+
data[i].order = data[i].order ?? 1000;
|
|
39
|
+
this.labels[i] = data[i];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
});
|