@raruto/leaflet-elevation 2.2.8 → 2.3.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 +9 -4
- package/dist/leaflet-elevation.js +44 -27
- 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-edgescale.js +636 -0
- package/libs/leaflet-edgescale.min.js +1 -0
- package/package.json +72 -69
- package/src/control.js +17 -1
- package/src/options.js +1 -0
- package/src/utils.spec.js +50 -0
package/README.md
CHANGED
|
@@ -35,8 +35,10 @@ _For a working example see one of the following demos:_
|
|
|
35
35
|
|
|
36
36
|
- [autohide map](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hidden-map.html)
|
|
37
37
|
- [autohide chart](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_hidden-chart.html)
|
|
38
|
+
- [clear button](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_clear-button.html)
|
|
38
39
|
- [collapsible button](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_close-button.html)
|
|
39
40
|
- [custom summary](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_custom-summary.html)
|
|
41
|
+
- [edge scale control](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_edge-scale.html)
|
|
40
42
|
- [follow marker](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_follow-marker.html)
|
|
41
43
|
- [layer almostover](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_almost-over.html)
|
|
42
44
|
- [slope chart](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_slope-chart.html)
|
|
@@ -153,6 +155,9 @@ _For a working example see one of the following demos:_
|
|
|
153
155
|
|
|
154
156
|
// Toggle "leaflet-distance-markers" integration
|
|
155
157
|
distanceMarkers: false,
|
|
158
|
+
|
|
159
|
+
// Toggle "leaflet-edgescale" integration
|
|
160
|
+
edgeScale: false,
|
|
156
161
|
|
|
157
162
|
// Toggle "leaflet-hotline" integration
|
|
158
163
|
hotline: true,
|
|
@@ -195,19 +200,19 @@ _For a working example see one of the following demos:_
|
|
|
195
200
|
|
|
196
201
|
### Build Guide
|
|
197
202
|
|
|
198
|
-
|
|
203
|
+
Within your local development environment:
|
|
199
204
|
|
|
200
205
|
```shell
|
|
201
206
|
git clone git@github.com:Raruto/leaflet-elevation.git
|
|
202
207
|
cd ./leaflet-elevation
|
|
203
208
|
|
|
204
209
|
npm i # install dependencies
|
|
205
|
-
npm run
|
|
210
|
+
npm run dev # start dev server at: http://localhost:8080
|
|
206
211
|
npm run build # generate "dist" files (once)
|
|
207
|
-
npm run test # test "spec" files (once)
|
|
212
|
+
npm run test # test all ".*spec.js" files (once)
|
|
208
213
|
```
|
|
209
214
|
|
|
210
|
-
After that you can start developing inside the `src` and `test` folders (eg. open "http://localhost/
|
|
215
|
+
After that you can start developing inside the `src` and `test` folders (eg. open "http://localhost:8080/test" in your browser to preview changes). Check also [CONTRIBUTING.md](.github/CONTRIBUTING.md) file for some information about it.
|
|
211
216
|
|
|
212
217
|
### FAQ
|
|
213
218
|
|
|
@@ -166,39 +166,39 @@
|
|
|
166
166
|
var _ = /*#__PURE__*/Object.freeze({
|
|
167
167
|
__proto__: null,
|
|
168
168
|
Colors: Colors,
|
|
169
|
-
formatTime: formatTime,
|
|
170
|
-
formatDate: formatDate,
|
|
171
|
-
saveFile: saveFile,
|
|
172
|
-
drawCanvas: drawCanvas,
|
|
173
|
-
coordPropsToMeta: coordPropsToMeta,
|
|
174
|
-
parseNumeric: parseNumeric,
|
|
175
|
-
parseDate: parseDate,
|
|
176
169
|
addClass: addClass,
|
|
177
|
-
removeClass: removeClass,
|
|
178
|
-
toggleClass: toggleClass,
|
|
179
|
-
replaceClass: replaceClass,
|
|
180
|
-
style: style,
|
|
181
|
-
toggleStyle: toggleStyle,
|
|
182
|
-
setAttributes: setAttributes,
|
|
183
|
-
toggleEvent: toggleEvent,
|
|
184
|
-
create: create,
|
|
185
170
|
append: append,
|
|
186
|
-
|
|
187
|
-
|
|
171
|
+
clamp: clamp,
|
|
172
|
+
coordPropsToMeta: coordPropsToMeta,
|
|
173
|
+
create: create,
|
|
174
|
+
drawCanvas: drawCanvas,
|
|
188
175
|
each: each,
|
|
189
|
-
|
|
176
|
+
formatDate: formatDate,
|
|
177
|
+
formatTime: formatTime,
|
|
178
|
+
hasClass: hasClass,
|
|
179
|
+
iAvg: iAvg,
|
|
190
180
|
iMax: iMax,
|
|
191
181
|
iMin: iMin,
|
|
192
|
-
iAvg: iAvg,
|
|
193
182
|
iSum: iSum,
|
|
194
|
-
|
|
183
|
+
insert: insert,
|
|
195
184
|
off: off,
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
185
|
+
on: on,
|
|
186
|
+
parseDate: parseDate,
|
|
187
|
+
parseNumeric: parseNumeric,
|
|
188
|
+
randomId: randomId,
|
|
189
|
+
removeClass: removeClass,
|
|
190
|
+
replaceClass: replaceClass,
|
|
199
191
|
round: round,
|
|
200
|
-
|
|
201
|
-
|
|
192
|
+
saveFile: saveFile,
|
|
193
|
+
select: select,
|
|
194
|
+
setAttributes: setAttributes,
|
|
195
|
+
style: style,
|
|
196
|
+
throttle: throttle,
|
|
197
|
+
toggleClass: toggleClass,
|
|
198
|
+
toggleEvent: toggleEvent,
|
|
199
|
+
toggleStyle: toggleStyle,
|
|
200
|
+
wrapDelta: wrapDelta,
|
|
201
|
+
wrapNum: wrapNum
|
|
202
202
|
});
|
|
203
203
|
|
|
204
204
|
var Options = {
|
|
@@ -215,6 +215,7 @@
|
|
|
215
215
|
dragging: !L.Browser.mobile,
|
|
216
216
|
downloadLink: 'link',
|
|
217
217
|
elevationDiv: "#elevation-div",
|
|
218
|
+
edgeScale: { bar: true, icon: false, coords: false },
|
|
218
219
|
followMarker: true,
|
|
219
220
|
imperial: false,
|
|
220
221
|
legend: true,
|
|
@@ -290,7 +291,7 @@
|
|
|
290
291
|
}
|
|
291
292
|
|
|
292
293
|
// Prevent CORS issues for relative locations (dynamic import)
|
|
293
|
-
const baseURL = ((document.currentScript && document.currentScript.src) || (({ url: (typeof document === 'undefined' && typeof location === 'undefined' ?
|
|
294
|
+
const baseURL = ((document.currentScript && document.currentScript.src) || (({ url: (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('leaflet-elevation.js', document.baseURI).href)) }) && (typeof document === 'undefined' && typeof location === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : typeof document === 'undefined' ? location.href : (document.currentScript && document.currentScript.src || new URL('leaflet-elevation.js', document.baseURI).href)))).split("/").slice(0,-1).join("/") + '/';
|
|
294
295
|
|
|
295
296
|
const Elevation = L.Control.Elevation = L.Control.extend({
|
|
296
297
|
|
|
@@ -305,6 +306,7 @@
|
|
|
305
306
|
__LALMOSTOVER: 'https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js',
|
|
306
307
|
__LHOTLINE: '../libs/leaflet-hotline.min.js',
|
|
307
308
|
__LDISTANCEM: '../libs/leaflet-distance-marker.min.js',
|
|
309
|
+
__LEDGESCALE: '../libs/leaflet-edgescale.min.js',
|
|
308
310
|
__LCHART: '../src/components/chart.js',
|
|
309
311
|
__LMARKER: '../src/components/marker.js',
|
|
310
312
|
__LSUMMARY: '../src/components/summary.js',
|
|
@@ -456,7 +458,10 @@
|
|
|
456
458
|
*/
|
|
457
459
|
initialize: function(opts) {
|
|
458
460
|
|
|
459
|
-
opts = L.setOptions(this, opts);
|
|
461
|
+
// opts = L.setOptions(this, opts);
|
|
462
|
+
|
|
463
|
+
// Fixes: https://github.com/Raruto/leaflet-elevation/pull/240
|
|
464
|
+
opts = L.setOptions(this, L.extend({}, structuredClone(Options), opts)); // "deep copy" nested objects (multiple charts)
|
|
460
465
|
|
|
461
466
|
this._data = [];
|
|
462
467
|
this._layers = L.featureGroup();
|
|
@@ -501,6 +506,7 @@
|
|
|
501
506
|
case this.__LGEOMUTIL: condition = typeof L.GeometryUtil !== 'object'; break;
|
|
502
507
|
case this.__LALMOSTOVER: condition = typeof L.Handler.AlmostOver !== 'function'; break;
|
|
503
508
|
case this.__LDISTANCEM: condition = typeof L.DistanceMarkers !== 'function'; break;
|
|
509
|
+
case this.__LEDGESCALE: condition = typeof L.Control.EdgeScale !== 'function'; break;
|
|
504
510
|
case this.__LHOTLINE: condition = typeof L.Hotline !== 'function'; break;
|
|
505
511
|
}
|
|
506
512
|
src = (src.startsWith('../') || src.startsWith('./') ? baseURL : '') + src;
|
|
@@ -703,6 +709,16 @@
|
|
|
703
709
|
return this.options.distanceMarkers ? Promise.all([this.import(this.__LGEOMUTIL), this.import(this.__LDISTANCEM)]) : Promise.resolve();
|
|
704
710
|
},
|
|
705
711
|
|
|
712
|
+
/**
|
|
713
|
+
* Initialize "L.Control.EdgeScale" integration
|
|
714
|
+
*/
|
|
715
|
+
_initEdgeScale: function(map) {
|
|
716
|
+
return this.options.edgeScale ? Promise.all([this.import(this.__LEDGESCALE)])
|
|
717
|
+
.then(() => {
|
|
718
|
+
map.edgeScaleControl = map.edgeScaleControl || L.control.edgeScale('boolean' !== typeof this.options.edgeScale ? this.options.edgeScale : {}).addTo(map);
|
|
719
|
+
}) : Promise.resolve();
|
|
720
|
+
},
|
|
721
|
+
|
|
706
722
|
_initHotLine: function(layer) {
|
|
707
723
|
let prop = typeof this.options.hotline == 'string' ? this.options.hotline : 'elevation';
|
|
708
724
|
return this.options.hotline ? this.import(this.__LHOTLINE)
|
|
@@ -748,6 +764,7 @@
|
|
|
748
764
|
this._initHotLine(layer),
|
|
749
765
|
this._initAlmostOverHandler(map, layer),
|
|
750
766
|
this._initDistanceMarkers(),
|
|
767
|
+
this._initEdgeScale(map),
|
|
751
768
|
]).then(() => {
|
|
752
769
|
if (this.options.polyline) {
|
|
753
770
|
layer.addTo(map);
|