@raruto/leaflet-elevation 2.7.1 → 2.7.2

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 CHANGED
@@ -27,6 +27,7 @@ _For a working example see one of the following demos:_
27
27
  - [stacking multiple charts (elevation, slope, speed)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_multiple-charts.html)
28
28
  - [translating plugin labels](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_i18n-strings.html)
29
29
  - [rotating chart labels](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_chart_labels.html)
30
+ - [updating a track continuously (live tracking)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_live-tracking.html)
30
31
  - [using custom colors](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_custom-theme.html)
31
32
  - [using .gpx extensions (cadence, heart, pace)](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_extended-ui.html)
32
33
  - [using .gpx waypoint icons](https://raruto.github.io/leaflet-elevation/examples/leaflet-elevation_gpx-waypoints.html)
@@ -214,7 +215,7 @@ cd ./leaflet-elevation
214
215
  npm i # install dependencies
215
216
  npm run dev # start dev server at: http://localhost:8080
216
217
  npm run build # generate "dist" files (once)
217
- npm run test # test all "*.spec.js" files (once)
218
+ npm test # run all cucumber tests
218
219
  ```
219
220
 
220
221
  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.
package/cucumber.mjs ADDED
@@ -0,0 +1,5 @@
1
+ export default {
2
+ paths: ['test/features/**/*.feature'],
3
+ import: ['test/support/**/*.js', 'test/steps/**/*.js'],
4
+ format: ['progress'],
5
+ };
@@ -306,15 +306,14 @@
306
306
  * Add data to the diagram either from GPX or GeoJSON and update the axis domain and data
307
307
  */
308
308
  addData(d, layer) {
309
- this.import(this.__D3).then(() => {
310
- if (this._modulesLoaded) {
311
- layer = layer ?? (d.on && d);
312
- this._addData(d);
313
- this._addLayer(layer);
314
- this._fireEvt("eledata_added", { data: d, layer, track_info: this.track_info });
315
- } else {
316
- this.once("modules_loaded", () => this.addData(d, layer));
309
+ return this.import(this.__D3).then(() => {
310
+ if (!this._modulesLoaded) {
311
+ return new Promise((resolve) => this.once("modules_loaded", () => resolve(this.addData(d, layer))));
317
312
  }
313
+ layer = layer ?? (d.on && d);
314
+ this._addData(d);
315
+ this._addLayer(layer);
316
+ this._fireEvt("eledata_added", { data: d, layer, track_info: this.track_info });
318
317
  });
319
318
  },
320
319
  /**
@@ -501,7 +500,7 @@
501
500
  onAdd(map) {
502
501
  this._map = map;
503
502
  let container = this._container = create("div", "elevation-control " + this.options.theme + " " + (this.options.detached ? "elevation-detached" : "leaflet-control"), this.options.detached ? { id: "elevation-" + randomId() } : {});
504
- if (!this.eleDiv) this.eleDiv = container;
503
+ this.eleDiv = container;
505
504
  this._loadModules(this.options.handlers).then(() => {
506
505
  this._initChart(container);
507
506
  this._initButton(container);
@@ -732,7 +731,7 @@
732
731
  _fillStroke(ctx, layer) {
733
732
  if (control._layers.hasLayer(layer)) {
734
733
  let options = layer.options;
735
- options.color = color.line || color.area || theme;
734
+ options.color = control._chartEnabled ? color.line || color.area || theme : "#000";
736
735
  options.stroke = !!options.color;
737
736
  oldProto.call(this, ctx, layer);
738
737
  if (options.stroke && options.weight !== 0) {
@@ -789,7 +788,7 @@
789
788
  * Hides the position/height indicator marker drawn onto the map
790
789
  */
791
790
  _hideMarker() {
792
- if (this.options.autohideMarker) {
791
+ if (this.options.autohideMarker && this._marker) {
793
792
  this._marker.remove();
794
793
  }
795
794
  },
@@ -823,6 +822,7 @@
823
822
  this.on("eledata_added eledata_loaded", this._updateChart, this).on("eledata_added eledata_loaded", this._updateSummary, this);
824
823
  this._updateChart();
825
824
  this._updateSummary();
825
+ map.invalidateSize();
826
826
  });
827
827
  },
828
828
  _initLayer() {
@@ -905,6 +905,7 @@
905
905
  _loadLayer(geojson) {
906
906
  let { polyline, theme, waypoints, wptIcons, wptLabels, distanceMarkers } = this.options;
907
907
  let style2 = L.extend({}, polyline);
908
+ let dataAdded = [];
908
909
  if (theme) {
909
910
  style2.className += " " + theme;
910
911
  }
@@ -934,9 +935,9 @@
934
935
  }
935
936
  }
936
937
  },
937
- onEachFeature: (feature, layer2) => feature.geometry && feature.geometry.type != "Point" && this.addData(feature, layer2)
938
+ onEachFeature: (feature, layer2) => feature.geometry && feature.geometry.type != "Point" && dataAdded.push(this.addData(feature, layer2))
938
939
  });
939
- this.import(this.__D3).then(() => {
940
+ this.import(this.__D3).then(() => Promise.all(dataAdded)).then(() => {
940
941
  this._initMapIntegrations(layer);
941
942
  const event_data = { data: geojson, layer, name: this.track_info.name, track_info: this.track_info };
942
943
  if (this._modulesLoaded) {
@@ -1020,7 +1021,10 @@
1020
1021
  */
1021
1022
  _onToggleChart({ name, enabled }) {
1022
1023
  this._chartEnabled = this._chart._hasActiveLayers();
1023
- this._layers.eachLayer((layer) => toggleClass(layer.getElement && layer.getElement(), this.options.polyline.className + " " + this.options.theme, this._chartEnabled));
1024
+ this._layers.eachLayer((layer) => {
1025
+ toggleClass(layer.getElement && layer.getElement(), this.options.polyline.className + " " + this.options.theme, this._chartEnabled);
1026
+ if (layer._renderer instanceof L.Canvas) layer.redraw();
1027
+ });
1024
1028
  this.options[name] = !enabled && this.options[name] == "disabled" ? "enabled" : "disabled";
1025
1029
  if (!this._chartEnabled) {
1026
1030
  this._chart._hideDiagramIndicator();
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/utils.js", "../src/options.js", "../src/control.js", "../src/index.js"],
4
- "sourcesContent": ["/**\n * TODO: exget computed styles of theese values from actual \"CSS vars\"\n **/\nexport const Colors = {\n\t'lightblue': { area: '#3366CC', alpha: 0.45, stroke: '#3366CC' },\n\t'magenta' : { area: '#FF005E' },\n\t'yellow' : { area: '#FF0' },\n\t'purple' : { area: '#732C7B' },\n\t'steelblue': { area: '#4682B4' },\n\t'red' : { area: '#F00' },\n\t'lime' : { area: '#9CC222', line: '#566B13' }\n};\n\nconst SEC = 1000;\nconst MIN = SEC * 60;\nconst HOUR = MIN * 60;\nconst DAY = HOUR * 24;\n\nexport function resolveURL(src, baseUrl) {\n\treturn (new URL(src, (src.startsWith('../') || src.startsWith('./')) ? baseUrl : undefined)).toString()\n};\n\n/**\n * Convert a time (millis) to a human readable duration string (%Dd %H:%M'%S\")\n */\nexport function formatTime(t) {\n\tlet d = Math.floor(t / DAY);\n\tlet h = Math.floor( (t - d * DAY) / HOUR);\n\tlet m = Math.floor( (t - d * DAY - h * HOUR) / MIN);\n\tlet s = Math.round( (t - d * DAY - h * HOUR - m * MIN) / SEC);\n\tif ( s === 60 ) { m++; s = 0; }\n\tif ( m === 60 ) { h++; m = 0; }\n\tif ( h === 24 ) { d++; h = 0; }\n\treturn (d ? d + \"d \" : '') + h.toString().padStart(2, 0) + ':' + m.toString().padStart(2, 0) + \"'\" + s.toString().padStart(2, 0) + '\"';\n}\n\n/**\n * Convert a time (millis) to human readable date string (dd-mm-yyyy hh:mm:ss)\n */\n export function formatDate(format) {\n\tif (!format) {\n\t\treturn (time) => (new Date(time)).toLocaleString().replaceAll('/', '-').replaceAll(',', ' ');\n\t} else if (format == 'time') {\n\t\treturn (time) => (new Date(time)).toLocaleTimeString();\n\t} else if (format == 'date') {\n\t\treturn (time) => (new Date(time)).toLocaleDateString();\n\t}\n\treturn (time) => format(time);\n}\n\n/**\n * Generate download data event.\n */\n export function saveFile(dataURI, fileName) {\n\tlet a = create('a', '', { href: dataURI, target: '_new', download: fileName || \"\", style: \"display:none;\" });\n\tlet b = document.body;\n\tb.appendChild(a);\n\ta.click();\n\tb.removeChild(a);\n}\n\n\n/**\n * Convert SVG Path into Path2D and then update canvas\n */\n export function drawCanvas(ctx, path) {\n\tpath.classed('canvas-path', true);\n\n\tctx.beginPath();\n\tctx.moveTo(0, 0);\n\tlet p = new Path2D(path.attr('d'));\n\n\tctx.strokeStyle = path.__strokeStyle || path.attr('stroke');\n\tctx.fillStyle = path.__fillStyle || path.attr('fill');\n\tctx.lineWidth = 1.25;\n\tctx.globalCompositeOperation = 'source-over';\n\n\t// stroke opacity\n\tctx.globalAlpha = path.attr('stroke-opacity') || 0.3;\n\tctx.stroke(p);\n\n\t// fill opacity\n\tctx.globalAlpha = path.attr('fill-opacity') || 0.45;\n\tctx.fill(p);\n\n\tctx.globalAlpha = 1;\n\n\tctx.closePath();\n}\n\n/**\n * Loop and extract GPX Extensions handled by \"@tmcw/toGeoJSON\" (eg. \"coordinateProperties\" > \"times\")\n */\nexport function coordPropsToMeta(coordProps, name, parser) {\n\treturn coordProps && (({props, point, id, isMulti }) => {\n\t\tif (props) {\n\t\t\tfor (const key of coordProps) {\n\t\t\t\tif (key in props) {\n\t\t\t\t\tpoint.meta[name] = (parser || parseNumeric).call(this, (isMulti ? props[key][isMulti] : props[key]), id);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n}\n\n/**\n * Extract numeric property (id) from GeoJSON object\n */\nexport const parseNumeric = (property, id) => parseInt((typeof property === 'object' ? property[id] : property));\n\n/**\n * Extract datetime property (id) from GeoJSON object\n */\nexport const parseDate = (property, id) => new Date(Date.parse((typeof property === 'object' ? property[id] : property)));\n\n/**\n * A little bit shorter than L.DomUtil\n */\nexport const addClass = (n, str) => n && str.split(\" \").every(s => s && L.DomUtil.addClass(n, s));\nexport const removeClass = (n, str) => n && str.split(\" \").every(s => s && L.DomUtil.removeClass(n, s));\nexport const toggleClass = (n, str, cond) => (cond ? addClass : removeClass)(n, str);\nexport const replaceClass = (n, rem, add) => (rem && removeClass(n, rem)) || (add && addClass(n, add));\nexport const style = (n, k, v) => (typeof v === \"undefined\" && L.DomUtil.getStyle(n, k)) || n.style.setProperty(k, v);\nexport const toggleStyle = (n, k, v, cond) => style(n, k, cond ? v : '');\nexport const setAttributes = (n, attrs) => { for (let k in attrs) { n.setAttribute(k, attrs[k]); } };\nexport const toggleEvent = (el, e, fn, cond) => el[cond ? 'on' : 'off'](e, fn);\nexport const create = (tag, str, attrs, n) => { let elem = L.DomUtil.create(tag, str || \"\"); if (attrs) setAttributes(elem, attrs); if (n) append(n, elem); return elem; };\nexport const append = (n, c) => n.appendChild(c);\nexport const insert = (n, c, pos) => n.insertAdjacentElement(pos, c);\nexport const select = (str, n) => (n || document).querySelector(str);\nexport const each = (obj, fn) => { for (let i in obj) fn(obj[i], i); };\nexport const randomId = () => Math.random().toString(36).substr(2, 9);\n\n/**\n * TODO: use generators instead? (ie. \"yield\")\n */\nexport const iMax = (iVal, max = -Infinity) => (iVal > max ? iVal : max); \nexport const iMin = (iVal, min = +Infinity) => (iVal < min ? iVal : min);\nexport const iAvg = (iVal, avg = 0, idx = 1) => (iVal + avg * (idx - 1)) / idx;\nexport const iSum = (iVal, sum = 0) => iVal + sum;\n\n/**\n * Alias for some leaflet core functions\n */\nexport const { on, off } = L.DomEvent;\nexport const { throttle, wrapNum } = L.Util;\nexport const { hasClass } = L.DomUtil;\n\n/**\n * Limit floating point precision\n */\nexport const round = L.Util.formatNum;\n\n/**\n * Limit a number between min / max values\n */\nexport const clamp = (val, range) => range ? (val < range[0] ? range[0] : val > range[1] ? range[1] : val) : val;\n\n/**\n * Limit a delta difference between two values\n */\nexport const wrapDelta = (curr, prev, deltaMax) => Math.abs(curr - prev) > deltaMax ? prev + deltaMax * Math.sign(curr - prev) : curr;\n\n/**\n * A deep copy implementation that takes care of correct prototype chain and cycles, references\n * \n * @see https://web.dev/structured-clone/#features-and-limitations\n */\nexport function cloneDeep(o, skipProps = [], cache = []) {\n\tswitch(!o || typeof o) {\n\t\tcase 'object':\n\t\t\tconst hit = cache.filter(c => o === c.original)[0];\n\t\t\tif (hit) return hit.copy; // handle circular structures\n\t\t\tconst copy = Array.isArray(o) ? [] : Object.create(Object.getPrototypeOf(o));\n\t\t\tcache.push({ original: o, copy });\n\t\t\tObject\n\t\t\t\t.getOwnPropertyNames(o)\n\t\t\t\t.forEach(function (prop) {\n\t\t\t\t\tconst propdesc = Object.getOwnPropertyDescriptor(o, prop);\n\t\t\t\t\tObject.defineProperty(\n\t\t\t\t\t\tcopy,\n\t\t\t\t\t\tprop,\n\t\t\t\t\t\tpropdesc.get || propdesc.set\n\t\t\t\t\t\t\t? propdesc // just copy accessor properties\n\t\t\t\t\t\t\t: { // deep copy data properties\n\t\t\t\t\t\t\t\twritable: propdesc.writable,\n\t\t\t\t\t\t\t\tconfigurable: propdesc.configurable,\n\t\t\t\t\t\t\t\tenumerable: propdesc.enumerable,\n\t\t\t\t\t\t\t\tvalue: skipProps.includes(prop) ? propdesc.value : cloneDeep(propdesc.value, skipProps, cache),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\treturn copy;\n\t\tcase 'function':\n\t\tcase 'symbol':\n\t\t\tconsole.warn('cloneDeep: ' + typeof o + 's not fully supported:', o);\n\t\tcase true:\n\t\t\t// null, undefined or falsy primitive\n\t\tdefault:\n\t\t\treturn o;\n\t}\n}", "import * as _ from './utils';\n\nexport var Options = {\n\tautofitBounds: true,\n\tautohide: false,\n\tautohideMarker: true,\n\talmostover: true,\n\taltitude: true,\n\tcloseBtn: true,\n\tcollapsed: false,\n\tdetached: true,\n\tdistance: true,\n\tdistanceMarkers: { lazy: true, distance: true, direction: true },\n\tdragging: !L.Browser.mobile,\n\tdownloadLink: 'link',\n\televationDiv: \"#elevation-div\",\n\tedgeScale: { bar: true, icon: false, coords: false },\n\tfollowMarker: true,\n\timperial: false,\n\tlegend: true,\n\thandlers: [\"Distance\", \"Time\", \"Altitude\", \"Slope\", \"Speed\", \"Acceleration\"],\n\thotline: 'elevation',\n\tmarker: 'elevation-line',\n\tmarkerIcon: L.divIcon({\n\t\tclassName: 'elevation-position-marker',\n\t\thtml: '<i class=\"elevation-position-icon\"></i>',\n\t\ticonSize: [32, 32],\n\t\ticonAnchor: [16, 16],\n\t}),\n\tposition: \"topright\",\n\tpolyline: {\n\t\tclassName: 'elevation-polyline',\n\t\tcolor: '#000',\n\t\topacity: 0.75,\n\t\tweight: 5,\n\t\tlineCap: 'round'\n\t},\n\tpolylineSegments: {\n\t\tclassName: 'elevation-polyline-segments',\n\t\tcolor: '#F00',\n\t\tinteractive: false,\n\t},\n\tpreferCanvas: false,\n\treverseCoords: false,\n\truler: true,\n\ttheme: \"lightblue-theme\",\n\tsummary: 'inline',\n\tslope: false,\n\tspeed: false,\n\ttime: true,\n\ttimeFactor: 3600,\n\ttimestamps: false,\n\ttrkStart: { className: 'start-marker', radius: 6, weight: 2, color: '#fff', fillColor: '#00d800', fillOpacity: 1, interactive: false },\n\ttrkEnd: { className: 'end-marker', radius: 6, weight: 2, color: '#fff', fillColor: '#ff0606', fillOpacity: 1, interactive: false },\n\twaypoints: true,\n\twptIcons: {\n\t\t'': L.divIcon({\n\t\t\tclassName: 'elevation-waypoint-marker',\n\t\t\thtml: '<i class=\"elevation-waypoint-icon default\"></i>',\n\t\t\ticonSize: [30, 30],\n\t\t\ticonAnchor: [8, 30],\n\t\t}),\n\t},\n\twptLabels: true,\n\txAttr: \"dist\",\n\txLabel: \"km\",\n\tyAttr: \"z\",\n\tyLabel: \"m\",\n\tzFollow: false,\n\tzooming: !L.Browser.Mobile,\n\n\t// Quite uncommon and undocumented options\n\tmargins: { top: 30, right: 30, bottom: 30, left: 40 },\n\theight: (screen.height * 0.3) || 200,\n\twidth: (screen.width * 0.6) || 600,\n\txTicks: undefined,\n\tyTicks: undefined,\n\n\tdecimalsX: 2,\n\tdecimalsY: 0,\n\tforceAxisBounds: false,\n\tinterpolation: \"curveLinear\",\n\tyAxisMax: undefined,\n\tyAxisMin: undefined,\n\n\t// Prevent CORS issues for relative locations (dynamic import)\n\tsrcFolder: ((document.currentScript && document.currentScript.src) || (import.meta && import.meta.url) || document.baseURI).split(\"/\").slice(0,-1).join(\"/\") + '/',\n};\n", "import * as _ from './utils';\nimport { Options } from './options';\n\n// \"leaflet-i18n\" fallback\nif (!L._ || !L.i18n) {\n\tL._ = L.i18n = (string, data) => string;\n}\n\nexport const Elevation = L.Control.Elevation = L.Control.extend({\n\n\tincludes: L.Evented ? L.Evented.prototype : L.Mixin.Events,\n\n\toptions: Options,\n\t__mileFactor: 0.621371, // 1 km = (0.621371 mi)\n\t__footFactor: 3.28084, // 1 m = (3.28084 ft)\n\t__D3: 'https://unpkg.com/d3@7.8.4/dist/d3.min.js',\n\t__TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@5.6.2/dist/togeojson.umd.js',\n\t__LGEOMUTIL: 'https://unpkg.com/leaflet-geometryutil@0.10.1/src/leaflet.geometryutil.js',\n\t__LALMOSTOVER: 'https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js',\n\t__LHOTLINE: '../libs/leaflet-hotline.min.js',\n\t__LDISTANCEM: '../libs/leaflet-distance-marker.min.js',\n\t__LEDGESCALE: '../libs/leaflet-edgescale.min.js',\n\t__LCHART: '../src/components/chart.js',\n\t__LMARKER: '../src/components/marker.js',\n\t__LSUMMARY: '../src/components/summary.js',\n\t__modulesFolder: '../src/handlers/',\n\t__btnIcon: '../images/elevation.svg',\n\n\t/*\n\t * Add data to the diagram either from GPX or GeoJSON and update the axis domain and data\n\t */\n\taddData(d, layer) {\n\t\tthis.import(this.__D3)\n\t\t\t.then(() => {\n\t\t\t\tif (this._modulesLoaded) {\n\t\t\t\t\tlayer = layer ?? (d.on && d);\n\t\t\t\t\tthis._addData(d);\n\t\t\t\t\tthis._addLayer(layer);\n\t\t\t\t\tthis._fireEvt(\"eledata_added\", { data: d, layer: layer, track_info: this.track_info });\n\t\t\t\t} else {\n\t\t\t\t\tthis.once('modules_loaded', () => this.addData(d,layer));\n\t\t\t\t}\n\t\t\t});\n\t},\n\n\t/**\n\t * Adds the control to the given map.\n\t */\n\taddTo(map) {\n\t\tif (this.options.detached) {\n\t\t\tlet parent = _.select(this.options.elevationDiv);\n\t\t\tlet eleDiv = this.onAdd(map);\n\t\t\tparent ? _.append(parent, eleDiv) : _.insert(map.getContainer(), eleDiv, 'afterend');\n\t\t} else {\n\t\t\tL.Control.prototype.addTo.call(this, map);\n\t\t}\n\t\treturn this;\n\t},\n\n\t/*\n\t * Reset data and display\n\t */\n\tclear() {\n\t\tif (this._marker) this._marker.remove();\n\t\tif (this._chart) this._clearChart();\n\t\tif (this._layers) this._clearLayers(this._layers);\n\t\tif (this._markers) this._clearLayers(this._markers);\n\t\tif (this._circleMarkers) this._circleMarkers.remove();\n\t\tif (this._hotline) this._hotline.eachLayer(l => l.options.renderer.remove()); // hotfix for: https://github.com/Raruto/leaflet-elevation/issues/233\n\t\tif (this._hotline) this._clearLayers(this._hotline);\n\n\t\tthis._data = [];\n\t\tthis.track_info = {};\n\t\tthis._yCoordMin = 0;\n\t\tthis._yCoordMax = -Infinity;\n\n\t\tthis._fireEvt(\"eledata_clear\");\n\n\t\tthis._updateChart();\n\t},\n\n\t_clearChart() {\n\t\tif (this._events && this._events.elechart_updated) {\n\t\t\tthis._events.elechart_updated.forEach(({fn, ctx}) => this.off('elechart_updated', fn, ctx));\n\t\t}\n\t\tif (this._chart && this._chart._container) {\n\t\t\tthis._chart._container.selectAll('g.point .point').remove();\n\t\t\tthis._chart.clear();\n\t\t}\n\t},\n\n\t_clearLayers(l) {\n\t\tl = l || this._layers;\n\t\tif (l && l.eachLayer) {\n\t\t\tl.eachLayer(f => f.remove())\n\t\t\tl.clearLayers();\n\t\t}\n\t},\n\n\t/**\n\t * TODO: Create a base class to handle custom data attributes (heart rate, cadence, temperature, ...)\n\t * \n\t * @link https://leafletjs.com/examples/extending/extending-3-controls.html#handlers\n\t */\n\t// addHandler: function (name, HandlerClass) {\n\t// \tif (HandlerClass) {\n\t// \t\tlet handler = this[name] = new HandlerClass(this);\n\t// \t\tthis.handlers.push(handler);\n\t// \t\tif (this.options[name]) {\n\t// \t\t\thandler.enable();\n\t// \t\t}\n\t// \t}\n\t// \treturn this;\n\t// },\n\n\t/**\n\t * Disable chart brushing.\n\t */\n\tdisableBrush() {\n\t\tthis._chart._brushEnabled = false;\n\t\tthis._resetDrag();\n\t},\n\n\t/**\n\t * Enable chart brushing.\n\t */\n\tenableBrush() {\n\t\tthis._chart._brushEnabled = true;\n\t},\n\n\t/**\n\t * Disable chart zooming.\n\t */\n\tdisableZoom() {\n\t\tthis._chart._zoomEnabled = false;\n\t\tthis._chart._resetZoom();\n\t},\n\n\t/**\n\t * Enable chart zooming.\n\t */\n\tenableZoom() {\n\t\tthis._chart._zoomEnabled = true;\n\t},\n\n\t/**\n\t * Sets a map view that contains the given geographical bounds.\n\t */\n\tfitBounds(bounds) {\n\t\tbounds = bounds || this.getBounds();\n\t\tif (this._map && bounds.isValid()) this._map.fitBounds(bounds);\n\t},\n\n\tgetBounds(data) {\n\t\treturn L.latLngBounds((data || this._data).map((d) => d.latlng));\n\t},\n\n\t/**\n\t * Get default zoom level (followMarker: true).\n\t */\n\tgetZFollow() {\n\t\treturn this.options.zFollow;\n\t},\n\n\t/**\n\t * Hide current elevation chart profile.\n\t */\n\thide() {\n\t\t_.style(this._container, \"display\", \"none\");\n\t},\n\n\t/**\n\t * Initialize chart control \"options\" and \"container\".\n\t */\n\tinitialize(opts) {\n\n\t\t// opts = L.setOptions(this, opts);\n\n\t\t// Fixes: https://github.com/Raruto/leaflet-elevation/pull/240\n\t\topts = L.setOptions(this, L.extend({}, _.cloneDeep(Options), opts)); // \"deep copy\" nested objects (multiple charts)\n\n\t\tthis._data = [];\n\t\tthis._layers = L.featureGroup();\n\t\tthis._markers = L.featureGroup();\n\t\tthis._hotline = L.featureGroup();\n\t\tthis._circleMarkers = L.featureGroup();\n\t\tthis._markedSegments = L.polyline([]);\n\t\tthis._start = L.circleMarker([0,0], (opts.trkStart || Options.trkStart));\n\t\tthis._end = L.circleMarker([0,0], (opts.trkEnd || Options.trkEnd));\n\t\tthis._chartEnabled = true;\n\t\tthis._yCoordMin = 0;\n\t\tthis._yCoordMax = -Infinity;\n\t\tthis.track_info = {};\n\t\t// this.handlers = [];\n\n\t\tif (opts.followMarker) this._setMapView = _.throttle(this._setMapView, 300, this);\n\t\tif (opts.legend) opts.margins.bottom += 30;\n\t\tif (opts.theme) opts.polylineSegments.className += ' ' + opts.theme;\n\t\tif (opts.wptIcons === true) opts.wptIcons = Options.wptIcons;\n\t\tif (opts.distanceMarkers === true) opts.distanceMarkers = Options.distanceMarkers;\n\t\tif (opts.trkStart) this._start.addTo(this._circleMarkers);\n\t\tif (opts.trkEnd) this._end.addTo(this._circleMarkers);\n\n\n\t\tthis._markedSegments.setStyle(opts.polylineSegments);\n\n\t\t// Leaflet canvas renderer colors\n\t\tL.extend(_.Colors, opts.colors || {});\n\n\t\t// Various stuff\n\t\tthis._fixCanvasPaths();\n\t\tthis._fixTooltipSize();\n\n\t},\n\n\t/**\n\t * Javascript scripts downloader (lazy loader)\n\t */\n\timport(src, condition) {\n\t\tif (Array.isArray(src)) {\n\t\t\treturn Promise.all(src.map(m => this.import(m)));\n\t\t}\n\t\tswitch(src) {\n\t\t\tcase this.__D3: condition = typeof d3 !== 'object'; break;\n\t\t\tcase this.__TOGEOJSON: condition = typeof toGeoJSON !== 'object'; break;\n\t\t\tcase this.__LGEOMUTIL: condition = typeof L.GeometryUtil !== 'object'; break;\n\t\t\tcase this.__LALMOSTOVER: condition = typeof L.Handler.AlmostOver !== 'function'; break;\n\t\t\tcase this.__LDISTANCEM: condition = typeof L.DistanceMarkers !== 'function'; break;\n\t\t\tcase this.__LEDGESCALE: condition = typeof L.Control.EdgeScale !== 'function'; break;\n\t\t\tcase this.__LHOTLINE: condition = typeof L.Hotline !== 'function'; break;\n\t\t}\n\t\treturn condition !== false ? import(_.resolveURL(src, this.options.srcFolder)) : Promise.resolve();\n\t},\n\n\t/**\n\t * Load elevation data (GPX, GeoJSON, KML or TCX).\n\t */\n\tload(data) {\n\t\tthis._parseFromString(data).then( geojson => geojson ? this._loadLayer(geojson) : this._loadFile(data));\n\t},\n\n\t/**\n\t * Create container DOM element and related event listeners.\n\t * Called on control.addTo(map).\n\t */\n\tonAdd(map) {\n\t\tthis._map = map;\n\n\t\tlet container = this._container = _.create(\"div\", \"elevation-control \" + this.options.theme + \" \" + (this.options.detached ? 'elevation-detached' : 'leaflet-control'), this.options.detached ? { id: 'elevation-' + _.randomId() } : {});\n\n\t\tif (!this.eleDiv) this.eleDiv = container;\n\n\t\tthis._loadModules(this.options.handlers).then(() => { // Inject here required modules (data handlers)\n\t\t\tthis._initChart(container);\n\t\t\tthis._initButton(container);\n\t\t\tthis._initSummary(container);\n\t\t\tthis._initMarker(map);\n\t\t\tthis._initLayer(map);\n\t\t\tthis._modulesLoaded = true;\n\t\t\tthis.fire('modules_loaded');\n\t\t});\n\n\t\tthis.fire('add');\n\n\t\treturn container;\n\t},\n\n\t/**\n\t * Clean up control code and related event listeners.\n\t * Called on control.remove().\n\t */\n\tonRemove(map) {\n\t\tthis._container = null;\n\n\t\tmap\n\t\t\t.off('zoom viewreset zoomanim', this._hideMarker, this)\n\t\t\t.off('resize', this._resetView, this)\n\t\t\t.off('resize', this._resizeChart, this)\n\t\t\t.off('mousedown', this._resetDrag, this);\n\n\t\t_.off(map.getContainer(), 'mousewheel', this._resetDrag, this);\n\t\t_.off(map.getContainer(), 'touchstart', this._resetDrag, this);\n\t\t_.off(document, 'keydown', this._onKeyDown, this);\n\n\t\tthis\n\t\t\t.off('eledata_added eledata_loaded', this._updateChart, this)\n\t\t\t.off('eledata_added eledata_loaded', this._updateSummary, this);\n\n\t\tthis.fire('remove');\n\t},\n\n\t/**\n\t * Redraws the chart control. Sometimes useful after screen resize.\n\t */\n\tredraw() {\n\t\tthis._resizeChart();\n\t},\n\n\t/**\n\t * Set default zoom level (followMarker: true).\n\t */\n\tsetZFollow(zoom) {\n\t\tthis.options.zFollow = zoom;\n\t},\n\n\t/**\n\t * Hide current elevation chart profile.\n\t */\n\tshow() {\n\t\t_.style(this._container, \"display\", \"block\");\n\t},\n\n\t/*\n\t * Parsing data either from GPX or GeoJSON and update the diagram data\n\t */\n\t_addData(d) {\n\t\tif (!d) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Standard GeoJSON\n\t\tif (d.type === \"FeatureCollection\" ) {\n\t\t\treturn _.each(d.features, feature => this._addData(feature));\n\t\t} else if (d.type === \"Feature\") {\n\t\t\tlet geom = d.geometry;\n\t\t\tif (geom) {\n\t\t\t\tswitch (geom.type) {\n\t\t\t\t\tcase 'LineString':\t\treturn this._addGeoJSONData(geom.coordinates, d.properties);\n\t\t\t\t\tcase 'MultiLineString':\treturn _.each(geom.coordinates, (coords, i) => this._addGeoJSONData(coords, d.properties, i));\n\t\t\t\t\tcase 'Point':\n\t\t\t\t\tdefault:\t\t\t\treturn console.warn('Unsopperted GeoJSON feature geometry type:' + geom.type);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Fallback for leaflet layers (eg. L.Gpx)\n\t\tif (d._latlngs) {\n\t\t\treturn this._addGeoJSONData(d._latlngs, d.feature && d.feature.properties);\n\t\t}\n\n\t},\n\n\t/*\n\t * Parsing of GeoJSON data lines and their elevation in z-coordinate\n\t */\n\t_addGeoJSONData(coords, properties, nestingLevel) {\n\n\t\t// \"coordinateProperties\" property is generated inside \"@tmcw/toGeoJSON\"\n\t\tlet props = (properties && properties.coordinateProperties) || properties;\n\n\t\tcoords.forEach((point, i) => {\n\n\t\t\t// GARMIN_EXTENSIONS = [\"hr\", \"cad\", \"atemp\", \"wtemp\", \"depth\", \"course\", \"bearing\"];\n\t\t\tpoint.meta = point.meta ?? { time: null, ele: null };\n\t\t\t\n\t\t\tpoint.prev = (attr) => (attr ? this._data[i > 0 ? i - 1 : 0][attr] : this._data[i > 0 ? i - 1 : 0]);\n\n\t\t\tthis.fire(\"elepoint_init\", { point: point, props: props, id: i, isMulti: nestingLevel });\n\n\t\t\tthis._addPoint(\n\t\t\t\tpoint.lat ?? point[1], \n\t\t\t\tpoint.lng ?? point[0],\n\t\t\t\tpoint.alt ?? point.meta.ele ?? point[2]\n\t\t\t);\n\n\t\t\tthis.fire(\"elepoint_added\", { point: point, index: this._data.length - 1 });\n\n\t\t\tif (this._yCoordMin > this._data[this._data.length - 1][this.options.yAttr]) this._yCoordMin = this._data[this._data.length - 1][this.options.yAttr];\n\t\t\tif (this._yCoordMax < this._data[this._data.length - 1][this.options.yAttr]) this._yCoordMax = this._data[this._data.length - 1][this.options.yAttr];\n\t\t});\n\n\t\tthis.fire(\"eletrack_added\", { coords: coords, index: this._data.length - 1 });\n\t},\n\n\t/*\n\t * Parse and push a single (x, y, z) point to current elevation profile.\n\t */\n\t_addPoint(x, y, z) {\n\t\tif (this.options.reverseCoords) {\n\t\t\t[x, y] = [y, x];\n\t\t}\n\n\t\tthis._data.push({\n\t\t\tx: x,\n\t\t\ty: y,\n\t\t\tz: z,\n\t\t\tlatlng: L.latLng(x, y, z)\n\t\t});\n\n\t\tthis.fire(\"eledata_updated\", { index: this._data.length - 1 });\n\t},\n\n\t_addLayer(layer) {\n\t\tif (layer) this._layers.addLayer(layer)\n\t\t// Postpone adding the distance markers (lazy: true)\n\t\tif (layer && this.options.distanceMarkers && this.options.distanceMarkers.lazy) {\n\t\t\tlayer.on('add remove', ({target, type}) => L.DistanceMarkers && target instanceof L.Polyline && target[type + 'DistanceMarkers']());\n\t\t}\n\t\treturn layer;\n\t},\n\n\t_addMarker(marker) {\n\t\tif (marker) this._markers.addLayer(marker)\n\t\treturn marker;\n\t},\n\n\t/**\n\t * Initialize \"L.AlmostOver\" integration\n\t */\n\t_initAlmostOverHandler(map, layer) {\n\t\treturn (map && this.options.almostOver && !L.Browser.mobile) ? this.import([this.__LGEOMUTIL, this.__LALMOSTOVER])\n\t\t\t.then(() => {\n\t\t\t\tmap.addHandler('almostOver', L.Handler.AlmostOver)\n\t\t\t\tif (L.GeometryUtil && map.almostOver && map.almostOver.enabled()) {\n\t\t\t\t\tmap.almostOver.addLayer(layer);\n\t\t\t\t\tmap\n\t\t\t\t\t\t.on('almost:move', this._onMouseMoveLayer, this)\n\t\t\t\t\t\t.on('almost:out', this._onMouseOut, this);\n\t\t\t\t\tthis.once('eledata_clear', () => {\n\t\t\t\t\t\tmap.almostOver.removeLayer(layer);\n\t\t\t\t\t\tmap\n\t\t\t\t\t\t.off('almost:move', this._onMouseMoveLayer, this)\n\t\t\t\t\t\t.off('almost:out', this._onMouseOut, this);\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}) : Promise.resolve();\n\t},\n\n\t/**\n\t * Initialize \"L.DistanceMarkers\" integration\n\t */\n\t_initDistanceMarkers() {\n\t\treturn this.options.distanceMarkers ? this.import([this.__LGEOMUTIL, this.__LDISTANCEM]) : Promise.resolve();\n\t},\n\n\t/**\n\t * Initialize \"L.Control.EdgeScale\" integration\n\t */\n\t_initEdgeScale(map) {\n\t\treturn this.options.edgeScale ? this.import(this.__LEDGESCALE)\n\t\t\t.then(() => {\n\t\t\t\tmap.edgeScaleControl = map.edgeScaleControl || L.control.edgeScale('boolean' !== typeof this.options.edgeScale ? this.options.edgeScale : {}).addTo(map);\n\t\t\t}) : Promise.resolve();\n\t},\n\n\t_initHotLine(layer) {\n\t\tlet prop = typeof this.options.hotline == 'string' ? this.options.hotline : 'elevation';\n\t\treturn this.options.hotline ? this.import(this.__LHOTLINE)\n\t\t\t.then(() => {\n\t\t\t\tlayer.eachLayer((trkseg) => {\n\t\t\t\t\tif (trkseg.feature.geometry.type != \"Point\") {\n\t\t\t\t\t\tlet geo = L.geoJson(trkseg.toGeoJSON(), { coordsToLatLng: (coords) => L.latLng(coords[0], coords[1], coords[2] * (this.options.altitudeFactor || 1))});\n\t\t\t\t\t\tlet line = L.hotline(geo.toGeoJSON().features[0].geometry.coordinates, {\n\t\t\t\t\t\t\trenderer: L.Hotline.renderer(),\n\t\t\t\t\t\t\tmin: isFinite(this.track_info[prop + '_min']) ? this.track_info[prop + '_min'] : 0,\n\t\t\t\t\t\t\tmax: isFinite(this.track_info[prop + '_max']) ? this.track_info[prop + '_max'] : 1,\n\t\t\t\t\t\t\tpalette: {\n\t\t\t\t\t\t\t\t0.0: '#008800',\n\t\t\t\t\t\t\t\t0.5: '#ffff00',\n\t\t\t\t\t\t\t\t1.0: '#ff0000'\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tweight: 5,\n\t\t\t\t\t\t\toutlineColor: '#000000',\n\t\t\t\t\t\t\toutlineWidth: 1\n\t\t\t\t\t\t}).addTo(this._hotline);\n\t\t\t\t\t\tlet alpha = trkseg.options.style && trkseg.options.style.opacity || 1;\n\t\t\t\t\t\ttrkseg.on('add remove', ({type}) => {\n\t\t\t\t\t\t\ttrkseg.setStyle({opacity: (type == 'add' ? 0 : alpha)});\n\t\t\t\t\t\t\tline[(type == 'add' ? 'addTo' : 'removeFrom')](trkseg._map);\n\t\t\t\t\t\t\tif (line._renderer) line._renderer._container.parentElement.insertBefore(line._renderer._container, line._renderer._container.parentElement.firstChild);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}) : Promise.resolve();\n\t},\n\n\t/**\n\t * Initialize \"L.AlmostOver\" and \"L.DistanceMarkers\"\n\t */\n\t_initMapIntegrations(layer) {\n\t\tlet map = this._map;\n\t\tif (map) {\n\t\t\tif (this._data.length) {\n\t\t\t\tthis._start.setLatLng(this._data[0].latlng);\n\t\t\t\tthis._end.setLatLng(this._data[this._data.length -1].latlng);\n\t\t\t}\n\t\t\tPromise.all([\n\t\t\t\tthis._initHotLine(layer),\n\t\t\t\tthis._initAlmostOverHandler(map, layer),\n\t\t\t\tthis._initDistanceMarkers(),\n\t\t\t\tthis._initEdgeScale(map),\n\t\t\t]).then(() => {\n\t\t\t\tif (this.options.polyline) {\n\t\t\t\t\tthis._layers.addLayer(layer.addTo(map)); // hotfix for: https://github.com/Raruto/leaflet-elevation/issues/233\n\t\t\t\t\tthis._circleMarkers.addTo(map);\n\t\t\t\t}\n\t\t\t\tif (this.options.autofitBounds) {\n\t\t\t\t\tthis.fitBounds(layer.getBounds());\n\t\t\t\t}\n\t\t\t\tmap.invalidateSize();\n\t\t\t});\n\t\t} else {\n\t\t\tthis.once('add', () => this._initMapIntegrations(layer));\n\t\t}\n\t},\n\n\t/*\n\t * Collapse current chart control.\n\t */\n\t_collapse() {\n\t\t_.replaceClass(this._container, 'elevation-expanded', 'elevation-collapsed');\n\t\tif (this._map) this._map.invalidateSize();\n\t},\n\n\t/*\n\t * Expand current chart control.\n\t */\n\t_expand() {\n\t\t_.replaceClass(this._container, 'elevation-collapsed', 'elevation-expanded');\n\t\tif (this._map) this._map.invalidateSize();\n\t},\n\n\t/**\n\t * Add some basic colors to leaflet canvas renderer (preferCanvas: true).\n\t */\n\t_fixCanvasPaths() {\n\t\tlet oldProto = L.Canvas.prototype._fillStroke;\n\t\tlet control = this;\n\n\t\tlet theme = this.options.theme.split(' ')[0].replace('-theme', '');\n\t\tlet color = _.Colors[theme] || {};\n\n\t\tL.Canvas.include({\n\t\t\t_fillStroke(ctx, layer) {\n\t\t\t\tif (control._layers.hasLayer(layer)) {\n\n\t\t\t\t\tlet options = layer.options;\n\n\t\t\t\t\toptions.color = color.line || color.area || theme;\n\t\t\t\t\toptions.stroke = !!options.color;\n\n\t\t\t\t\toldProto.call(this, ctx, layer);\n\n\t\t\t\t\tif (options.stroke && options.weight !== 0) {\n\t\t\t\t\t\tlet oldVal = ctx.globalCompositeOperation || 'source-over';\n\t\t\t\t\t\tctx.globalCompositeOperation = 'destination-over'\n\t\t\t\t\t\tctx.strokeStyle = color.outline || '#FFF';\n\t\t\t\t\t\tctx.lineWidth = options.weight * 1.75;\n\t\t\t\t\t\tctx.stroke();\n\t\t\t\t\t\tctx.globalCompositeOperation = oldVal;\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\toldProto.call(this, ctx, layer);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t},\n\n\t/**\n\t * Partial fix for initial tooltip size\n\t * \n\t * @link https://github.com/Raruto/leaflet-elevation/issues/81#issuecomment-713477050\n\t */\n\t_fixTooltipSize() {\n\t\tthis.on('elechart_init', () =>\n\t\t\tthis.once('elechart_change elechart_hover', ({data, xCoord}) => {\n\t\t\t\tif (this._chartEnabled) {\n\t\t\t\t\tthis._chart._showDiagramIndicator(data, xCoord);\n\t\t\t\t\tthis._chart._showDiagramIndicator(data, xCoord);\n\t\t\t\t}\n\t\t\t\tthis._updateMarker(data);\n\t\t\t})\n\t\t);\n\t},\n\n\t/*\n\t * Finds a data entry for the given LatLng\n\t */\n\t_findItemForLatLng(latlng) {\n\t\treturn this._data[this._chart._findIndexForLatLng(latlng)];\n\t},\n\n\t/*\n\t * Finds a data entry for the given xDiagCoord\n\t */\n\t_findItemForX(x) {\n\t\treturn this._data[this._chart._findIndexForXCoord(x)];\n\t},\n\n\t/**\n\t * Fires an event of the specified type.\n\t */\n\t_fireEvt(type, data, propagate) {\n\t\tif (this.fire) this.fire(type, data, propagate);\n\t\tif (this._map) this._map.fire(type, data, propagate);\n\t},\n\n\t/*\n\t * Hides the position/height indicator marker drawn onto the map\n\t */\n\t_hideMarker() {\n\t\tif (this.options.autohideMarker) {\n\t\t\tthis._marker.remove();\n\t\t}\n\t},\n\n\t/**\n\t * Generate \"svg\" chart (DOM element).\n\t */\n\t_initChart(container) {\n\t\tlet opts = this.options;\n\t\tlet map = this._map;\n\n\t\tif (opts.detached) {\n\t\t\tlet { offsetWidth, offsetHeight} = this.eleDiv;\n\t\t\tif (offsetWidth > 0) opts.width = offsetWidth;\n\t\t\tif (offsetHeight > 20) opts.height = offsetHeight - 20; // 20 = horizontal scrollbar size.\n\t\t} else {\n\t\t\tlet { clientWidth } = map.getContainer();\n\t\t\topts._maxWidth = opts._maxWidth > opts.width ? opts._maxWidth : opts.width;\n\t\t\tthis._container.style.maxWidth = opts._maxWidth + 'px';\n\t\t\tif (opts._maxWidth > clientWidth) opts.width = clientWidth - 30;\n\t\t}\n\n\t\tthis\n\t\t\t.import([this.__D3, this.__LCHART])\n\t\t\t.then((m) => {\n\n\t\t\tlet chart = this._chart = new (m[1] || Elevation).Chart(opts, this);\n\t\n\t\t\tthis._x = this._chart._x;\n\t\t\tthis._y = this._chart._y;\n\t\n\t\t\td3\n\t\t\t\t.select(container)\n\t\t\t\t.call(chart.render())\n\t\n\t\t\tchart\n\t\t\t\t.on('reset_drag', this._hideMarker, this)\n\t\t\t\t.on('mouse_enter', this._onMouseEnter, this)\n\t\t\t\t.on('dragged', this._onDragEnd, this)\n\t\t\t\t.on('mouse_move', this._onMouseMove, this)\n\t\t\t\t.on('mouse_out', this._onMouseOut, this)\n\t\t\t\t.on('ruler_filter', this._onRulerFilter, this)\n\t\t\t\t.on('zoom', this._updateChart, this)\n\t\t\t\t.on('elepath_toggle', this._onToggleChart, this)\n\t\t\t\t.on('margins_updated', this._resizeChart, this);\n\t\n\t\n\t\t\tthis.fire(\"elechart_init\");\n\n\t\t\tmap\n\t\t\t\t.on('zoom viewreset zoomanim', this._hideMarker, this)\n\t\t\t\t.on('resize', this._resetView, this)\n\t\t\t\t.on('resize', this._resizeChart, this)\n\t\t\t\t.on('rotate', this._rotateMarker, this)\n\t\t\t\t.on('mousedown', this._resetDrag, this);\n\n\t\t\t_.on(map.getContainer(), 'mousewheel', this._resetDrag, this);\n\t\t\t_.on(map.getContainer(), 'touchstart', this._resetDrag, this);\n\t\t\t_.on(document, 'keydown', this._onKeyDown, this);\n\n\t\t\tthis\n\t\t\t\t.on('eledata_added eledata_loaded', this._updateChart, this)\n\t\t\t\t.on('eledata_added eledata_loaded', this._updateSummary, this);\n\n\t\t\tthis._updateChart();\n\t\t\tthis._updateSummary();\n\t\t});\n\n\n\t},\n\n\t_initLayer() {\n\t\tthis._layers\n\t\t\t.on('layeradd layerremove', ({layer, type}) => {\n\t\t\t\tlet node = layer.getElement && layer.getElement();\n\t\t\t\t_.toggleClass(node, this.options.polyline.className + ' ' + this.options.theme, type == 'layeradd');\n\t\t\t\t_.toggleEvent(layer, \"mousemove\", this._onMouseMoveLayer.bind(this), type == 'layeradd')\n\t\t\t\t_.toggleEvent(layer, \"mouseout\", this._onMouseOut.bind(this), type == 'layeradd');\n\t\t\t});\n\t},\n\n\t_initMarker(map) {\n\t\tlet pane = map.getPane('elevationPane');\n\t\tif (!pane) {\n\t\t\tpane = this._pane = map.createPane('elevationPane', map.getPane('norotatePane') || map.getPane('mapPane'));\n\t\t\tpane.style.zIndex = 625; // This pane is above markers but below popups.\n\t\t\tpane.style.pointerEvents = 'none';\n\t\t}\n\n\t\tif (this._renderer) this._renderer.remove()\n\t\tthis._renderer = L.svg({ pane: \"elevationPane\" }).addTo(this._map); // default leaflet svg renderer\n\n\t\tthis.import([this.__D3, this.__LMARKER])\n\t\t\t.then((m) => {\n\t\t\t\tthis._marker = new (m[1] || Elevation).Marker(this.options, this);\n\t\t\t\tthis.fire(\"elechart_marker\");\n\t\t\t});\n\t},\n\n\t/**\n\t * Inspired by L.Control.Layers\n\t */\n\t_initButton(container) {\n\t\tL.DomEvent\n\t\t\t.disableClickPropagation(container)\n\t\t\t.disableScrollPropagation(container);\n\n\t\tthis.options.collapsed ? this._collapse() : this._expand();\n\n\t\tif (this.options.autohide) {\n\t\t\t_.on(container, 'mouseover', this._expand, this);\n\t\t\t_.on(container, 'mouseout', this._collapse, this);\n\t\t\tthis._map.on('click', this._collapse, this);\n\t\t}\n\n\t\tif (this.options.closeBtn) {\n\t\t\tlet link = this._button = _.create('a', \"elevation-toggle-icon\", { href: '#', title: L._('Elevation'), }, container);\n\t\t\t_.on(link, 'click', L.DomEvent.stop);\n\t\t\t_.on(link, 'click', this._toggle, this);\n\t\t\t_.on(link, 'focus', this._toggle, this);\n\t\t\tfetch(_.resolveURL(this.__btnIcon, this.options.srcFolder)).then(r => r.ok && r.text().then(img => link.innerHTML = img));\n\t\t}\n\t},\n\n\t_initSummary(container) {\n\t\tthis.import(this.__LSUMMARY).then((m)=>{\n\t\t\tthis._summary = new (m || Elevation).Summary({ summary: this.options.summary }, this);\n\n\t\t\tthis.on('elechart_init', () => {\n\t\t\t\td3.select(container).call(this._summary.render());\n\t\t\t});\n\t\t});\n\t},\n\n\t/**\n\t * Retrieve data from a remote url (HTTP).\n\t */\n\t_loadFile(url) {\n\t\tfetch(url)\n\t\t\t.then((response) => response.text())\n\t\t\t.then((data) => {\n\t\t\t\tthis._downloadURL = url; // TODO: handle multiple urls?\n\t\t\t\tthis._parseFromString(data)\n\t\t\t\t\t.then( geojson => geojson && this._loadLayer(geojson));\n\t\t\t}).catch((err) => console.warn(err));\n\t},\n\n\t/**\n\t * Dynamically import only required javascript modules (code splitting)\n\t */\n\t_loadModules(handlers) {\n\t\t// First map known classnames (eg. \"Altitude\" --> L.Control.Elevation.Altitude)\n\t\thandlers = handlers.map((h) => typeof h === 'string' && typeof Elevation[h] !== \"undefined\" ? Elevation[h] : h);\n\t\t// Then load optional classes and custom imports (eg. \"Cadence\" --> import('../src/handlers/cadence.js'))\n\t\tlet modules = handlers.map(file => (typeof file === 'string' && this.import(this.__modulesFolder + file.toLowerCase() + '.js')) || (file instanceof Promise && file) || Promise.resolve());\n\t\treturn Promise.all(modules).then((m) => {\n\t\t\t_.each(m, (exported, i) => {\n\t\t\t\tlet fn = exported && Object.keys(exported)[0];\n\t\t\t\tif (fn) {\n\t\t\t\t\thandlers[i] = Elevation[fn] = (Elevation[fn] ?? exported[fn]);\n\t\t\t\t}\n\t\t\t});\n\t\t\t_.each(handlers, h => [\"function\", \"object\"].includes(typeof h) && this._registerHandler(h));\n\t\t});\n\t},\n\n\t/**\n\t * Simple GeoJSON data loader (L.GeoJSON).\n\t */\n\t_loadLayer(geojson) {\n\t\tlet { polyline, theme, waypoints, wptIcons, wptLabels, distanceMarkers } = this.options;\n\t\tlet style = L.extend({}, polyline);\n\n\t\tif (theme) {\n\t\t\tstyle.className += ' ' + theme;\n\t\t}\n\n\t\tif (geojson.name) {\n\t\t\tthis.track_info.name = geojson.name;\n\t\t}\n\n\t\tlet layer = L.geoJson(geojson, {\n\t\t\tdistanceMarkers: distanceMarkers,\n\t\t\tstyle: style,\n\t\t\tpointToLayer: (feature, latlng) => {\n\t\t\t\tif (waypoints) {\n\t\t\t\t\tlet { desc, name, sym } = feature.properties;\n\t\t\t\t\tdesc = desc || '';\n\t\t\t\t\tname = name || '';\n\t\t\t\t\t// Handle chart waypoints (dots)\n\t\t\t\t\tif ([true, 'dots'].includes(waypoints)) {\n\t\t\t\t\t\tthis._registerCheckPoint({\n\t\t\t\t\t\t\tlatlng: latlng,\n\t\t\t\t\t\t\tlabel : ([true, 'dots'].includes(wptLabels) ? name : '')\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\t// Handle map waypoints (markers)\n\t\t\t\t\tif ([true, 'markers'].includes(waypoints) && wptIcons != false) {\n\t\t\t\t\t\treturn this._registerMarker({\n\t\t\t\t\t\t\tlatlng : latlng,\n\t\t\t\t\t\t\tsym : (sym ?? name).replace(/[\"']/g, '').replace(/ /g, '-').toLowerCase(),\n\t\t\t\t\t\t\tcontent: [true, 'markers'].includes(wptLabels) && (name || desc) && decodeURI(\"<b>\" + name + \"</b>\" + (desc.length > 0 ? '<br>' + desc : ''))\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tonEachFeature: (feature, layer) => feature.geometry && feature.geometry.type != 'Point' && this.addData(feature, layer),\n\t\t});\n\n\t\tthis.import(this.__D3).then(() => {\n\t\t\tthis._initMapIntegrations(layer);\n\t\t\tconst event_data = { data: geojson, layer: layer, name: this.track_info.name, track_info: this.track_info };\n\t\t\tif (this._modulesLoaded) {\n\t\t\t\tthis._fireEvt(\"eledata_loaded\", event_data);\n\t\t\t} else {\n\t\t\t\tthis.once('modules_loaded', () => this._fireEvt(\"eledata_loaded\", event_data));\n\t\t\t}\n\t\t});\n\n\t\treturn layer;\n\t},\n\n\t_onDragEnd({ dragstart, dragend}) {\n\t\tthis._hideMarker();\n\t\tthis.fitBounds(L.latLngBounds([dragstart.latlng, dragend.latlng]));\n\n\t\tthis.fire(\"elechart_dragged\");\n\t},\n\n\t_onKeyDown({key}) {\n\t\tif (!this.options.detached && key === \"Escape\"){\n\t\t\tthis._collapse()\n\t\t};\n\t},\n\n\t/**\n\t * Trigger mouseenter event.\n\t */\n\t_onMouseEnter() {\n\t\tthis.fire('elechart_enter');\n\t},\n\n\t/*\n\t * Handles the moueseover the chart and displays distance and altitude level.\n\t */\n\t_onMouseMove({xCoord}) {\n\t\tif (this._chartEnabled && this._data.length) {\n\t\t\tlet item = this._findItemForX(xCoord);\n\t\t\tif (item) {\n\t\t\t\tif (this._chartEnabled) this._chart._showDiagramIndicator(item, xCoord);\n\n\t\t\t\tthis._updateMarker(item);\n\t\t\t\tthis._setMapView(item);\n\n\t\t\t\tif (this._map) {\n\t\t\t\t\t_.addClass(this._map.getContainer(), 'elechart-hover');\n\t\t\t\t}\n\n\t\t\t\tthis.fire(\"elechart_change\", { data: item, xCoord: xCoord });\n\t\t\t\tthis.fire(\"elechart_hover\", { data: item, xCoord: xCoord });\n\t\t\t}\n\t\t}\n\t},\n\n\t/*\n\t * Handles mouseover events of the data layers on the map.\n\t */\n\t_onMouseMoveLayer({latlng}) {\n\t\tif (this._data.length) {\n\t\t\tlet item = this._findItemForLatLng(latlng);\n\t\t\tif (item) {\n\t\t\t\tlet xCoord = item.xDiagCoord;\n\t\n\t\t\t\tif (this._chartEnabled) this._chart._showDiagramIndicator(item, xCoord);\n\t\n\t\t\t\tthis._updateMarker(item);\n\t\n\t\t\t\tthis.fire(\"elechart_change\", { data: item, xCoord: xCoord });\n\t\t\t}\n\t\t}\n\t},\n\n\t/*\n\t * Handles the moueseout over the chart.\n\t */\n\t_onMouseOut() {\n\t\tif (!this.options.detached) {\n\t\t\tthis._hideMarker();\n\t\t\tthis._chart._hideDiagramIndicator();\n\t\t}\n\n\t\tif (this._map) {\n\t\t\t_.removeClass(this._map.getContainer(), 'elechart-hover');\n\t\t}\n\n\t\tthis.fire(\"elechart_leave\");\n\t},\n\n\t/**\n\t * Handles the drag event over the ruler filter.\n\t */\n\t_onRulerFilter({coords}) {\n\t\tthis._updateMapSegments(coords);\n\t},\n\n\t/**\n\t * Toggle chart data on legend click\n\t */\n\t_onToggleChart({ name, enabled }) {\n\n\t\tthis._chartEnabled = this._chart._hasActiveLayers();\n\n\t\t// toggle layer visibility on empty chart\n\t\tthis._layers.eachLayer(layer => _.toggleClass(layer.getElement && layer.getElement(), this.options.polyline.className + ' ' + this.options.theme, this._chartEnabled));\n\n\t\t// toggle option value (eg. altitude = { 'disabled' || 'enabled' })\n\t\tthis.options[name] = !enabled && this.options[name] == 'disabled' ? 'enabled' : 'disabled';\n\n\t\t// remove marker on empty chart\n\t\tif (!this._chartEnabled) {\n\t\t\tthis._chart._hideDiagramIndicator();\n\t\t\tthis._marker.remove();\n\t\t}\n\t},\n\n\t/**\n\t * Simple GeoJSON Parser\n\t */\n\t_parseFromGeoJSONString(data) {\n\t\ttry {\n\t\t\treturn JSON.parse(data);\n\t\t} catch (e) { }\n\t},\n\n\t/**\n\t * Attempt to parse raw response data (GeoJSON or XML > GeoJSON)\n\t */\n\t_parseFromString(data) {\n\t\treturn new Promise(resolve =>\n\t\t\tthis.import(this.__TOGEOJSON).then(() => {\n\t\t\t\tlet geojson;\n\t\t\t\ttry {\n\t\t\t\t\tgeojson = this._parseFromXMLString(data.trim());\n\t\t\t\t} catch (e) {\n\t\t\t\t\tgeojson = this._parseFromGeoJSONString(data.toString());\n\t\t\t\t}\n\t\t\t\tif (geojson) {\n\t\t\t\t\tgeojson.name = geojson.name || (this._downloadURL || '').split('/').pop().split('#')[0].split('?')[0];\n\t\t\t\t}\n\t\t\t\tresolve(geojson);\n\t\t\t})\n\t\t);\n\t},\n\n\t/**\n\t * Simple XML Parser (GPX, KML, TCX)\n\t */\n\t_parseFromXMLString(data) {\n\t\tif (data.indexOf(\"<\") != 0) {\n\t\t\tthrow 'Invalid XML';\n\t\t}\n\t\tlet xml = (new DOMParser()).parseFromString(data, \"text/xml\");\n\t\tlet type = xml.documentElement.tagName.toLowerCase(); // \"kml\" or \"gpx\"\n\t\tlet name = xml.getElementsByTagName('name');\n\t\tif (xml.getElementsByTagName('parsererror').length) {\n\t\t\tthrow 'Invalid XML';\n\t\t}\n\t\tif (!(type in toGeoJSON)) {\n\t\t\ttype = xml.documentElement.tagName == \"TrainingCenterDatabase\" ? 'tcx' : 'gpx';\n\t\t}\n\t\tlet geojson = toGeoJSON[type](xml);\n\t\tgeojson.name = name.length > 0 ? (Array.from(name).find(tag => tag.parentElement.tagName == \"trk\") ?? name[0]).textContent : '';\n\t\treturn geojson;\n\t},\n\n\t/**\n\t * Add chart profile to diagram\n\t */\n\t_registerAreaPath(props) {\n\t\tthis.on(\"elechart_init\", () => this._chart._registerAreaPath(props));\n\t},\n\n\t/**\n\t * Add chart grid to diagram\n\t */\n\t_registerAxisGrid(props) {\n\t\tthis.on(\"elechart_axis\", () => this._chart._registerAxisGrid(props));\n\t},\n\n\t/**\n\t * Add chart axis to diagram\n\t */\n\t_registerAxisScale(props) {\n\t\tthis.on(\"elechart_axis\", () => this._chart._registerAxisScale(props));\n\t},\n\n\t/**\n\t * Add a point of interest over the diagram\n\t */\n\t_registerCheckPoint(props) {\n\t\tconst cb = () => this._chart._registerCheckPoint(props);\n\t\tthis\n\t\t\t.on(\"elechart_updated\", cb)\n\t\t\t.once(\"eledata_clear\", () => this.off(\"elechart_updated\", cb));\n\t},\n\n\t/**\n\t * Base handler for iterative track statistics (dist, time, z, slope, speed, acceleration, ...)\n\t */\n\t _registerDataAttribute(props) {\n\n\t\t// parse of \"coordinateProperties\" for later usage\n\t\tif (props.coordPropsToMeta) {\n\t\t\tthis.on(\"elepoint_init\", (e) => props.coordPropsToMeta.call(this, e));\n\t\t}\n\n\t\t// prevent excessive variabile instanstations\n\t\tlet i, curr, prev, attr = props.attr || props.name;\n\n\t\t// save here a reference to last used point\n\t\tlet lastValid = {};\n\n\t\t// iteration\n\t\tthis.on(\"elepoint_added\", ({index, point}) => {\n\t\t\ti = index;\n\n\t\t\tprev = curr ?? this._data[i]; // same as: this._data[i > 0 ? i - 1 : i]\n\t\t\tcurr = this._data[i];\n\n\t\t\t// retrieve point value\n\t\t\tcurr[attr] = props.pointToAttr.call(this, point, i);\n\n\t\t\t// check and fix missing data on last added point\n\t\t\tif (i > 0 && isNaN(prev[attr])) {\n\t\t\t\tif (!isNaN(lastValid[attr]) && !isNaN(curr[attr])) {\n\t\t\t\t\tprev[attr] = (lastValid[attr] + curr[attr]) / 2;\n\t\t\t\t} else if (!isNaN(lastValid[attr])) {\n\t\t\t\t\tprev[attr] = lastValid[attr];\n\t\t\t\t} else if (!isNaN(curr[attr])) {\n\t\t\t\t\tprev[attr] = curr[attr];\n\t\t\t\t}\n\t\t\t\t// update \"yAttr\" and \"xAttr\"\n\t\t\t\tif (props.meta) {\n\t\t\t\t\tprev[props.meta] = prev[attr];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// skip to next iteration for invalid or missing data (eg. i == 0)\n\t\t\tif (isNaN(curr[attr])) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// update reference to last used point\n\t\t\tlastValid[attr] = curr[attr];\n\n\t\t\t// Limit \"crazy\" delta values.\n\t\t\tif (props.deltaMax) {\n\t\t\t\tcurr[attr] =_.wrapDelta(curr[attr], prev[attr], props.deltaMax);\n\t\t\t}\n\t\t\t\n\t\t\t// Range of acceptable values.\n\t\t\tif (props.clampRange) {\n\t\t\t\tcurr[attr] = _.clamp(curr[attr], props.clampRange);\n\t\t\t}\n\n\t\t\t// Limit floating point precision.\n\t\t\tif (!isNaN(props.decimals)) {\n\t\t\t\tcurr[attr] = _.round(curr[attr], props.decimals);\n\t\t\t}\n\n\t\t\t// update \"track_info\" stats (min, max, avg, ...)\n\t\t\tif (props.stats) {\n\t\t\t\tfor (const key in props.stats) {\n\t\t\t\t\tlet sname = (props.statsName || attr) + (key != '' ? '_' : '');\n\t\t\t\t\tthis.track_info[sname + key] = props.stats[key].call(this, curr[attr], this.track_info[sname + key], this._data.length);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// update here some mixins (eg. complex \"track_info\" stuff)\n\t\t\tif (props.onPointAdded) props.onPointAdded.call(this, curr[attr], i, point);\n\t\t});\n\t},\n\n\t/**\n\t * Parse a module definition and attach related function listeners\n\t */\n\t_registerHandler(props) {\n\n\t\t// eg. L.Control.Altitude\n\t\tif (typeof props === \"function\") {\n\t\t\treturn this._registerHandler(props.call(this));\n\t\t}\n\n\t\tlet {\n\t\t\tname,\n\t\t\tattr,\n\t\t\trequired,\n\t\t\tdeltaMax,\n\t\t\tclampRange,\n\t\t\tdecimals,\n\t\t\tmeta,\n\t\t\tunit,\n\t\t\tcoordinateProperties,\n\t\t\tcoordPropsToMeta,\n\t\t\tpointToAttr,\n\t\t\tonPointAdded,\n\t\t\tstats,\n\t\t\tstatsName,\n\t\t\tgrid,\n\t\t\tscale,\n\t\t\tpath,\n\t\t\ttooltip,\n\t\t\tsummary\n\t\t} = props;\n\n\t\t// eg. \"altitude\" == true\n\t\tif (this.options[name] || required) {\n\n\t\t\tthis._registerDataAttribute({\n\t\t\t\tname,\n\t\t\t\tattr,\n\t\t\t\tmeta,\n\t\t\t\tdeltaMax,\n\t\t\t\tclampRange,\n\t\t\t\tdecimals,\n\t\t\t\tcoordPropsToMeta: _.coordPropsToMeta(coordinateProperties, meta || name, coordPropsToMeta),\n\t\t\t\tpointToAttr,\n\t\t\t\tonPointAdded,\n\t\t\t\tstats,\n\t\t\t\tstatsName,\n\t\t\t});\n\n\t\t\tif (grid) {\n\t\t\t\tthis._registerAxisGrid(L.extend({ name }, grid));\n\t\t\t}\n\n\t\t\tif (this.options[name] !== \"summary\") {\n\t\t\t\tif (scale) this._registerAxisScale(L.extend({ name, label: unit }, scale));\n\t\t\t\tif (path) this._registerAreaPath(L.extend({ name }, path));\n\t\t\t}\n\n\t\t\tif (tooltip || props.tooltips) {\n\t\t\t\t_.each([tooltip, ...(props.tooltips || [])], t => t && this._registerTooltip(L.extend({ name }, t)));\n\t\t\t}\n\n\t\t\tif (summary) {\n\t\t\t\t_.each(summary, (s, k) => summary[k] = L.extend({ unit }, s));\n\t\t\t\tthis._registerSummary(summary);\n\t\t\t}\n\t\t}\n\t},\n\n\t_registerMarker({latlng, sym, content}) {\n\t\tlet { wptIcons } = this.options;\n\t\t// generate and cache appropriate icon symbol\n\t\tif (!wptIcons.hasOwnProperty(sym)) {\n\t\t\twptIcons[sym] = L.divIcon(L.extend({}, wptIcons[\"\"].options, { html: '<i class=\"elevation-waypoint-icon ' + sym + '\"></i>' } ));\n\t\t}\n\t\tlet marker = L.marker(latlng, { icon: wptIcons[sym] });\n\t\tif (content) {\n\t\t\tmarker.bindPopup(content, { className: 'elevation-popup', keepInView: true }).openPopup();\n\t\t\tmarker.bindTooltip(content, { className: 'elevation-tooltip', direction: 'auto', sticky: true, opacity: 1 }).openTooltip();\n\t\t}\n\t\treturn this._addMarker(marker)\n\t},\n\t\n\t/**\n\t * Add chart or marker tooltip info\n\t */\n\t_registerTooltip(props) {\n\t\tprops.chart && this.on(\"elechart_init\", () => this._chart._registerTooltip(L.extend({}, props, { value: props.chart })));\n\t\tprops.marker && this.on(\"elechart_marker\", () => this._marker._registerTooltip(L.extend({}, props, { value: props.marker })));\n\t},\n\n\t/**\n\t * Add summary info to diagram\n\t */\n\t_registerSummary(props) {\n\t\tthis.on('elechart_summary', () => this._summary._registerSummary(props));\n\t},\n\n\t/*\n\t * Removes the drag rectangle and zoms back to the total extent of the data.\n\t */\n\t_resetDrag() {\n\t\tthis._chart._resetDrag();\n\t\tthis._hideMarker();\n\t},\n\n\t/**\n\t * Resets drag, marker and bounds.\n\t */\n\t_resetView() {\n\t\tif (this._map && this._map._isFullscreen) return;\n\t\tthis._resetDrag();\n\t\tthis._hideMarker();\n\t\tif (this.options.autofitBounds) {\n\t\t\tthis.fitBounds();\n\t\t}\n\t},\n\n\t/**\n\t * Hacky way for handling chart resize. Deletes it and redraw chart.\n\t */\n\t_resizeChart() {\n\t\tif (this._container && _.style(this._container, \"display\") != \"none\") {\n\t\t\tlet opts = this.options;\n\t\t\tlet newWidth = opts.detached ? (this.eleDiv || this._container).offsetWidth : _.clamp(opts._maxWidth, [0, this._map.getContainer().clientWidth - 30]);\n\t\t\tif (newWidth) {\n\t\t\t\topts.width = newWidth;\n\t\t\t\tif (this._chart && this._chart._chart) {\n\t\t\t\t\tthis._chart._chart._resize(opts);\n\t\t\t\t\tthis._updateChart();\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._updateMapSegments();\n\t\t}\n\t},\n\n\t/**\n\t * Collapse or Expand chart control.\n\t */\n\t_toggle() {\n\t\t_.hasClass(this._container, \"elevation-expanded\") ? this._collapse() : this._expand();\n\t},\n\n\t/**\n\t * Update map center and zoom (followMarker: true)\n\t */\n\t_setMapView(item) {\n\t\tif (this._map && this.options.followMarker) {\n\t\t\tlet zoom = this._map.getZoom();\n\t\t\tlet z = this.options.zFollow;\n\t\t\tif (typeof z === \"number\") {\n\t\t\t\tthis._map.setView(item.latlng, (zoom < z ? z : zoom), { animate: true, duration: 0.25 });\n\t\t\t} else if (!this._map.getBounds().contains(item.latlng)) {\n\t\t\t\tthis._map.setView(item.latlng, zoom, { animate: true, duration: 0.25 });\n\t\t\t}\n\t\t}\n\t},\n\n\t/**\n\t * Calculates [x, y] domain and then update chart.\n\t */\n\t_updateChart() {\n\t\tif (this._chart && this._container) {\n\t\t\tthis.fire(\"elechart_axis\");\n\t\n\t\t\tthis._chart.update({ data: this._data, options: this.options });\n\t\n\t\t\tthis._x = this._chart._x;\n\t\t\tthis._y = this._chart._y;\n\t\n\t\t\tthis.fire('elechart_updated');\t\t\n\t\t}\n\t},\n\n\t/*\n\t * Update the position/height indicator marker drawn onto the map\n\t */\n\t_updateMarker(item) {\n\t\tif (this._marker) {\n\t\t\tthis._marker.update({\n\t\t\t\tmap : this._map,\n\t\t\t\titem : item,\n\t\t\t\tyCoordMin : this._yCoordMin,\n\t\t\t\tyCoordMax : this._yCoordMax || 0,\n\t\t\t\toptions : this.options\n\t\t\t});\n\t\t}\n\t},\n\n\t/**\n\t * Fix marker rotation on rotated maps\n\t */\n\t_rotateMarker() {\n\t\tif (this._marker) {\n\t\t\tthis._marker.update();\n\t\t}\n\t},\n\n\t/**\n\t * Highlight track segments on the map.\n\t */\n\t_updateMapSegments(coords) {\n\t\tthis._markedSegments.setLatLngs(coords || []);\n\t\tif (coords && this._map && !this._map.hasLayer(this._markedSegments)) {\n\t\t\tthis._markedSegments.addTo(this._map);\n\t\t}\n\t},\n\n\t/**\n\t * Update chart summary.\n\t */\n\t_updateSummary() {\n\t\tif (this._summary) {\n\t\t\tthis._summary.reset();\n\t\t\tif (this.options.summary) {\n\t\t\t\tthis.fire(\"elechart_summary\");\n\t\t\t\tthis._summary.update();\n\t\t\t}\n\t\t\tif (this.options.downloadLink && this._downloadURL) { // TODO: generate dynamically file content instead of using static file urls.\n\t\t\t\tthis._summary._container.innerHTML += '<span class=\"download\"><a href=\"#\">' + L._('Download') + '</a></span>'\n\t\t\t\t_.select('.download a', this._summary._container).onclick = (e) => {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tlet event = { downloadLink: this.options.downloadLink, confirm: _.saveFile.bind(this, this._downloadURL) };\n\t\t\t\t\tif (this.options.downloadLink == 'modal' && typeof CustomEvent === \"function\") {\n\t\t\t\t\t\tdocument.dispatchEvent(new CustomEvent(\"eletrack_download\", { detail: event }));\n\t\t\t\t\t} else if (this.options.downloadLink == 'link' || this.options.downloadLink === true) {\n\t\t\t\t\t\tevent.confirm();\n\t\t\t\t\t}\n\t\t\t\t\tthis.fire('eletrack_download', event);\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t},\n\n\n\t/**\n\t * Calculates chart width.\n\t */\n\t_width() {\n\t\tif (this._chart) return this._chart._width();\n\t\tconst { width, margins } = this.options;\n\t\treturn width - margins.left - margins.right;\n\t},\n\n\t/**\n\t * Calculates chart height.\n\t */\n\t_height() {\n\t\tif (this._chart) return this._chart._height();\n\t\tconst { height, margins } = this.options;\n\t\treturn height - margins.top - margins.bottom;\n\t},\n\n});\n", "/*\n * Copyright (c) 2019, GPL-3.0+ Project, Raruto\n *\n * This file is free software: you may copy, redistribute and/or modify it\n * under the terms of the GNU General Public License as published by the\n * Free Software Foundation, either version 2 of the License, or (at your\n * option) any later version.\n *\n * This file is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n *\n * This file incorporates work covered by the following copyright and\n * permission notice:\n *\n * Copyright (c) 2013-2016, MIT License, Felix \u201CMrMufflon\u201D Bache\n *\n * Permission to use, copy, modify, and/or distribute this software\n * for any purpose with or without fee is hereby granted, provided\n * that the above copyright notice and this permission notice appear\n * in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL\n * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE\n * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR\n * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,\n * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\nimport * as _ from './utils';\nimport { Elevation } from './control';\n\nElevation.Utils = _;\n\nL.control.elevation = (options) => new Elevation(options);\n"],
5
- "mappings": ";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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aAAO,QAAQ,QAAQ,OAAO,QAAQ;AAAA,IACvC;AAAA;AAAA;AAAA;AAAA,IAKA,UAAU;AACT,UAAI,KAAK,OAAQ,QAAO,KAAK,OAAO,QAAQ;AAC5C,YAAM,EAAE,QAAQ,QAAQ,IAAI,KAAK;AACjC,aAAO,SAAS,QAAQ,MAAM,QAAQ;AAAA,IACvC;AAAA,EAED,CAAC;;;ACpxCD,YAAU,QAAQ;AAElB,IAAE,QAAQ,YAAY,CAAC,YAAY,IAAI,UAAU,OAAO;",
4
+ "sourcesContent": ["/**\n * TODO: exget computed styles of theese values from actual \"CSS vars\"\n **/\nexport const Colors = {\n\t'lightblue': { area: '#3366CC', alpha: 0.45, stroke: '#3366CC' },\n\t'magenta' : { area: '#FF005E' },\n\t'yellow' : { area: '#FF0' },\n\t'purple' : { area: '#732C7B' },\n\t'steelblue': { area: '#4682B4' },\n\t'red' : { area: '#F00' },\n\t'lime' : { area: '#9CC222', line: '#566B13' }\n};\n\nconst SEC = 1000;\nconst MIN = SEC * 60;\nconst HOUR = MIN * 60;\nconst DAY = HOUR * 24;\n\nexport function resolveURL(src, baseUrl) {\n\treturn (new URL(src, (src.startsWith('../') || src.startsWith('./')) ? baseUrl : undefined)).toString()\n};\n\n/**\n * Convert a time (millis) to a human readable duration string (%Dd %H:%M'%S\")\n */\nexport function formatTime(t) {\n\tlet d = Math.floor(t / DAY);\n\tlet h = Math.floor( (t - d * DAY) / HOUR);\n\tlet m = Math.floor( (t - d * DAY - h * HOUR) / MIN);\n\tlet s = Math.round( (t - d * DAY - h * HOUR - m * MIN) / SEC);\n\tif ( s === 60 ) { m++; s = 0; }\n\tif ( m === 60 ) { h++; m = 0; }\n\tif ( h === 24 ) { d++; h = 0; }\n\treturn (d ? d + \"d \" : '') + h.toString().padStart(2, 0) + ':' + m.toString().padStart(2, 0) + \"'\" + s.toString().padStart(2, 0) + '\"';\n}\n\n/**\n * Convert a time (millis) to human readable date string (dd-mm-yyyy hh:mm:ss)\n */\n export function formatDate(format) {\n\tif (!format) {\n\t\treturn (time) => (new Date(time)).toLocaleString().replaceAll('/', '-').replaceAll(',', ' ');\n\t} else if (format == 'time') {\n\t\treturn (time) => (new Date(time)).toLocaleTimeString();\n\t} else if (format == 'date') {\n\t\treturn (time) => (new Date(time)).toLocaleDateString();\n\t}\n\treturn (time) => format(time);\n}\n\n/**\n * Generate download data event.\n */\n export function saveFile(dataURI, fileName) {\n\tlet a = create('a', '', { href: dataURI, target: '_new', download: fileName || \"\", style: \"display:none;\" });\n\tlet b = document.body;\n\tb.appendChild(a);\n\ta.click();\n\tb.removeChild(a);\n}\n\n\n/**\n * Convert SVG Path into Path2D and then update canvas\n */\n export function drawCanvas(ctx, path) {\n\tpath.classed('canvas-path', true);\n\n\tctx.beginPath();\n\tctx.moveTo(0, 0);\n\tlet p = new Path2D(path.attr('d'));\n\n\tctx.strokeStyle = path.__strokeStyle || path.attr('stroke');\n\tctx.fillStyle = path.__fillStyle || path.attr('fill');\n\tctx.lineWidth = 1.25;\n\tctx.globalCompositeOperation = 'source-over';\n\n\t// stroke opacity\n\tctx.globalAlpha = path.attr('stroke-opacity') || 0.3;\n\tctx.stroke(p);\n\n\t// fill opacity\n\tctx.globalAlpha = path.attr('fill-opacity') || 0.45;\n\tctx.fill(p);\n\n\tctx.globalAlpha = 1;\n\n\tctx.closePath();\n}\n\n/**\n * Loop and extract GPX Extensions handled by \"@tmcw/toGeoJSON\" (eg. \"coordinateProperties\" > \"times\")\n */\nexport function coordPropsToMeta(coordProps, name, parser) {\n\treturn coordProps && (({props, point, id, isMulti }) => {\n\t\tif (props) {\n\t\t\tfor (const key of coordProps) {\n\t\t\t\tif (key in props) {\n\t\t\t\t\tpoint.meta[name] = (parser || parseNumeric).call(this, (isMulti ? props[key][isMulti] : props[key]), id);\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t});\n}\n\n/**\n * Extract numeric property (id) from GeoJSON object\n */\nexport const parseNumeric = (property, id) => parseInt((typeof property === 'object' ? property[id] : property));\n\n/**\n * Extract datetime property (id) from GeoJSON object\n */\nexport const parseDate = (property, id) => new Date(Date.parse((typeof property === 'object' ? property[id] : property)));\n\n/**\n * A little bit shorter than L.DomUtil\n */\nexport const addClass = (n, str) => n && str.split(\" \").every(s => s && L.DomUtil.addClass(n, s));\nexport const removeClass = (n, str) => n && str.split(\" \").every(s => s && L.DomUtil.removeClass(n, s));\nexport const toggleClass = (n, str, cond) => (cond ? addClass : removeClass)(n, str);\nexport const replaceClass = (n, rem, add) => (rem && removeClass(n, rem)) || (add && addClass(n, add));\nexport const style = (n, k, v) => (typeof v === \"undefined\" && L.DomUtil.getStyle(n, k)) || n.style.setProperty(k, v);\nexport const toggleStyle = (n, k, v, cond) => style(n, k, cond ? v : '');\nexport const setAttributes = (n, attrs) => { for (let k in attrs) { n.setAttribute(k, attrs[k]); } };\nexport const toggleEvent = (el, e, fn, cond) => el[cond ? 'on' : 'off'](e, fn);\nexport const create = (tag, str, attrs, n) => { let elem = L.DomUtil.create(tag, str || \"\"); if (attrs) setAttributes(elem, attrs); if (n) append(n, elem); return elem; };\nexport const append = (n, c) => n.appendChild(c);\nexport const insert = (n, c, pos) => n.insertAdjacentElement(pos, c);\nexport const select = (str, n) => (n || document).querySelector(str);\nexport const each = (obj, fn) => { for (let i in obj) fn(obj[i], i); };\nexport const randomId = () => Math.random().toString(36).substr(2, 9);\n\n/**\n * TODO: use generators instead? (ie. \"yield\")\n */\nexport const iMax = (iVal, max = -Infinity) => (iVal > max ? iVal : max); \nexport const iMin = (iVal, min = +Infinity) => (iVal < min ? iVal : min);\nexport const iAvg = (iVal, avg = 0, idx = 1) => (iVal + avg * (idx - 1)) / idx;\nexport const iSum = (iVal, sum = 0) => iVal + sum;\n\n/**\n * Alias for some leaflet core functions\n */\nexport const { on, off } = L.DomEvent;\nexport const { throttle, wrapNum } = L.Util;\nexport const { hasClass } = L.DomUtil;\n\n/**\n * Limit floating point precision\n */\nexport const round = L.Util.formatNum;\n\n/**\n * Limit a number between min / max values\n */\nexport const clamp = (val, range) => range ? (val < range[0] ? range[0] : val > range[1] ? range[1] : val) : val;\n\n/**\n * Limit a delta difference between two values\n */\nexport const wrapDelta = (curr, prev, deltaMax) => Math.abs(curr - prev) > deltaMax ? prev + deltaMax * Math.sign(curr - prev) : curr;\n\n/**\n * A deep copy implementation that takes care of correct prototype chain and cycles, references\n * \n * @see https://web.dev/structured-clone/#features-and-limitations\n */\nexport function cloneDeep(o, skipProps = [], cache = []) {\n\tswitch(!o || typeof o) {\n\t\tcase 'object':\n\t\t\tconst hit = cache.filter(c => o === c.original)[0];\n\t\t\tif (hit) return hit.copy; // handle circular structures\n\t\t\tconst copy = Array.isArray(o) ? [] : Object.create(Object.getPrototypeOf(o));\n\t\t\tcache.push({ original: o, copy });\n\t\t\tObject\n\t\t\t\t.getOwnPropertyNames(o)\n\t\t\t\t.forEach(function (prop) {\n\t\t\t\t\tconst propdesc = Object.getOwnPropertyDescriptor(o, prop);\n\t\t\t\t\tObject.defineProperty(\n\t\t\t\t\t\tcopy,\n\t\t\t\t\t\tprop,\n\t\t\t\t\t\tpropdesc.get || propdesc.set\n\t\t\t\t\t\t\t? propdesc // just copy accessor properties\n\t\t\t\t\t\t\t: { // deep copy data properties\n\t\t\t\t\t\t\t\twritable: propdesc.writable,\n\t\t\t\t\t\t\t\tconfigurable: propdesc.configurable,\n\t\t\t\t\t\t\t\tenumerable: propdesc.enumerable,\n\t\t\t\t\t\t\t\tvalue: skipProps.includes(prop) ? propdesc.value : cloneDeep(propdesc.value, skipProps, cache),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t});\n\t\t\treturn copy;\n\t\tcase 'function':\n\t\tcase 'symbol':\n\t\t\tconsole.warn('cloneDeep: ' + typeof o + 's not fully supported:', o);\n\t\tcase true:\n\t\t\t// null, undefined or falsy primitive\n\t\tdefault:\n\t\t\treturn o;\n\t}\n}", "import * as _ from './utils';\n\nexport var Options = {\n\tautofitBounds: true,\n\tautohide: false,\n\tautohideMarker: true,\n\talmostover: true,\n\taltitude: true,\n\tcloseBtn: true,\n\tcollapsed: false,\n\tdetached: true,\n\tdistance: true,\n\tdistanceMarkers: { lazy: true, distance: true, direction: true },\n\tdragging: !L.Browser.mobile,\n\tdownloadLink: 'link',\n\televationDiv: \"#elevation-div\",\n\tedgeScale: { bar: true, icon: false, coords: false },\n\tfollowMarker: true,\n\timperial: false,\n\tlegend: true,\n\thandlers: [\"Distance\", \"Time\", \"Altitude\", \"Slope\", \"Speed\", \"Acceleration\"],\n\thotline: 'elevation',\n\tmarker: 'elevation-line',\n\tmarkerIcon: L.divIcon({\n\t\tclassName: 'elevation-position-marker',\n\t\thtml: '<i class=\"elevation-position-icon\"></i>',\n\t\ticonSize: [32, 32],\n\t\ticonAnchor: [16, 16],\n\t}),\n\tposition: \"topright\",\n\tpolyline: {\n\t\tclassName: 'elevation-polyline',\n\t\tcolor: '#000',\n\t\topacity: 0.75,\n\t\tweight: 5,\n\t\tlineCap: 'round'\n\t},\n\tpolylineSegments: {\n\t\tclassName: 'elevation-polyline-segments',\n\t\tcolor: '#F00',\n\t\tinteractive: false,\n\t},\n\tpreferCanvas: false,\n\treverseCoords: false,\n\truler: true,\n\ttheme: \"lightblue-theme\",\n\tsummary: 'inline',\n\tslope: false,\n\tspeed: false,\n\ttime: true,\n\ttimeFactor: 3600,\n\ttimestamps: false,\n\ttrkStart: { className: 'start-marker', radius: 6, weight: 2, color: '#fff', fillColor: '#00d800', fillOpacity: 1, interactive: false },\n\ttrkEnd: { className: 'end-marker', radius: 6, weight: 2, color: '#fff', fillColor: '#ff0606', fillOpacity: 1, interactive: false },\n\twaypoints: true,\n\twptIcons: {\n\t\t'': L.divIcon({\n\t\t\tclassName: 'elevation-waypoint-marker',\n\t\t\thtml: '<i class=\"elevation-waypoint-icon default\"></i>',\n\t\t\ticonSize: [30, 30],\n\t\t\ticonAnchor: [8, 30],\n\t\t}),\n\t},\n\twptLabels: true,\n\txAttr: \"dist\",\n\txLabel: \"km\",\n\tyAttr: \"z\",\n\tyLabel: \"m\",\n\tzFollow: false,\n\tzooming: !L.Browser.Mobile,\n\n\t// Quite uncommon and undocumented options\n\tmargins: { top: 30, right: 30, bottom: 30, left: 40 },\n\theight: (screen.height * 0.3) || 200,\n\twidth: (screen.width * 0.6) || 600,\n\txTicks: undefined,\n\tyTicks: undefined,\n\n\tdecimalsX: 2,\n\tdecimalsY: 0,\n\tforceAxisBounds: false,\n\tinterpolation: \"curveLinear\",\n\tyAxisMax: undefined,\n\tyAxisMin: undefined,\n\n\t// Prevent CORS issues for relative locations (dynamic import)\n\tsrcFolder: ((document.currentScript && document.currentScript.src) || (import.meta && import.meta.url) || document.baseURI).split(\"/\").slice(0,-1).join(\"/\") + '/',\n};\n", "import * as _ from './utils';\nimport { Options } from './options';\n\n// \"leaflet-i18n\" fallback\nif (!L._ || !L.i18n) {\n\tL._ = L.i18n = (string, data) => string;\n}\n\nexport const Elevation = L.Control.Elevation = L.Control.extend({\n\n\tincludes: L.Evented ? L.Evented.prototype : L.Mixin.Events,\n\n\toptions: Options,\n\t__mileFactor: 0.621371, // 1 km = (0.621371 mi)\n\t__footFactor: 3.28084, // 1 m = (3.28084 ft)\n\t__D3: 'https://unpkg.com/d3@7.8.4/dist/d3.min.js',\n\t__TOGEOJSON: 'https://unpkg.com/@tmcw/togeojson@5.6.2/dist/togeojson.umd.js',\n\t__LGEOMUTIL: 'https://unpkg.com/leaflet-geometryutil@0.10.1/src/leaflet.geometryutil.js',\n\t__LALMOSTOVER: 'https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js',\n\t__LHOTLINE: '../libs/leaflet-hotline.min.js',\n\t__LDISTANCEM: '../libs/leaflet-distance-marker.min.js',\n\t__LEDGESCALE: '../libs/leaflet-edgescale.min.js',\n\t__LCHART: '../src/components/chart.js',\n\t__LMARKER: '../src/components/marker.js',\n\t__LSUMMARY: '../src/components/summary.js',\n\t__modulesFolder: '../src/handlers/',\n\t__btnIcon: '../images/elevation.svg',\n\n\t/*\n\t * Add data to the diagram either from GPX or GeoJSON and update the axis domain and data\n\t */\n\taddData(d, layer) {\n\t\treturn this.import(this.__D3).then(() => {\n\t\t\tif (!this._modulesLoaded) {\n\t\t\t\treturn new Promise(resolve => this.once('modules_loaded', () => resolve(this.addData(d, layer))));\n\t\t\t}\n\t\t\tlayer = layer ?? (d.on && d);\n\t\t\tthis._addData(d);\n\t\t\tthis._addLayer(layer);\n\t\t\tthis._fireEvt(\"eledata_added\", { data: d, layer: layer, track_info: this.track_info });\n\t\t});\n\t},\n\n\t/**\n\t * Adds the control to the given map.\n\t */\n\taddTo(map) {\n\t\tif (this.options.detached) {\n\t\t\tlet parent = _.select(this.options.elevationDiv);\n\t\t\tlet eleDiv = this.onAdd(map);\n\t\t\tparent ? _.append(parent, eleDiv) : _.insert(map.getContainer(), eleDiv, 'afterend');\n\t\t} else {\n\t\t\tL.Control.prototype.addTo.call(this, map);\n\t\t}\n\t\treturn this;\n\t},\n\n\t/*\n\t * Reset data and display\n\t */\n\tclear() {\n\t\tif (this._marker) this._marker.remove();\n\t\tif (this._chart) this._clearChart();\n\t\tif (this._layers) this._clearLayers(this._layers);\n\t\tif (this._markers) this._clearLayers(this._markers);\n\t\tif (this._circleMarkers) this._circleMarkers.remove();\n\t\tif (this._hotline) this._hotline.eachLayer(l => l.options.renderer.remove()); // hotfix for: https://github.com/Raruto/leaflet-elevation/issues/233\n\t\tif (this._hotline) this._clearLayers(this._hotline);\n\n\t\tthis._data = [];\n\t\tthis.track_info = {};\n\t\tthis._yCoordMin = 0;\n\t\tthis._yCoordMax = -Infinity;\n\n\t\tthis._fireEvt(\"eledata_clear\");\n\n\t\tthis._updateChart();\n\t},\n\n\t_clearChart() {\n\t\tif (this._events && this._events.elechart_updated) {\n\t\t\tthis._events.elechart_updated.forEach(({fn, ctx}) => this.off('elechart_updated', fn, ctx));\n\t\t}\n\t\tif (this._chart && this._chart._container) {\n\t\t\tthis._chart._container.selectAll('g.point .point').remove();\n\t\t\tthis._chart.clear();\n\t\t}\n\t},\n\n\t_clearLayers(l) {\n\t\tl = l || this._layers;\n\t\tif (l && l.eachLayer) {\n\t\t\tl.eachLayer(f => f.remove())\n\t\t\tl.clearLayers();\n\t\t}\n\t},\n\n\t/**\n\t * TODO: Create a base class to handle custom data attributes (heart rate, cadence, temperature, ...)\n\t * \n\t * @link https://leafletjs.com/examples/extending/extending-3-controls.html#handlers\n\t */\n\t// addHandler: function (name, HandlerClass) {\n\t// \tif (HandlerClass) {\n\t// \t\tlet handler = this[name] = new HandlerClass(this);\n\t// \t\tthis.handlers.push(handler);\n\t// \t\tif (this.options[name]) {\n\t// \t\t\thandler.enable();\n\t// \t\t}\n\t// \t}\n\t// \treturn this;\n\t// },\n\n\t/**\n\t * Disable chart brushing.\n\t */\n\tdisableBrush() {\n\t\tthis._chart._brushEnabled = false;\n\t\tthis._resetDrag();\n\t},\n\n\t/**\n\t * Enable chart brushing.\n\t */\n\tenableBrush() {\n\t\tthis._chart._brushEnabled = true;\n\t},\n\n\t/**\n\t * Disable chart zooming.\n\t */\n\tdisableZoom() {\n\t\tthis._chart._zoomEnabled = false;\n\t\tthis._chart._resetZoom();\n\t},\n\n\t/**\n\t * Enable chart zooming.\n\t */\n\tenableZoom() {\n\t\tthis._chart._zoomEnabled = true;\n\t},\n\n\t/**\n\t * Sets a map view that contains the given geographical bounds.\n\t */\n\tfitBounds(bounds) {\n\t\tbounds = bounds || this.getBounds();\n\t\tif (this._map && bounds.isValid()) this._map.fitBounds(bounds);\n\t},\n\n\tgetBounds(data) {\n\t\treturn L.latLngBounds((data || this._data).map((d) => d.latlng));\n\t},\n\n\t/**\n\t * Get default zoom level (followMarker: true).\n\t */\n\tgetZFollow() {\n\t\treturn this.options.zFollow;\n\t},\n\n\t/**\n\t * Hide current elevation chart profile.\n\t */\n\thide() {\n\t\t_.style(this._container, \"display\", \"none\");\n\t},\n\n\t/**\n\t * Initialize chart control \"options\" and \"container\".\n\t */\n\tinitialize(opts) {\n\n\t\t// opts = L.setOptions(this, opts);\n\n\t\t// Fixes: https://github.com/Raruto/leaflet-elevation/pull/240\n\t\topts = L.setOptions(this, L.extend({}, _.cloneDeep(Options), opts)); // \"deep copy\" nested objects (multiple charts)\n\n\t\tthis._data = [];\n\t\tthis._layers = L.featureGroup();\n\t\tthis._markers = L.featureGroup();\n\t\tthis._hotline = L.featureGroup();\n\t\tthis._circleMarkers = L.featureGroup();\n\t\tthis._markedSegments = L.polyline([]);\n\t\tthis._start = L.circleMarker([0,0], (opts.trkStart || Options.trkStart));\n\t\tthis._end = L.circleMarker([0,0], (opts.trkEnd || Options.trkEnd));\n\t\tthis._chartEnabled = true;\n\t\tthis._yCoordMin = 0;\n\t\tthis._yCoordMax = -Infinity;\n\t\tthis.track_info = {};\n\t\t// this.handlers = [];\n\n\t\tif (opts.followMarker) this._setMapView = _.throttle(this._setMapView, 300, this);\n\t\tif (opts.legend) opts.margins.bottom += 30;\n\t\tif (opts.theme) opts.polylineSegments.className += ' ' + opts.theme;\n\t\tif (opts.wptIcons === true) opts.wptIcons = Options.wptIcons;\n\t\tif (opts.distanceMarkers === true) opts.distanceMarkers = Options.distanceMarkers;\n\t\tif (opts.trkStart) this._start.addTo(this._circleMarkers);\n\t\tif (opts.trkEnd) this._end.addTo(this._circleMarkers);\n\n\n\t\tthis._markedSegments.setStyle(opts.polylineSegments);\n\n\t\t// Leaflet canvas renderer colors\n\t\tL.extend(_.Colors, opts.colors || {});\n\n\t\t// Various stuff\n\t\tthis._fixCanvasPaths();\n\t\tthis._fixTooltipSize();\n\n\t},\n\n\t/**\n\t * Javascript scripts downloader (lazy loader)\n\t */\n\timport(src, condition) {\n\t\tif (Array.isArray(src)) {\n\t\t\treturn Promise.all(src.map(m => this.import(m)));\n\t\t}\n\t\tswitch(src) {\n\t\t\tcase this.__D3: condition = typeof d3 !== 'object'; break;\n\t\t\tcase this.__TOGEOJSON: condition = typeof toGeoJSON !== 'object'; break;\n\t\t\tcase this.__LGEOMUTIL: condition = typeof L.GeometryUtil !== 'object'; break;\n\t\t\tcase this.__LALMOSTOVER: condition = typeof L.Handler.AlmostOver !== 'function'; break;\n\t\t\tcase this.__LDISTANCEM: condition = typeof L.DistanceMarkers !== 'function'; break;\n\t\t\tcase this.__LEDGESCALE: condition = typeof L.Control.EdgeScale !== 'function'; break;\n\t\t\tcase this.__LHOTLINE: condition = typeof L.Hotline !== 'function'; break;\n\t\t}\n\t\treturn condition !== false ? import(_.resolveURL(src, this.options.srcFolder)) : Promise.resolve();\n\t},\n\n\t/**\n\t * Load elevation data (GPX, GeoJSON, KML or TCX).\n\t */\n\tload(data) {\n\t\tthis._parseFromString(data).then( geojson => geojson ? this._loadLayer(geojson) : this._loadFile(data));\n\t},\n\n\t/**\n\t * Create container DOM element and related event listeners.\n\t * Called on control.addTo(map).\n\t */\n\tonAdd(map) {\n\t\tthis._map = map;\n\n\t\tlet container = this._container = _.create(\"div\", \"elevation-control \" + this.options.theme + \" \" + (this.options.detached ? 'elevation-detached' : 'leaflet-control'), this.options.detached ? { id: 'elevation-' + _.randomId() } : {});\n\n\t\tthis.eleDiv = container;\n\n\t\tthis._loadModules(this.options.handlers).then(() => { // Inject here required modules (data handlers)\n\t\t\tthis._initChart(container);\n\t\t\tthis._initButton(container);\n\t\t\tthis._initSummary(container);\n\t\t\tthis._initMarker(map);\n\t\t\tthis._initLayer(map);\n\t\t\tthis._modulesLoaded = true;\n\t\t\tthis.fire('modules_loaded');\n\t\t});\n\n\t\tthis.fire('add');\n\n\t\treturn container;\n\t},\n\n\t/**\n\t * Clean up control code and related event listeners.\n\t * Called on control.remove().\n\t */\n\tonRemove(map) {\n\t\tthis._container = null;\n\n\t\tmap\n\t\t\t.off('zoom viewreset zoomanim', this._hideMarker, this)\n\t\t\t.off('resize', this._resetView, this)\n\t\t\t.off('resize', this._resizeChart, this)\n\t\t\t.off('mousedown', this._resetDrag, this);\n\n\t\t_.off(map.getContainer(), 'mousewheel', this._resetDrag, this);\n\t\t_.off(map.getContainer(), 'touchstart', this._resetDrag, this);\n\t\t_.off(document, 'keydown', this._onKeyDown, this);\n\n\t\tthis\n\t\t\t.off('eledata_added eledata_loaded', this._updateChart, this)\n\t\t\t.off('eledata_added eledata_loaded', this._updateSummary, this);\n\n\t\tthis.fire('remove');\n\t},\n\n\t/**\n\t * Redraws the chart control. Sometimes useful after screen resize.\n\t */\n\tredraw() {\n\t\tthis._resizeChart();\n\t},\n\n\t/**\n\t * Set default zoom level (followMarker: true).\n\t */\n\tsetZFollow(zoom) {\n\t\tthis.options.zFollow = zoom;\n\t},\n\n\t/**\n\t * Hide current elevation chart profile.\n\t */\n\tshow() {\n\t\t_.style(this._container, \"display\", \"block\");\n\t},\n\n\t/*\n\t * Parsing data either from GPX or GeoJSON and update the diagram data\n\t */\n\t_addData(d) {\n\t\tif (!d) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Standard GeoJSON\n\t\tif (d.type === \"FeatureCollection\" ) {\n\t\t\treturn _.each(d.features, feature => this._addData(feature));\n\t\t} else if (d.type === \"Feature\") {\n\t\t\tlet geom = d.geometry;\n\t\t\tif (geom) {\n\t\t\t\tswitch (geom.type) {\n\t\t\t\t\tcase 'LineString':\t\treturn this._addGeoJSONData(geom.coordinates, d.properties);\n\t\t\t\t\tcase 'MultiLineString':\treturn _.each(geom.coordinates, (coords, i) => this._addGeoJSONData(coords, d.properties, i));\n\t\t\t\t\tcase 'Point':\n\t\t\t\t\tdefault:\t\t\t\treturn console.warn('Unsopperted GeoJSON feature geometry type:' + geom.type);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\t// Fallback for leaflet layers (eg. L.Gpx)\n\t\tif (d._latlngs) {\n\t\t\treturn this._addGeoJSONData(d._latlngs, d.feature && d.feature.properties);\n\t\t}\n\n\t},\n\n\t/*\n\t * Parsing of GeoJSON data lines and their elevation in z-coordinate\n\t */\n\t_addGeoJSONData(coords, properties, nestingLevel) {\n\n\t\t// \"coordinateProperties\" property is generated inside \"@tmcw/toGeoJSON\"\n\t\tlet props = (properties && properties.coordinateProperties) || properties;\n\n\t\tcoords.forEach((point, i) => {\n\n\t\t\t// GARMIN_EXTENSIONS = [\"hr\", \"cad\", \"atemp\", \"wtemp\", \"depth\", \"course\", \"bearing\"];\n\t\t\tpoint.meta = point.meta ?? { time: null, ele: null };\n\t\t\t\n\t\t\tpoint.prev = (attr) => (attr ? this._data[i > 0 ? i - 1 : 0][attr] : this._data[i > 0 ? i - 1 : 0]);\n\n\t\t\tthis.fire(\"elepoint_init\", { point: point, props: props, id: i, isMulti: nestingLevel });\n\n\t\t\tthis._addPoint(\n\t\t\t\tpoint.lat ?? point[1], \n\t\t\t\tpoint.lng ?? point[0],\n\t\t\t\tpoint.alt ?? point.meta.ele ?? point[2]\n\t\t\t);\n\n\t\t\tthis.fire(\"elepoint_added\", { point: point, index: this._data.length - 1 });\n\n\t\t\tif (this._yCoordMin > this._data[this._data.length - 1][this.options.yAttr]) this._yCoordMin = this._data[this._data.length - 1][this.options.yAttr];\n\t\t\tif (this._yCoordMax < this._data[this._data.length - 1][this.options.yAttr]) this._yCoordMax = this._data[this._data.length - 1][this.options.yAttr];\n\t\t});\n\n\t\tthis.fire(\"eletrack_added\", { coords: coords, index: this._data.length - 1 });\n\t},\n\n\t/*\n\t * Parse and push a single (x, y, z) point to current elevation profile.\n\t */\n\t_addPoint(x, y, z) {\n\t\tif (this.options.reverseCoords) {\n\t\t\t[x, y] = [y, x];\n\t\t}\n\n\t\tthis._data.push({\n\t\t\tx: x,\n\t\t\ty: y,\n\t\t\tz: z,\n\t\t\tlatlng: L.latLng(x, y, z)\n\t\t});\n\n\t\tthis.fire(\"eledata_updated\", { index: this._data.length - 1 });\n\t},\n\n\t_addLayer(layer) {\n\t\tif (layer) this._layers.addLayer(layer)\n\t\t// Postpone adding the distance markers (lazy: true)\n\t\tif (layer && this.options.distanceMarkers && this.options.distanceMarkers.lazy) {\n\t\t\tlayer.on('add remove', ({target, type}) => L.DistanceMarkers && target instanceof L.Polyline && target[type + 'DistanceMarkers']());\n\t\t}\n\t\treturn layer;\n\t},\n\n\t_addMarker(marker) {\n\t\tif (marker) this._markers.addLayer(marker)\n\t\treturn marker;\n\t},\n\n\t/**\n\t * Initialize \"L.AlmostOver\" integration\n\t */\n\t_initAlmostOverHandler(map, layer) {\n\t\treturn (map && this.options.almostOver && !L.Browser.mobile) ? this.import([this.__LGEOMUTIL, this.__LALMOSTOVER])\n\t\t\t.then(() => {\n\t\t\t\tmap.addHandler('almostOver', L.Handler.AlmostOver)\n\t\t\t\tif (L.GeometryUtil && map.almostOver && map.almostOver.enabled()) {\n\t\t\t\t\tmap.almostOver.addLayer(layer);\n\t\t\t\t\tmap\n\t\t\t\t\t\t.on('almost:move', this._onMouseMoveLayer, this)\n\t\t\t\t\t\t.on('almost:out', this._onMouseOut, this);\n\t\t\t\t\tthis.once('eledata_clear', () => {\n\t\t\t\t\t\tmap.almostOver.removeLayer(layer);\n\t\t\t\t\t\tmap\n\t\t\t\t\t\t.off('almost:move', this._onMouseMoveLayer, this)\n\t\t\t\t\t\t.off('almost:out', this._onMouseOut, this);\n\t\t\t\t\t})\n\t\t\t\t}\n\t\t\t}) : Promise.resolve();\n\t},\n\n\t/**\n\t * Initialize \"L.DistanceMarkers\" integration\n\t */\n\t_initDistanceMarkers() {\n\t\treturn this.options.distanceMarkers ? this.import([this.__LGEOMUTIL, this.__LDISTANCEM]) : Promise.resolve();\n\t},\n\n\t/**\n\t * Initialize \"L.Control.EdgeScale\" integration\n\t */\n\t_initEdgeScale(map) {\n\t\treturn this.options.edgeScale ? this.import(this.__LEDGESCALE)\n\t\t\t.then(() => {\n\t\t\t\tmap.edgeScaleControl = map.edgeScaleControl || L.control.edgeScale('boolean' !== typeof this.options.edgeScale ? this.options.edgeScale : {}).addTo(map);\n\t\t\t}) : Promise.resolve();\n\t},\n\n\t_initHotLine(layer) {\n\t\tlet prop = typeof this.options.hotline == 'string' ? this.options.hotline : 'elevation';\n\t\treturn this.options.hotline ? this.import(this.__LHOTLINE)\n\t\t\t.then(() => {\n\t\t\t\tlayer.eachLayer((trkseg) => {\n\t\t\t\t\tif (trkseg.feature.geometry.type != \"Point\") {\n\t\t\t\t\t\tlet geo = L.geoJson(trkseg.toGeoJSON(), { coordsToLatLng: (coords) => L.latLng(coords[0], coords[1], coords[2] * (this.options.altitudeFactor || 1))});\n\t\t\t\t\t\tlet line = L.hotline(geo.toGeoJSON().features[0].geometry.coordinates, {\n\t\t\t\t\t\t\trenderer: L.Hotline.renderer(),\n\t\t\t\t\t\t\tmin: isFinite(this.track_info[prop + '_min']) ? this.track_info[prop + '_min'] : 0,\n\t\t\t\t\t\t\tmax: isFinite(this.track_info[prop + '_max']) ? this.track_info[prop + '_max'] : 1,\n\t\t\t\t\t\t\tpalette: {\n\t\t\t\t\t\t\t\t0.0: '#008800',\n\t\t\t\t\t\t\t\t0.5: '#ffff00',\n\t\t\t\t\t\t\t\t1.0: '#ff0000'\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tweight: 5,\n\t\t\t\t\t\t\toutlineColor: '#000000',\n\t\t\t\t\t\t\toutlineWidth: 1\n\t\t\t\t\t\t}).addTo(this._hotline);\n\t\t\t\t\t\tlet alpha = trkseg.options.style && trkseg.options.style.opacity || 1;\n\t\t\t\t\t\ttrkseg.on('add remove', ({type}) => {\n\t\t\t\t\t\t\ttrkseg.setStyle({opacity: (type == 'add' ? 0 : alpha)});\n\t\t\t\t\t\t\tline[(type == 'add' ? 'addTo' : 'removeFrom')](trkseg._map);\n\t\t\t\t\t\t\tif (line._renderer) line._renderer._container.parentElement.insertBefore(line._renderer._container, line._renderer._container.parentElement.firstChild);\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}) : Promise.resolve();\n\t},\n\n\t/**\n\t * Initialize \"L.AlmostOver\" and \"L.DistanceMarkers\"\n\t */\n\t_initMapIntegrations(layer) {\n\t\tlet map = this._map;\n\t\tif (map) {\n\t\t\tif (this._data.length) {\n\t\t\t\tthis._start.setLatLng(this._data[0].latlng);\n\t\t\t\tthis._end.setLatLng(this._data[this._data.length -1].latlng);\n\t\t\t}\n\t\t\tPromise.all([\n\t\t\t\tthis._initHotLine(layer),\n\t\t\t\tthis._initAlmostOverHandler(map, layer),\n\t\t\t\tthis._initDistanceMarkers(),\n\t\t\t\tthis._initEdgeScale(map),\n\t\t\t]).then(() => {\n\t\t\t\tif (this.options.polyline) {\n\t\t\t\t\tthis._layers.addLayer(layer.addTo(map)); // hotfix for: https://github.com/Raruto/leaflet-elevation/issues/233\n\t\t\t\t\tthis._circleMarkers.addTo(map);\n\t\t\t\t}\n\t\t\t\tif (this.options.autofitBounds) {\n\t\t\t\t\tthis.fitBounds(layer.getBounds());\n\t\t\t\t}\n\t\t\t\tmap.invalidateSize();\n\t\t\t});\n\t\t} else {\n\t\t\tthis.once('add', () => this._initMapIntegrations(layer));\n\t\t}\n\t},\n\n\t/*\n\t * Collapse current chart control.\n\t */\n\t_collapse() {\n\t\t_.replaceClass(this._container, 'elevation-expanded', 'elevation-collapsed');\n\t\tif (this._map) this._map.invalidateSize();\n\t},\n\n\t/*\n\t * Expand current chart control.\n\t */\n\t_expand() {\n\t\t_.replaceClass(this._container, 'elevation-collapsed', 'elevation-expanded');\n\t\tif (this._map) this._map.invalidateSize();\n\t},\n\n\t/**\n\t * Add some basic colors to leaflet canvas renderer (preferCanvas: true).\n\t */\n\t_fixCanvasPaths() {\n\t\tlet oldProto = L.Canvas.prototype._fillStroke;\n\t\tlet control = this;\n\n\t\tlet theme = this.options.theme.split(' ')[0].replace('-theme', '');\n\t\tlet color = _.Colors[theme] || {};\n\n\t\tL.Canvas.include({\n\t\t\t_fillStroke(ctx, layer) {\n\t\t\t\tif (control._layers.hasLayer(layer)) {\n\n\t\t\t\t\tlet options = layer.options;\n\n\t\t\t\t\toptions.color = control._chartEnabled ? (color.line || color.area || theme) : '#000';\n\t\t\t\t\toptions.stroke = !!options.color;\n\n\t\t\t\t\toldProto.call(this, ctx, layer);\n\n\t\t\t\t\tif (options.stroke && options.weight !== 0) {\n\t\t\t\t\t\tlet oldVal = ctx.globalCompositeOperation || 'source-over';\n\t\t\t\t\t\tctx.globalCompositeOperation = 'destination-over'\n\t\t\t\t\t\tctx.strokeStyle = color.outline || '#FFF';\n\t\t\t\t\t\tctx.lineWidth = options.weight * 1.75;\n\t\t\t\t\t\tctx.stroke();\n\t\t\t\t\t\tctx.globalCompositeOperation = oldVal;\n\t\t\t\t\t}\n\n\t\t\t\t} else {\n\t\t\t\t\toldProto.call(this, ctx, layer);\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\t},\n\n\t/**\n\t * Partial fix for initial tooltip size\n\t * \n\t * @link https://github.com/Raruto/leaflet-elevation/issues/81#issuecomment-713477050\n\t */\n\t_fixTooltipSize() {\n\t\tthis.on('elechart_init', () =>\n\t\t\tthis.once('elechart_change elechart_hover', ({data, xCoord}) => {\n\t\t\t\tif (this._chartEnabled) {\n\t\t\t\t\tthis._chart._showDiagramIndicator(data, xCoord);\n\t\t\t\t\tthis._chart._showDiagramIndicator(data, xCoord);\n\t\t\t\t}\n\t\t\t\tthis._updateMarker(data);\n\t\t\t})\n\t\t);\n\t},\n\n\t/*\n\t * Finds a data entry for the given LatLng\n\t */\n\t_findItemForLatLng(latlng) {\n\t\treturn this._data[this._chart._findIndexForLatLng(latlng)];\n\t},\n\n\t/*\n\t * Finds a data entry for the given xDiagCoord\n\t */\n\t_findItemForX(x) {\n\t\treturn this._data[this._chart._findIndexForXCoord(x)];\n\t},\n\n\t/**\n\t * Fires an event of the specified type.\n\t */\n\t_fireEvt(type, data, propagate) {\n\t\tif (this.fire) this.fire(type, data, propagate);\n\t\tif (this._map) this._map.fire(type, data, propagate);\n\t},\n\n\t/*\n\t * Hides the position/height indicator marker drawn onto the map\n\t */\n\t_hideMarker() {\n\t\tif (this.options.autohideMarker && this._marker) {\n\t\t\tthis._marker.remove();\n\t\t}\n\t},\n\n\t/**\n\t * Generate \"svg\" chart (DOM element).\n\t */\n\t_initChart(container) {\n\t\tlet opts = this.options;\n\t\tlet map = this._map;\n\n\t\tif (opts.detached) {\n\t\t\tlet { offsetWidth, offsetHeight} = this.eleDiv;\n\t\t\tif (offsetWidth > 0) opts.width = offsetWidth;\n\t\t\tif (offsetHeight > 20) opts.height = offsetHeight - 20; // 20 = horizontal scrollbar size.\n\t\t} else {\n\t\t\tlet { clientWidth } = map.getContainer();\n\t\t\topts._maxWidth = opts._maxWidth > opts.width ? opts._maxWidth : opts.width;\n\t\t\tthis._container.style.maxWidth = opts._maxWidth + 'px';\n\t\t\tif (opts._maxWidth > clientWidth) opts.width = clientWidth - 30;\n\t\t}\n\n\t\tthis\n\t\t\t.import([this.__D3, this.__LCHART])\n\t\t\t.then((m) => {\n\n\t\t\tlet chart = this._chart = new (m[1] || Elevation).Chart(opts, this);\n\t\n\t\t\tthis._x = this._chart._x;\n\t\t\tthis._y = this._chart._y;\n\t\n\t\t\td3\n\t\t\t\t.select(container)\n\t\t\t\t.call(chart.render())\n\t\n\t\t\tchart\n\t\t\t\t.on('reset_drag', this._hideMarker, this)\n\t\t\t\t.on('mouse_enter', this._onMouseEnter, this)\n\t\t\t\t.on('dragged', this._onDragEnd, this)\n\t\t\t\t.on('mouse_move', this._onMouseMove, this)\n\t\t\t\t.on('mouse_out', this._onMouseOut, this)\n\t\t\t\t.on('ruler_filter', this._onRulerFilter, this)\n\t\t\t\t.on('zoom', this._updateChart, this)\n\t\t\t\t.on('elepath_toggle', this._onToggleChart, this)\n\t\t\t\t.on('margins_updated', this._resizeChart, this);\n\t\n\t\n\t\t\tthis.fire(\"elechart_init\");\n\n\t\t\tmap\n\t\t\t\t.on('zoom viewreset zoomanim', this._hideMarker, this)\n\t\t\t\t.on('resize', this._resetView, this)\n\t\t\t\t.on('resize', this._resizeChart, this)\n\t\t\t\t.on('rotate', this._rotateMarker, this)\n\t\t\t\t.on('mousedown', this._resetDrag, this);\n\n\t\t\t_.on(map.getContainer(), 'mousewheel', this._resetDrag, this);\n\t\t\t_.on(map.getContainer(), 'touchstart', this._resetDrag, this);\n\t\t\t_.on(document, 'keydown', this._onKeyDown, this);\n\n\t\t\tthis\n\t\t\t\t.on('eledata_added eledata_loaded', this._updateChart, this)\n\t\t\t\t.on('eledata_added eledata_loaded', this._updateSummary, this);\n\n\t\t\tthis._updateChart();\n\t\t\tthis._updateSummary();\n\t\t\tmap.invalidateSize();\n\t\t});\n\n\n\t},\n\n\t_initLayer() {\n\t\tthis._layers\n\t\t\t.on('layeradd layerremove', ({layer, type}) => {\n\t\t\t\tlet node = layer.getElement && layer.getElement();\n\t\t\t\t_.toggleClass(node, this.options.polyline.className + ' ' + this.options.theme, type == 'layeradd');\n\t\t\t\t_.toggleEvent(layer, \"mousemove\", this._onMouseMoveLayer.bind(this), type == 'layeradd')\n\t\t\t\t_.toggleEvent(layer, \"mouseout\", this._onMouseOut.bind(this), type == 'layeradd');\n\t\t\t});\n\t},\n\n\t_initMarker(map) {\n\t\tlet pane = map.getPane('elevationPane');\n\t\tif (!pane) {\n\t\t\tpane = this._pane = map.createPane('elevationPane', map.getPane('norotatePane') || map.getPane('mapPane'));\n\t\t\tpane.style.zIndex = 625; // This pane is above markers but below popups.\n\t\t\tpane.style.pointerEvents = 'none';\n\t\t}\n\n\t\tif (this._renderer) this._renderer.remove()\n\t\tthis._renderer = L.svg({ pane: \"elevationPane\" }).addTo(this._map); // default leaflet svg renderer\n\n\t\tthis.import([this.__D3, this.__LMARKER])\n\t\t\t.then((m) => {\n\t\t\t\tthis._marker = new (m[1] || Elevation).Marker(this.options, this);\n\t\t\t\tthis.fire(\"elechart_marker\");\n\t\t\t});\n\t},\n\n\t/**\n\t * Inspired by L.Control.Layers\n\t */\n\t_initButton(container) {\n\t\tL.DomEvent\n\t\t\t.disableClickPropagation(container)\n\t\t\t.disableScrollPropagation(container);\n\n\t\tthis.options.collapsed ? this._collapse() : this._expand();\n\n\t\tif (this.options.autohide) {\n\t\t\t_.on(container, 'mouseover', this._expand, this);\n\t\t\t_.on(container, 'mouseout', this._collapse, this);\n\t\t\tthis._map.on('click', this._collapse, this);\n\t\t}\n\n\t\tif (this.options.closeBtn) {\n\t\t\tlet link = this._button = _.create('a', \"elevation-toggle-icon\", { href: '#', title: L._('Elevation'), }, container);\n\t\t\t_.on(link, 'click', L.DomEvent.stop);\n\t\t\t_.on(link, 'click', this._toggle, this);\n\t\t\t_.on(link, 'focus', this._toggle, this);\n\t\t\tfetch(_.resolveURL(this.__btnIcon, this.options.srcFolder)).then(r => r.ok && r.text().then(img => link.innerHTML = img));\n\t\t}\n\t},\n\n\t_initSummary(container) {\n\t\tthis.import(this.__LSUMMARY).then((m)=>{\n\t\t\tthis._summary = new (m || Elevation).Summary({ summary: this.options.summary }, this);\n\n\t\t\tthis.on('elechart_init', () => {\n\t\t\t\td3.select(container).call(this._summary.render());\n\t\t\t});\n\t\t});\n\t},\n\n\t/**\n\t * Retrieve data from a remote url (HTTP).\n\t */\n\t_loadFile(url) {\n\t\tfetch(url)\n\t\t\t.then((response) => response.text())\n\t\t\t.then((data) => {\n\t\t\t\tthis._downloadURL = url; // TODO: handle multiple urls?\n\t\t\t\tthis._parseFromString(data)\n\t\t\t\t\t.then( geojson => geojson && this._loadLayer(geojson));\n\t\t\t}).catch((err) => console.warn(err));\n\t},\n\n\t/**\n\t * Dynamically import only required javascript modules (code splitting)\n\t */\n\t_loadModules(handlers) {\n\t\t// First map known classnames (eg. \"Altitude\" --> L.Control.Elevation.Altitude)\n\t\thandlers = handlers.map((h) => typeof h === 'string' && typeof Elevation[h] !== \"undefined\" ? Elevation[h] : h);\n\t\t// Then load optional classes and custom imports (eg. \"Cadence\" --> import('../src/handlers/cadence.js'))\n\t\tlet modules = handlers.map(file => (typeof file === 'string' && this.import(this.__modulesFolder + file.toLowerCase() + '.js')) || (file instanceof Promise && file) || Promise.resolve());\n\t\treturn Promise.all(modules).then((m) => {\n\t\t\t_.each(m, (exported, i) => {\n\t\t\t\tlet fn = exported && Object.keys(exported)[0];\n\t\t\t\tif (fn) {\n\t\t\t\t\thandlers[i] = Elevation[fn] = (Elevation[fn] ?? exported[fn]);\n\t\t\t\t}\n\t\t\t});\n\t\t\t_.each(handlers, h => [\"function\", \"object\"].includes(typeof h) && this._registerHandler(h));\n\t\t});\n\t},\n\n\t/**\n\t * Simple GeoJSON data loader (L.GeoJSON).\n\t */\n\t_loadLayer(geojson) {\n\t\tlet { polyline, theme, waypoints, wptIcons, wptLabels, distanceMarkers } = this.options;\n\t\tlet style = L.extend({}, polyline);\n\t\tlet dataAdded = [];\n\n\t\tif (theme) {\n\t\t\tstyle.className += ' ' + theme;\n\t\t}\n\n\t\tif (geojson.name) {\n\t\t\tthis.track_info.name = geojson.name;\n\t\t}\n\n\t\tlet layer = L.geoJson(geojson, {\n\t\t\tdistanceMarkers: distanceMarkers,\n\t\t\tstyle: style,\n\t\t\tpointToLayer: (feature, latlng) => {\n\t\t\t\tif (waypoints) {\n\t\t\t\t\tlet { desc, name, sym } = feature.properties;\n\t\t\t\t\tdesc = desc || '';\n\t\t\t\t\tname = name || '';\n\t\t\t\t\t// Handle chart waypoints (dots)\n\t\t\t\t\tif ([true, 'dots'].includes(waypoints)) {\n\t\t\t\t\t\tthis._registerCheckPoint({\n\t\t\t\t\t\t\tlatlng: latlng,\n\t\t\t\t\t\t\tlabel : ([true, 'dots'].includes(wptLabels) ? name : '')\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\t// Handle map waypoints (markers)\n\t\t\t\t\tif ([true, 'markers'].includes(waypoints) && wptIcons != false) {\n\t\t\t\t\t\treturn this._registerMarker({\n\t\t\t\t\t\t\tlatlng : latlng,\n\t\t\t\t\t\t\tsym : (sym ?? name).replace(/[\"']/g, '').replace(/ /g, '-').toLowerCase(),\n\t\t\t\t\t\t\tcontent: [true, 'markers'].includes(wptLabels) && (name || desc) && decodeURI(\"<b>\" + name + \"</b>\" + (desc.length > 0 ? '<br>' + desc : ''))\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tonEachFeature: (feature, layer) => feature.geometry && feature.geometry.type != 'Point' && dataAdded.push(this.addData(feature, layer)),\n\t\t});\n\n\t\tthis.import(this.__D3).then(() => Promise.all(dataAdded)).then(() => {\n\t\t\tthis._initMapIntegrations(layer);\n\t\t\tconst event_data = { data: geojson, layer: layer, name: this.track_info.name, track_info: this.track_info };\n\t\t\tif (this._modulesLoaded) {\n\t\t\t\tthis._fireEvt(\"eledata_loaded\", event_data);\n\t\t\t} else {\n\t\t\t\tthis.once('modules_loaded', () => this._fireEvt(\"eledata_loaded\", event_data));\n\t\t\t}\n\t\t});\n\n\t\treturn layer;\n\t},\n\n\t_onDragEnd({ dragstart, dragend}) {\n\t\tthis._hideMarker();\n\t\tthis.fitBounds(L.latLngBounds([dragstart.latlng, dragend.latlng]));\n\n\t\tthis.fire(\"elechart_dragged\");\n\t},\n\n\t_onKeyDown({key}) {\n\t\tif (!this.options.detached && key === \"Escape\"){\n\t\t\tthis._collapse()\n\t\t};\n\t},\n\n\t/**\n\t * Trigger mouseenter event.\n\t */\n\t_onMouseEnter() {\n\t\tthis.fire('elechart_enter');\n\t},\n\n\t/*\n\t * Handles the moueseover the chart and displays distance and altitude level.\n\t */\n\t_onMouseMove({xCoord}) {\n\t\tif (this._chartEnabled && this._data.length) {\n\t\t\tlet item = this._findItemForX(xCoord);\n\t\t\tif (item) {\n\t\t\t\tif (this._chartEnabled) this._chart._showDiagramIndicator(item, xCoord);\n\n\t\t\t\tthis._updateMarker(item);\n\t\t\t\tthis._setMapView(item);\n\n\t\t\t\tif (this._map) {\n\t\t\t\t\t_.addClass(this._map.getContainer(), 'elechart-hover');\n\t\t\t\t}\n\n\t\t\t\tthis.fire(\"elechart_change\", { data: item, xCoord: xCoord });\n\t\t\t\tthis.fire(\"elechart_hover\", { data: item, xCoord: xCoord });\n\t\t\t}\n\t\t}\n\t},\n\n\t/*\n\t * Handles mouseover events of the data layers on the map.\n\t */\n\t_onMouseMoveLayer({latlng}) {\n\t\tif (this._data.length) {\n\t\t\tlet item = this._findItemForLatLng(latlng);\n\t\t\tif (item) {\n\t\t\t\tlet xCoord = item.xDiagCoord;\n\t\n\t\t\t\tif (this._chartEnabled) this._chart._showDiagramIndicator(item, xCoord);\n\t\n\t\t\t\tthis._updateMarker(item);\n\t\n\t\t\t\tthis.fire(\"elechart_change\", { data: item, xCoord: xCoord });\n\t\t\t}\n\t\t}\n\t},\n\n\t/*\n\t * Handles the moueseout over the chart.\n\t */\n\t_onMouseOut() {\n\t\tif (!this.options.detached) {\n\t\t\tthis._hideMarker();\n\t\t\tthis._chart._hideDiagramIndicator();\n\t\t}\n\n\t\tif (this._map) {\n\t\t\t_.removeClass(this._map.getContainer(), 'elechart-hover');\n\t\t}\n\n\t\tthis.fire(\"elechart_leave\");\n\t},\n\n\t/**\n\t * Handles the drag event over the ruler filter.\n\t */\n\t_onRulerFilter({coords}) {\n\t\tthis._updateMapSegments(coords);\n\t},\n\n\t/**\n\t * Toggle chart data on legend click\n\t */\n\t_onToggleChart({ name, enabled }) {\n\n\t\tthis._chartEnabled = this._chart._hasActiveLayers();\n\n\t\t// toggle layer visibility on empty chart\n\t\tthis._layers.eachLayer(layer => {\n\t\t\t_.toggleClass(layer.getElement && layer.getElement(), this.options.polyline.className + ' ' + this.options.theme, this._chartEnabled);\n\t\t\tif (layer._renderer instanceof L.Canvas) layer.redraw();\n\t\t});\n\n\t\t// toggle option value (eg. altitude = { 'disabled' || 'enabled' })\n\t\tthis.options[name] = !enabled && this.options[name] == 'disabled' ? 'enabled' : 'disabled';\n\n\t\t// remove marker on empty chart\n\t\tif (!this._chartEnabled) {\n\t\t\tthis._chart._hideDiagramIndicator();\n\t\t\tthis._marker.remove();\n\t\t}\n\t},\n\n\t/**\n\t * Simple GeoJSON Parser\n\t */\n\t_parseFromGeoJSONString(data) {\n\t\ttry {\n\t\t\treturn JSON.parse(data);\n\t\t} catch (e) { }\n\t},\n\n\t/**\n\t * Attempt to parse raw response data (GeoJSON or XML > GeoJSON)\n\t */\n\t_parseFromString(data) {\n\t\treturn new Promise(resolve =>\n\t\t\tthis.import(this.__TOGEOJSON).then(() => {\n\t\t\t\tlet geojson;\n\t\t\t\ttry {\n\t\t\t\t\tgeojson = this._parseFromXMLString(data.trim());\n\t\t\t\t} catch (e) {\n\t\t\t\t\tgeojson = this._parseFromGeoJSONString(data.toString());\n\t\t\t\t}\n\t\t\t\tif (geojson) {\n\t\t\t\t\tgeojson.name = geojson.name || (this._downloadURL || '').split('/').pop().split('#')[0].split('?')[0];\n\t\t\t\t}\n\t\t\t\tresolve(geojson);\n\t\t\t})\n\t\t);\n\t},\n\n\t/**\n\t * Simple XML Parser (GPX, KML, TCX)\n\t */\n\t_parseFromXMLString(data) {\n\t\tif (data.indexOf(\"<\") != 0) {\n\t\t\tthrow 'Invalid XML';\n\t\t}\n\t\tlet xml = (new DOMParser()).parseFromString(data, \"text/xml\");\n\t\tlet type = xml.documentElement.tagName.toLowerCase(); // \"kml\" or \"gpx\"\n\t\tlet name = xml.getElementsByTagName('name');\n\t\tif (xml.getElementsByTagName('parsererror').length) {\n\t\t\tthrow 'Invalid XML';\n\t\t}\n\t\tif (!(type in toGeoJSON)) {\n\t\t\ttype = xml.documentElement.tagName == \"TrainingCenterDatabase\" ? 'tcx' : 'gpx';\n\t\t}\n\t\tlet geojson = toGeoJSON[type](xml);\n\t\tgeojson.name = name.length > 0 ? (Array.from(name).find(tag => tag.parentElement.tagName == \"trk\") ?? name[0]).textContent : '';\n\t\treturn geojson;\n\t},\n\n\t/**\n\t * Add chart profile to diagram\n\t */\n\t_registerAreaPath(props) {\n\t\tthis.on(\"elechart_init\", () => this._chart._registerAreaPath(props));\n\t},\n\n\t/**\n\t * Add chart grid to diagram\n\t */\n\t_registerAxisGrid(props) {\n\t\tthis.on(\"elechart_axis\", () => this._chart._registerAxisGrid(props));\n\t},\n\n\t/**\n\t * Add chart axis to diagram\n\t */\n\t_registerAxisScale(props) {\n\t\tthis.on(\"elechart_axis\", () => this._chart._registerAxisScale(props));\n\t},\n\n\t/**\n\t * Add a point of interest over the diagram\n\t */\n\t_registerCheckPoint(props) {\n\t\tconst cb = () => this._chart._registerCheckPoint(props);\n\t\tthis\n\t\t\t.on(\"elechart_updated\", cb)\n\t\t\t.once(\"eledata_clear\", () => this.off(\"elechart_updated\", cb));\n\t},\n\n\t/**\n\t * Base handler for iterative track statistics (dist, time, z, slope, speed, acceleration, ...)\n\t */\n\t _registerDataAttribute(props) {\n\n\t\t// parse of \"coordinateProperties\" for later usage\n\t\tif (props.coordPropsToMeta) {\n\t\t\tthis.on(\"elepoint_init\", (e) => props.coordPropsToMeta.call(this, e));\n\t\t}\n\n\t\t// prevent excessive variabile instanstations\n\t\tlet i, curr, prev, attr = props.attr || props.name;\n\n\t\t// save here a reference to last used point\n\t\tlet lastValid = {};\n\n\t\t// iteration\n\t\tthis.on(\"elepoint_added\", ({index, point}) => {\n\t\t\ti = index;\n\n\t\t\tprev = curr ?? this._data[i]; // same as: this._data[i > 0 ? i - 1 : i]\n\t\t\tcurr = this._data[i];\n\n\t\t\t// retrieve point value\n\t\t\tcurr[attr] = props.pointToAttr.call(this, point, i);\n\n\t\t\t// check and fix missing data on last added point\n\t\t\tif (i > 0 && isNaN(prev[attr])) {\n\t\t\t\tif (!isNaN(lastValid[attr]) && !isNaN(curr[attr])) {\n\t\t\t\t\tprev[attr] = (lastValid[attr] + curr[attr]) / 2;\n\t\t\t\t} else if (!isNaN(lastValid[attr])) {\n\t\t\t\t\tprev[attr] = lastValid[attr];\n\t\t\t\t} else if (!isNaN(curr[attr])) {\n\t\t\t\t\tprev[attr] = curr[attr];\n\t\t\t\t}\n\t\t\t\t// update \"yAttr\" and \"xAttr\"\n\t\t\t\tif (props.meta) {\n\t\t\t\t\tprev[props.meta] = prev[attr];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// skip to next iteration for invalid or missing data (eg. i == 0)\n\t\t\tif (isNaN(curr[attr])) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// update reference to last used point\n\t\t\tlastValid[attr] = curr[attr];\n\n\t\t\t// Limit \"crazy\" delta values.\n\t\t\tif (props.deltaMax) {\n\t\t\t\tcurr[attr] =_.wrapDelta(curr[attr], prev[attr], props.deltaMax);\n\t\t\t}\n\t\t\t\n\t\t\t// Range of acceptable values.\n\t\t\tif (props.clampRange) {\n\t\t\t\tcurr[attr] = _.clamp(curr[attr], props.clampRange);\n\t\t\t}\n\n\t\t\t// Limit floating point precision.\n\t\t\tif (!isNaN(props.decimals)) {\n\t\t\t\tcurr[attr] = _.round(curr[attr], props.decimals);\n\t\t\t}\n\n\t\t\t// update \"track_info\" stats (min, max, avg, ...)\n\t\t\tif (props.stats) {\n\t\t\t\tfor (const key in props.stats) {\n\t\t\t\t\tlet sname = (props.statsName || attr) + (key != '' ? '_' : '');\n\t\t\t\t\tthis.track_info[sname + key] = props.stats[key].call(this, curr[attr], this.track_info[sname + key], this._data.length);\n\t\t\t\t}\n\t\t\t}\n\n\t\t\t// update here some mixins (eg. complex \"track_info\" stuff)\n\t\t\tif (props.onPointAdded) props.onPointAdded.call(this, curr[attr], i, point);\n\t\t});\n\t},\n\n\t/**\n\t * Parse a module definition and attach related function listeners\n\t */\n\t_registerHandler(props) {\n\n\t\t// eg. L.Control.Altitude\n\t\tif (typeof props === \"function\") {\n\t\t\treturn this._registerHandler(props.call(this));\n\t\t}\n\n\t\tlet {\n\t\t\tname,\n\t\t\tattr,\n\t\t\trequired,\n\t\t\tdeltaMax,\n\t\t\tclampRange,\n\t\t\tdecimals,\n\t\t\tmeta,\n\t\t\tunit,\n\t\t\tcoordinateProperties,\n\t\t\tcoordPropsToMeta,\n\t\t\tpointToAttr,\n\t\t\tonPointAdded,\n\t\t\tstats,\n\t\t\tstatsName,\n\t\t\tgrid,\n\t\t\tscale,\n\t\t\tpath,\n\t\t\ttooltip,\n\t\t\tsummary\n\t\t} = props;\n\n\t\t// eg. \"altitude\" == true\n\t\tif (this.options[name] || required) {\n\n\t\t\tthis._registerDataAttribute({\n\t\t\t\tname,\n\t\t\t\tattr,\n\t\t\t\tmeta,\n\t\t\t\tdeltaMax,\n\t\t\t\tclampRange,\n\t\t\t\tdecimals,\n\t\t\t\tcoordPropsToMeta: _.coordPropsToMeta(coordinateProperties, meta || name, coordPropsToMeta),\n\t\t\t\tpointToAttr,\n\t\t\t\tonPointAdded,\n\t\t\t\tstats,\n\t\t\t\tstatsName,\n\t\t\t});\n\n\t\t\tif (grid) {\n\t\t\t\tthis._registerAxisGrid(L.extend({ name }, grid));\n\t\t\t}\n\n\t\t\tif (this.options[name] !== \"summary\") {\n\t\t\t\tif (scale) this._registerAxisScale(L.extend({ name, label: unit }, scale));\n\t\t\t\tif (path) this._registerAreaPath(L.extend({ name }, path));\n\t\t\t}\n\n\t\t\tif (tooltip || props.tooltips) {\n\t\t\t\t_.each([tooltip, ...(props.tooltips || [])], t => t && this._registerTooltip(L.extend({ name }, t)));\n\t\t\t}\n\n\t\t\tif (summary) {\n\t\t\t\t_.each(summary, (s, k) => summary[k] = L.extend({ unit }, s));\n\t\t\t\tthis._registerSummary(summary);\n\t\t\t}\n\t\t}\n\t},\n\n\t_registerMarker({latlng, sym, content}) {\n\t\tlet { wptIcons } = this.options;\n\t\t// generate and cache appropriate icon symbol\n\t\tif (!wptIcons.hasOwnProperty(sym)) {\n\t\t\twptIcons[sym] = L.divIcon(L.extend({}, wptIcons[\"\"].options, { html: '<i class=\"elevation-waypoint-icon ' + sym + '\"></i>' } ));\n\t\t}\n\t\tlet marker = L.marker(latlng, { icon: wptIcons[sym] });\n\t\tif (content) {\n\t\t\tmarker.bindPopup(content, { className: 'elevation-popup', keepInView: true }).openPopup();\n\t\t\tmarker.bindTooltip(content, { className: 'elevation-tooltip', direction: 'auto', sticky: true, opacity: 1 }).openTooltip();\n\t\t}\n\t\treturn this._addMarker(marker)\n\t},\n\t\n\t/**\n\t * Add chart or marker tooltip info\n\t */\n\t_registerTooltip(props) {\n\t\tprops.chart && this.on(\"elechart_init\", () => this._chart._registerTooltip(L.extend({}, props, { value: props.chart })));\n\t\tprops.marker && this.on(\"elechart_marker\", () => this._marker._registerTooltip(L.extend({}, props, { value: props.marker })));\n\t},\n\n\t/**\n\t * Add summary info to diagram\n\t */\n\t_registerSummary(props) {\n\t\tthis.on('elechart_summary', () => this._summary._registerSummary(props));\n\t},\n\n\t/*\n\t * Removes the drag rectangle and zoms back to the total extent of the data.\n\t */\n\t_resetDrag() {\n\t\tthis._chart._resetDrag();\n\t\tthis._hideMarker();\n\t},\n\n\t/**\n\t * Resets drag, marker and bounds.\n\t */\n\t_resetView() {\n\t\tif (this._map && this._map._isFullscreen) return;\n\t\tthis._resetDrag();\n\t\tthis._hideMarker();\n\t\tif (this.options.autofitBounds) {\n\t\t\tthis.fitBounds();\n\t\t}\n\t},\n\n\t/**\n\t * Hacky way for handling chart resize. Deletes it and redraw chart.\n\t */\n\t_resizeChart() {\n\t\tif (this._container && _.style(this._container, \"display\") != \"none\") {\n\t\t\tlet opts = this.options;\n\t\t\tlet newWidth = opts.detached ? (this.eleDiv || this._container).offsetWidth : _.clamp(opts._maxWidth, [0, this._map.getContainer().clientWidth - 30]);\n\t\t\tif (newWidth) {\n\t\t\t\topts.width = newWidth;\n\t\t\t\tif (this._chart && this._chart._chart) {\n\t\t\t\t\tthis._chart._chart._resize(opts);\n\t\t\t\t\tthis._updateChart();\n\t\t\t\t}\n\t\t\t}\n\t\t\tthis._updateMapSegments();\n\t\t}\n\t},\n\n\t/**\n\t * Collapse or Expand chart control.\n\t */\n\t_toggle() {\n\t\t_.hasClass(this._container, \"elevation-expanded\") ? this._collapse() : this._expand();\n\t},\n\n\t/**\n\t * Update map center and zoom (followMarker: true)\n\t */\n\t_setMapView(item) {\n\t\tif (this._map && this.options.followMarker) {\n\t\t\tlet zoom = this._map.getZoom();\n\t\t\tlet z = this.options.zFollow;\n\t\t\tif (typeof z === \"number\") {\n\t\t\t\tthis._map.setView(item.latlng, (zoom < z ? z : zoom), { animate: true, duration: 0.25 });\n\t\t\t} else if (!this._map.getBounds().contains(item.latlng)) {\n\t\t\t\tthis._map.setView(item.latlng, zoom, { animate: true, duration: 0.25 });\n\t\t\t}\n\t\t}\n\t},\n\n\t/**\n\t * Calculates [x, y] domain and then update chart.\n\t */\n\t_updateChart() {\n\t\tif (this._chart && this._container) {\n\t\t\tthis.fire(\"elechart_axis\");\n\t\n\t\t\tthis._chart.update({ data: this._data, options: this.options });\n\t\n\t\t\tthis._x = this._chart._x;\n\t\t\tthis._y = this._chart._y;\n\t\n\t\t\tthis.fire('elechart_updated');\t\t\n\t\t}\n\t},\n\n\t/*\n\t * Update the position/height indicator marker drawn onto the map\n\t */\n\t_updateMarker(item) {\n\t\tif (this._marker) {\n\t\t\tthis._marker.update({\n\t\t\t\tmap : this._map,\n\t\t\t\titem : item,\n\t\t\t\tyCoordMin : this._yCoordMin,\n\t\t\t\tyCoordMax : this._yCoordMax || 0,\n\t\t\t\toptions : this.options\n\t\t\t});\n\t\t}\n\t},\n\n\t/**\n\t * Fix marker rotation on rotated maps\n\t */\n\t_rotateMarker() {\n\t\tif (this._marker) {\n\t\t\tthis._marker.update();\n\t\t}\n\t},\n\n\t/**\n\t * Highlight track segments on the map.\n\t */\n\t_updateMapSegments(coords) {\n\t\tthis._markedSegments.setLatLngs(coords || []);\n\t\tif (coords && this._map && !this._map.hasLayer(this._markedSegments)) {\n\t\t\tthis._markedSegments.addTo(this._map);\n\t\t}\n\t},\n\n\t/**\n\t * Update chart summary.\n\t */\n\t_updateSummary() {\n\t\tif (this._summary) {\n\t\t\tthis._summary.reset();\n\t\t\tif (this.options.summary) {\n\t\t\t\tthis.fire(\"elechart_summary\");\n\t\t\t\tthis._summary.update();\n\t\t\t}\n\t\t\tif (this.options.downloadLink && this._downloadURL) { // TODO: generate dynamically file content instead of using static file urls.\n\t\t\t\tthis._summary._container.innerHTML += '<span class=\"download\"><a href=\"#\">' + L._('Download') + '</a></span>'\n\t\t\t\t_.select('.download a', this._summary._container).onclick = (e) => {\n\t\t\t\t\te.preventDefault();\n\t\t\t\t\tlet event = { downloadLink: this.options.downloadLink, confirm: _.saveFile.bind(this, this._downloadURL) };\n\t\t\t\t\tif (this.options.downloadLink == 'modal' && typeof CustomEvent === \"function\") {\n\t\t\t\t\t\tdocument.dispatchEvent(new CustomEvent(\"eletrack_download\", { detail: event }));\n\t\t\t\t\t} else if (this.options.downloadLink == 'link' || this.options.downloadLink === true) {\n\t\t\t\t\t\tevent.confirm();\n\t\t\t\t\t}\n\t\t\t\t\tthis.fire('eletrack_download', event);\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t},\n\n\n\t/**\n\t * Calculates chart width.\n\t */\n\t_width() {\n\t\tif (this._chart) return this._chart._width();\n\t\tconst { width, margins } = this.options;\n\t\treturn width - margins.left - margins.right;\n\t},\n\n\t/**\n\t * Calculates chart height.\n\t */\n\t_height() {\n\t\tif (this._chart) return this._chart._height();\n\t\tconst { height, margins } = this.options;\n\t\treturn height - margins.top - margins.bottom;\n\t},\n\n});\n", "/*\n * Copyright (c) 2019, GPL-3.0+ Project, Raruto\n *\n * This file is free software: you may copy, redistribute and/or modify it\n * under the terms of the GNU General Public License as published by the\n * Free Software Foundation, either version 2 of the License, or (at your\n * option) any later version.\n *\n * This file is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU\n * General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program. If not, see .\n *\n * This file incorporates work covered by the following copyright and\n * permission notice:\n *\n * Copyright (c) 2013-2016, MIT License, Felix \u201CMrMufflon\u201D Bache\n *\n * Permission to use, copy, modify, and/or distribute this software\n * for any purpose with or without fee is hereby granted, provided\n * that the above copyright notice and this permission notice appear\n * in all copies.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL\n * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE\n * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR\n * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS\n * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,\n * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN\n * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n */\n\nimport * as _ from './utils';\nimport { Elevation } from './control';\n\nElevation.Utils = _;\n\nL.control.elevation = (options) => new Elevation(options);\n"],
5
+ "mappings": ";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,MAAM,SAAS;AAAA,IACrB,aAAa,EAAE,MAAM,WAAW,OAAO,MAAM,QAAQ,UAAU;AAAA,IAC/D,WAAa,EAAE,MAAM,UAAU;AAAA,IAC/B,UAAa,EAAE,MAAM,OAAO;AAAA,IAC5B,UAAa,EAAE,MAAM,UAAU;AAAA,IAC/B,aAAa,EAAE,MAAM,UAAU;AAAA,IAC/B,OAAa,EAAE,MAAM,OAAO;AAAA,IAC5B,QAAa,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,EACjD;AAEA,MAAM,MAAO;AACb,MAAM,MAAO,MAAM;AACnB,MAAM,OAAO,MAAM;AACnB,MAAM,MAAO,OAAO;AAEb,WAAS,WAAW,KAAK,SAAS;AACxC,WAAQ,IAAI,IAAI,KAAM,IAAI,WAAW,KAAK,KAAK,IAAI,WAAW,IAAI,IAAK,UAAU,MAA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7
  }
@@ -1 +1 @@
1
- (()=>{var it=Object.defineProperty;var at=(t,e)=>{for(var i in e)it(t,i,{get:e[i],enumerable:!0})};var I={};at(I,{Colors:()=>x,addClass:()=>y,append:()=>N,clamp:()=>P,cloneDeep:()=>F,coordPropsToMeta:()=>R,create:()=>k,drawCanvas:()=>rt,each:()=>m,formatDate:()=>ot,formatTime:()=>st,hasClass:()=>J,iAvg:()=>_t,iMax:()=>ht,iMin:()=>dt,iSum:()=>ct,insert:()=>U,off:()=>M,on:()=>d,parseDate:()=>nt,parseNumeric:()=>Q,randomId:()=>j,removeClass:()=>v,replaceClass:()=>O,resolveURL:()=>E,round:()=>W,saveFile:()=>B,select:()=>T,setAttributes:()=>$,style:()=>g,throttle:()=>H,toggleClass:()=>D,toggleEvent:()=>A,toggleStyle:()=>lt,wrapDelta:()=>V,wrapNum:()=>mt});var x={lightblue:{area:"#3366CC",alpha:.45,stroke:"#3366CC"},magenta:{area:"#FF005E"},yellow:{area:"#FF0"},purple:{area:"#732C7B"},steelblue:{area:"#4682B4"},red:{area:"#F00"},lime:{area:"#9CC222",line:"#566B13"}},q=1e3,G=q*60,b=G*60,S=b*24;function E(t,e){return new URL(t,t.startsWith("../")||t.startsWith("./")?e:void 0).toString()}function st(t){let e=Math.floor(t/S),i=Math.floor((t-e*S)/b),s=Math.floor((t-e*S-i*b)/G),a=Math.round((t-e*S-i*b-s*G)/q);return a===60&&(s++,a=0),s===60&&(i++,s=0),i===24&&(e++,i=0),(e?e+"d ":"")+i.toString().padStart(2,0)+":"+s.toString().padStart(2,0)+"'"+a.toString().padStart(2,0)+'"'}function ot(t){if(t){if(t=="time")return e=>new Date(e).toLocaleTimeString();if(t=="date")return e=>new Date(e).toLocaleDateString()}else return e=>new Date(e).toLocaleString().replaceAll("/","-").replaceAll(","," ");return e=>t(e)}function B(t,e){let i=k("a","",{href:t,target:"_new",download:e||"",style:"display:none;"}),s=document.body;s.appendChild(i),i.click(),s.removeChild(i)}function rt(t,e){e.classed("canvas-path",!0),t.beginPath(),t.moveTo(0,0);let i=new Path2D(e.attr("d"));t.strokeStyle=e.__strokeStyle||e.attr("stroke"),t.fillStyle=e.__fillStyle||e.attr("fill"),t.lineWidth=1.25,t.globalCompositeOperation="source-over",t.globalAlpha=e.attr("stroke-opacity")||.3,t.stroke(i),t.globalAlpha=e.attr("fill-opacity")||.45,t.fill(i),t.globalAlpha=1,t.closePath()}function R(t,e,i){return t&&(({props:s,point:a,id:o,isMulti:r})=>{if(s){for(let n of t)if(n in s){a.meta[e]=(i||Q).call(this,r?s[n][r]:s[n],o);break}}})}var Q=(t,e)=>parseInt(typeof t=="object"?t[e]:t),nt=(t,e)=>new Date(Date.parse(typeof t=="object"?t[e]:t)),y=(t,e)=>t&&e.split(" ").every(i=>i&&L.DomUtil.addClass(t,i)),v=(t,e)=>t&&e.split(" ").every(i=>i&&L.DomUtil.removeClass(t,i)),D=(t,e,i)=>(i?y:v)(t,e),O=(t,e,i)=>e&&v(t,e)||i&&y(t,i),g=(t,e,i)=>typeof i>"u"&&L.DomUtil.getStyle(t,e)||t.style.setProperty(e,i),lt=(t,e,i,s)=>g(t,e,s?i:""),$=(t,e)=>{for(let i in e)t.setAttribute(i,e[i])},A=(t,e,i,s)=>t[s?"on":"off"](e,i),k=(t,e,i,s)=>{let a=L.DomUtil.create(t,e||"");return i&&$(a,i),s&&N(s,a),a},N=(t,e)=>t.appendChild(e),U=(t,e,i)=>t.insertAdjacentElement(i,e),T=(t,e)=>(e||document).querySelector(t),m=(t,e)=>{for(let i in t)e(t[i],i)},j=()=>Math.random().toString(36).substr(2,9),ht=(t,e=-1/0)=>t>e?t:e,dt=(t,e=1/0)=>t<e?t:e,_t=(t,e=0,i=1)=>(t+e*(i-1))/i,ct=(t,e=0)=>t+e,{on:d,off:M}=L.DomEvent,{throttle:H,wrapNum:mt}=L.Util,{hasClass:J}=L.DomUtil,W=L.Util.formatNum,P=(t,e)=>e?t<e[0]?e[0]:t>e[1]?e[1]:t:t,V=(t,e,i)=>Math.abs(t-e)>i?e+i*Math.sign(t-e):t;function F(t,e=[],i=[]){switch(!t||typeof t){case"object":let s=i.filter(o=>t===o.original)[0];if(s)return s.copy;let a=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return i.push({original:t,copy:a}),Object.getOwnPropertyNames(t).forEach(function(o){let r=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(a,o,r.get||r.set?r:{writable:r.writable,configurable:r.configurable,enumerable:r.enumerable,value:e.includes(o)?r.value:F(r.value,e,i)})}),a;case"function":case"symbol":console.warn("cloneDeep: "+typeof t+"s not fully supported:",t);default:return t}}var p={autofitBounds:!0,autohide:!1,autohideMarker:!0,almostover:!0,altitude:!0,closeBtn:!0,collapsed:!1,detached:!0,distance:!0,distanceMarkers:{lazy:!0,distance:!0,direction:!0},dragging:!L.Browser.mobile,downloadLink:"link",elevationDiv:"#elevation-div",edgeScale:{bar:!0,icon:!1,coords:!1},followMarker:!0,imperial:!1,legend:!0,handlers:["Distance","Time","Altitude","Slope","Speed","Acceleration"],hotline:"elevation",marker:"elevation-line",markerIcon:L.divIcon({className:"elevation-position-marker",html:'<i class="elevation-position-icon"></i>',iconSize:[32,32],iconAnchor:[16,16]}),position:"topright",polyline:{className:"elevation-polyline",color:"#000",opacity:.75,weight:5,lineCap:"round"},polylineSegments:{className:"elevation-polyline-segments",color:"#F00",interactive:!1},preferCanvas:!1,reverseCoords:!1,ruler:!0,theme:"lightblue-theme",summary:"inline",slope:!1,speed:!1,time:!0,timeFactor:3600,timestamps:!1,trkStart:{className:"start-marker",radius:6,weight:2,color:"#fff",fillColor:"#00d800",fillOpacity:1,interactive:!1},trkEnd:{className:"end-marker",radius:6,weight:2,color:"#fff",fillColor:"#ff0606",fillOpacity:1,interactive:!1},waypoints:!0,wptIcons:{"":L.divIcon({className:"elevation-waypoint-marker",html:'<i class="elevation-waypoint-icon default"></i>',iconSize:[30,30],iconAnchor:[8,30]})},wptLabels:!0,xAttr:"dist",xLabel:"km",yAttr:"z",yLabel:"m",zFollow:!1,zooming:!L.Browser.Mobile,margins:{top:30,right:30,bottom:30,left:40},height:screen.height*.3||200,width:screen.width*.6||600,xTicks:void 0,yTicks:void 0,decimalsX:2,decimalsY:0,forceAxisBounds:!1,interpolation:"curveLinear",yAxisMax:void 0,yAxisMin:void 0,srcFolder:(document.currentScript&&document.currentScript.src||null||document.baseURI).split("/").slice(0,-1).join("/")+"/"};(!L._||!L.i18n)&&(L._=L.i18n=(t,e)=>t);var _=L.Control.Elevation=L.Control.extend({includes:L.Evented?L.Evented.prototype:L.Mixin.Events,options:p,__mileFactor:.621371,__footFactor:3.28084,__D3:"https://unpkg.com/d3@7.8.4/dist/d3.min.js",__TOGEOJSON:"https://unpkg.com/@tmcw/togeojson@5.6.2/dist/togeojson.umd.js",__LGEOMUTIL:"https://unpkg.com/leaflet-geometryutil@0.10.1/src/leaflet.geometryutil.js",__LALMOSTOVER:"https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js",__LHOTLINE:"../libs/leaflet-hotline.min.js",__LDISTANCEM:"../libs/leaflet-distance-marker.min.js",__LEDGESCALE:"../libs/leaflet-edgescale.min.js",__LCHART:"../src/components/chart.js",__LMARKER:"../src/components/marker.js",__LSUMMARY:"../src/components/summary.js",__modulesFolder:"../src/handlers/",__btnIcon:"../images/elevation.svg",addData(t,e){this.import(this.__D3).then(()=>{this._modulesLoaded?(e=e??(t.on&&t),this._addData(t),this._addLayer(e),this._fireEvt("eledata_added",{data:t,layer:e,track_info:this.track_info})):this.once("modules_loaded",()=>this.addData(t,e))})},addTo(t){if(this.options.detached){let e=T(this.options.elevationDiv),i=this.onAdd(t);e?N(e,i):U(t.getContainer(),i,"afterend")}else L.Control.prototype.addTo.call(this,t);return this},clear(){this._marker&&this._marker.remove(),this._chart&&this._clearChart(),this._layers&&this._clearLayers(this._layers),this._markers&&this._clearLayers(this._markers),this._circleMarkers&&this._circleMarkers.remove(),this._hotline&&this._hotline.eachLayer(t=>t.options.renderer.remove()),this._hotline&&this._clearLayers(this._hotline),this._data=[],this.track_info={},this._yCoordMin=0,this._yCoordMax=-1/0,this._fireEvt("eledata_clear"),this._updateChart()},_clearChart(){this._events&&this._events.elechart_updated&&this._events.elechart_updated.forEach(({fn:t,ctx:e})=>this.off("elechart_updated",t,e)),this._chart&&this._chart._container&&(this._chart._container.selectAll("g.point .point").remove(),this._chart.clear())},_clearLayers(t){t=t||this._layers,t&&t.eachLayer&&(t.eachLayer(e=>e.remove()),t.clearLayers())},disableBrush(){this._chart._brushEnabled=!1,this._resetDrag()},enableBrush(){this._chart._brushEnabled=!0},disableZoom(){this._chart._zoomEnabled=!1,this._chart._resetZoom()},enableZoom(){this._chart._zoomEnabled=!0},fitBounds(t){t=t||this.getBounds(),this._map&&t.isValid()&&this._map.fitBounds(t)},getBounds(t){return L.latLngBounds((t||this._data).map(e=>e.latlng))},getZFollow(){return this.options.zFollow},hide(){g(this._container,"display","none")},initialize(t){t=L.setOptions(this,L.extend({},F(p),t)),this._data=[],this._layers=L.featureGroup(),this._markers=L.featureGroup(),this._hotline=L.featureGroup(),this._circleMarkers=L.featureGroup(),this._markedSegments=L.polyline([]),this._start=L.circleMarker([0,0],t.trkStart||p.trkStart),this._end=L.circleMarker([0,0],t.trkEnd||p.trkEnd),this._chartEnabled=!0,this._yCoordMin=0,this._yCoordMax=-1/0,this.track_info={},t.followMarker&&(this._setMapView=H(this._setMapView,300,this)),t.legend&&(t.margins.bottom+=30),t.theme&&(t.polylineSegments.className+=" "+t.theme),t.wptIcons===!0&&(t.wptIcons=p.wptIcons),t.distanceMarkers===!0&&(t.distanceMarkers=p.distanceMarkers),t.trkStart&&this._start.addTo(this._circleMarkers),t.trkEnd&&this._end.addTo(this._circleMarkers),this._markedSegments.setStyle(t.polylineSegments),L.extend(x,t.colors||{}),this._fixCanvasPaths(),this._fixTooltipSize()},import(t,e){if(Array.isArray(t))return Promise.all(t.map(i=>this.import(i)));switch(t){case this.__D3:e=typeof d3!="object";break;case this.__TOGEOJSON:e=typeof toGeoJSON!="object";break;case this.__LGEOMUTIL:e=typeof L.GeometryUtil!="object";break;case this.__LALMOSTOVER:e=typeof L.Handler.AlmostOver!="function";break;case this.__LDISTANCEM:e=typeof L.DistanceMarkers!="function";break;case this.__LEDGESCALE:e=typeof L.Control.EdgeScale!="function";break;case this.__LHOTLINE:e=typeof L.Hotline!="function";break}return e!==!1?import(E(t,this.options.srcFolder)):Promise.resolve()},load(t){this._parseFromString(t).then(e=>e?this._loadLayer(e):this._loadFile(t))},onAdd(t){this._map=t;let e=this._container=k("div","elevation-control "+this.options.theme+" "+(this.options.detached?"elevation-detached":"leaflet-control"),this.options.detached?{id:"elevation-"+j()}:{});return this.eleDiv||(this.eleDiv=e),this._loadModules(this.options.handlers).then(()=>{this._initChart(e),this._initButton(e),this._initSummary(e),this._initMarker(t),this._initLayer(t),this._modulesLoaded=!0,this.fire("modules_loaded")}),this.fire("add"),e},onRemove(t){this._container=null,t.off("zoom viewreset zoomanim",this._hideMarker,this).off("resize",this._resetView,this).off("resize",this._resizeChart,this).off("mousedown",this._resetDrag,this),M(t.getContainer(),"mousewheel",this._resetDrag,this),M(t.getContainer(),"touchstart",this._resetDrag,this),M(document,"keydown",this._onKeyDown,this),this.off("eledata_added eledata_loaded",this._updateChart,this).off("eledata_added eledata_loaded",this._updateSummary,this),this.fire("remove")},redraw(){this._resizeChart()},setZFollow(t){this.options.zFollow=t},show(){g(this._container,"display","block")},_addData(t){if(t){if(t.type==="FeatureCollection")return m(t.features,e=>this._addData(e));if(t.type==="Feature"){let e=t.geometry;if(e)switch(e.type){case"LineString":return this._addGeoJSONData(e.coordinates,t.properties);case"MultiLineString":return m(e.coordinates,(i,s)=>this._addGeoJSONData(i,t.properties,s));default:return console.warn("Unsopperted GeoJSON feature geometry type:"+e.type)}}if(t._latlngs)return this._addGeoJSONData(t._latlngs,t.feature&&t.feature.properties)}},_addGeoJSONData(t,e,i){let s=e&&e.coordinateProperties||e;t.forEach((a,o)=>{a.meta=a.meta??{time:null,ele:null},a.prev=r=>r?this._data[o>0?o-1:0][r]:this._data[o>0?o-1:0],this.fire("elepoint_init",{point:a,props:s,id:o,isMulti:i}),this._addPoint(a.lat??a[1],a.lng??a[0],a.alt??a.meta.ele??a[2]),this.fire("elepoint_added",{point:a,index:this._data.length-1}),this._yCoordMin>this._data[this._data.length-1][this.options.yAttr]&&(this._yCoordMin=this._data[this._data.length-1][this.options.yAttr]),this._yCoordMax<this._data[this._data.length-1][this.options.yAttr]&&(this._yCoordMax=this._data[this._data.length-1][this.options.yAttr])}),this.fire("eletrack_added",{coords:t,index:this._data.length-1})},_addPoint(t,e,i){this.options.reverseCoords&&([t,e]=[e,t]),this._data.push({x:t,y:e,z:i,latlng:L.latLng(t,e,i)}),this.fire("eledata_updated",{index:this._data.length-1})},_addLayer(t){return t&&this._layers.addLayer(t),t&&this.options.distanceMarkers&&this.options.distanceMarkers.lazy&&t.on("add remove",({target:e,type:i})=>L.DistanceMarkers&&e instanceof L.Polyline&&e[i+"DistanceMarkers"]()),t},_addMarker(t){return t&&this._markers.addLayer(t),t},_initAlmostOverHandler(t,e){return t&&this.options.almostOver&&!L.Browser.mobile?this.import([this.__LGEOMUTIL,this.__LALMOSTOVER]).then(()=>{t.addHandler("almostOver",L.Handler.AlmostOver),L.GeometryUtil&&t.almostOver&&t.almostOver.enabled()&&(t.almostOver.addLayer(e),t.on("almost:move",this._onMouseMoveLayer,this).on("almost:out",this._onMouseOut,this),this.once("eledata_clear",()=>{t.almostOver.removeLayer(e),t.off("almost:move",this._onMouseMoveLayer,this).off("almost:out",this._onMouseOut,this)}))}):Promise.resolve()},_initDistanceMarkers(){return this.options.distanceMarkers?this.import([this.__LGEOMUTIL,this.__LDISTANCEM]):Promise.resolve()},_initEdgeScale(t){return this.options.edgeScale?this.import(this.__LEDGESCALE).then(()=>{t.edgeScaleControl=t.edgeScaleControl||L.control.edgeScale(typeof this.options.edgeScale!="boolean"?this.options.edgeScale:{}).addTo(t)}):Promise.resolve()},_initHotLine(t){let e=typeof this.options.hotline=="string"?this.options.hotline:"elevation";return this.options.hotline?this.import(this.__LHOTLINE).then(()=>{t.eachLayer(i=>{if(i.feature.geometry.type!="Point"){let s=L.geoJson(i.toGeoJSON(),{coordsToLatLng:r=>L.latLng(r[0],r[1],r[2]*(this.options.altitudeFactor||1))}),a=L.hotline(s.toGeoJSON().features[0].geometry.coordinates,{renderer:L.Hotline.renderer(),min:isFinite(this.track_info[e+"_min"])?this.track_info[e+"_min"]:0,max:isFinite(this.track_info[e+"_max"])?this.track_info[e+"_max"]:1,palette:{0:"#008800",.5:"#ffff00",1:"#ff0000"},weight:5,outlineColor:"#000000",outlineWidth:1}).addTo(this._hotline),o=i.options.style&&i.options.style.opacity||1;i.on("add remove",({type:r})=>{i.setStyle({opacity:r=="add"?0:o}),a[r=="add"?"addTo":"removeFrom"](i._map),a._renderer&&a._renderer._container.parentElement.insertBefore(a._renderer._container,a._renderer._container.parentElement.firstChild)})}})}):Promise.resolve()},_initMapIntegrations(t){let e=this._map;e?(this._data.length&&(this._start.setLatLng(this._data[0].latlng),this._end.setLatLng(this._data[this._data.length-1].latlng)),Promise.all([this._initHotLine(t),this._initAlmostOverHandler(e,t),this._initDistanceMarkers(),this._initEdgeScale(e)]).then(()=>{this.options.polyline&&(this._layers.addLayer(t.addTo(e)),this._circleMarkers.addTo(e)),this.options.autofitBounds&&this.fitBounds(t.getBounds()),e.invalidateSize()})):this.once("add",()=>this._initMapIntegrations(t))},_collapse(){O(this._container,"elevation-expanded","elevation-collapsed"),this._map&&this._map.invalidateSize()},_expand(){O(this._container,"elevation-collapsed","elevation-expanded"),this._map&&this._map.invalidateSize()},_fixCanvasPaths(){let t=L.Canvas.prototype._fillStroke,e=this,i=this.options.theme.split(" ")[0].replace("-theme",""),s=x[i]||{};L.Canvas.include({_fillStroke(a,o){if(e._layers.hasLayer(o)){let r=o.options;if(r.color=s.line||s.area||i,r.stroke=!!r.color,t.call(this,a,o),r.stroke&&r.weight!==0){let n=a.globalCompositeOperation||"source-over";a.globalCompositeOperation="destination-over",a.strokeStyle=s.outline||"#FFF",a.lineWidth=r.weight*1.75,a.stroke(),a.globalCompositeOperation=n}}else t.call(this,a,o)}})},_fixTooltipSize(){this.on("elechart_init",()=>this.once("elechart_change elechart_hover",({data:t,xCoord:e})=>{this._chartEnabled&&(this._chart._showDiagramIndicator(t,e),this._chart._showDiagramIndicator(t,e)),this._updateMarker(t)}))},_findItemForLatLng(t){return this._data[this._chart._findIndexForLatLng(t)]},_findItemForX(t){return this._data[this._chart._findIndexForXCoord(t)]},_fireEvt(t,e,i){this.fire&&this.fire(t,e,i),this._map&&this._map.fire(t,e,i)},_hideMarker(){this.options.autohideMarker&&this._marker.remove()},_initChart(t){let e=this.options,i=this._map;if(e.detached){let{offsetWidth:s,offsetHeight:a}=this.eleDiv;s>0&&(e.width=s),a>20&&(e.height=a-20)}else{let{clientWidth:s}=i.getContainer();e._maxWidth=e._maxWidth>e.width?e._maxWidth:e.width,this._container.style.maxWidth=e._maxWidth+"px",e._maxWidth>s&&(e.width=s-30)}this.import([this.__D3,this.__LCHART]).then(s=>{let a=this._chart=new(s[1]||_).Chart(e,this);this._x=this._chart._x,this._y=this._chart._y,d3.select(t).call(a.render()),a.on("reset_drag",this._hideMarker,this).on("mouse_enter",this._onMouseEnter,this).on("dragged",this._onDragEnd,this).on("mouse_move",this._onMouseMove,this).on("mouse_out",this._onMouseOut,this).on("ruler_filter",this._onRulerFilter,this).on("zoom",this._updateChart,this).on("elepath_toggle",this._onToggleChart,this).on("margins_updated",this._resizeChart,this),this.fire("elechart_init"),i.on("zoom viewreset zoomanim",this._hideMarker,this).on("resize",this._resetView,this).on("resize",this._resizeChart,this).on("rotate",this._rotateMarker,this).on("mousedown",this._resetDrag,this),d(i.getContainer(),"mousewheel",this._resetDrag,this),d(i.getContainer(),"touchstart",this._resetDrag,this),d(document,"keydown",this._onKeyDown,this),this.on("eledata_added eledata_loaded",this._updateChart,this).on("eledata_added eledata_loaded",this._updateSummary,this),this._updateChart(),this._updateSummary()})},_initLayer(){this._layers.on("layeradd layerremove",({layer:t,type:e})=>{let i=t.getElement&&t.getElement();D(i,this.options.polyline.className+" "+this.options.theme,e=="layeradd"),A(t,"mousemove",this._onMouseMoveLayer.bind(this),e=="layeradd"),A(t,"mouseout",this._onMouseOut.bind(this),e=="layeradd")})},_initMarker(t){let e=t.getPane("elevationPane");e||(e=this._pane=t.createPane("elevationPane",t.getPane("norotatePane")||t.getPane("mapPane")),e.style.zIndex=625,e.style.pointerEvents="none"),this._renderer&&this._renderer.remove(),this._renderer=L.svg({pane:"elevationPane"}).addTo(this._map),this.import([this.__D3,this.__LMARKER]).then(i=>{this._marker=new(i[1]||_).Marker(this.options,this),this.fire("elechart_marker")})},_initButton(t){if(L.DomEvent.disableClickPropagation(t).disableScrollPropagation(t),this.options.collapsed?this._collapse():this._expand(),this.options.autohide&&(d(t,"mouseover",this._expand,this),d(t,"mouseout",this._collapse,this),this._map.on("click",this._collapse,this)),this.options.closeBtn){let e=this._button=k("a","elevation-toggle-icon",{href:"#",title:L._("Elevation")},t);d(e,"click",L.DomEvent.stop),d(e,"click",this._toggle,this),d(e,"focus",this._toggle,this),fetch(E(this.__btnIcon,this.options.srcFolder)).then(i=>i.ok&&i.text().then(s=>e.innerHTML=s))}},_initSummary(t){this.import(this.__LSUMMARY).then(e=>{this._summary=new(e||_).Summary({summary:this.options.summary},this),this.on("elechart_init",()=>{d3.select(t).call(this._summary.render())})})},_loadFile(t){fetch(t).then(e=>e.text()).then(e=>{this._downloadURL=t,this._parseFromString(e).then(i=>i&&this._loadLayer(i))}).catch(e=>console.warn(e))},_loadModules(t){t=t.map(i=>typeof i=="string"&&typeof _[i]<"u"?_[i]:i);let e=t.map(i=>typeof i=="string"&&this.import(this.__modulesFolder+i.toLowerCase()+".js")||i instanceof Promise&&i||Promise.resolve());return Promise.all(e).then(i=>{m(i,(s,a)=>{let o=s&&Object.keys(s)[0];o&&(t[a]=_[o]=_[o]??s[o])}),m(t,s=>["function","object"].includes(typeof s)&&this._registerHandler(s))})},_loadLayer(t){let{polyline:e,theme:i,waypoints:s,wptIcons:a,wptLabels:o,distanceMarkers:r}=this.options,n=L.extend({},e);i&&(n.className+=" "+i),t.name&&(this.track_info.name=t.name);let h=L.geoJson(t,{distanceMarkers:r,style:n,pointToLayer:(l,u)=>{if(s){let{desc:f,name:c,sym:z}=l.properties;if(f=f||"",c=c||"",[!0,"dots"].includes(s)&&this._registerCheckPoint({latlng:u,label:[!0,"dots"].includes(o)?c:""}),[!0,"markers"].includes(s)&&a!=!1)return this._registerMarker({latlng:u,sym:(z??c).replace(/["']/g,"").replace(/ /g,"-").toLowerCase(),content:[!0,"markers"].includes(o)&&(c||f)&&decodeURI("<b>"+c+"</b>"+(f.length>0?"<br>"+f:""))})}},onEachFeature:(l,u)=>l.geometry&&l.geometry.type!="Point"&&this.addData(l,u)});return this.import(this.__D3).then(()=>{this._initMapIntegrations(h);let l={data:t,layer:h,name:this.track_info.name,track_info:this.track_info};this._modulesLoaded?this._fireEvt("eledata_loaded",l):this.once("modules_loaded",()=>this._fireEvt("eledata_loaded",l))}),h},_onDragEnd({dragstart:t,dragend:e}){this._hideMarker(),this.fitBounds(L.latLngBounds([t.latlng,e.latlng])),this.fire("elechart_dragged")},_onKeyDown({key:t}){!this.options.detached&&t==="Escape"&&this._collapse()},_onMouseEnter(){this.fire("elechart_enter")},_onMouseMove({xCoord:t}){if(this._chartEnabled&&this._data.length){let e=this._findItemForX(t);e&&(this._chartEnabled&&this._chart._showDiagramIndicator(e,t),this._updateMarker(e),this._setMapView(e),this._map&&y(this._map.getContainer(),"elechart-hover"),this.fire("elechart_change",{data:e,xCoord:t}),this.fire("elechart_hover",{data:e,xCoord:t}))}},_onMouseMoveLayer({latlng:t}){if(this._data.length){let e=this._findItemForLatLng(t);if(e){let i=e.xDiagCoord;this._chartEnabled&&this._chart._showDiagramIndicator(e,i),this._updateMarker(e),this.fire("elechart_change",{data:e,xCoord:i})}}},_onMouseOut(){this.options.detached||(this._hideMarker(),this._chart._hideDiagramIndicator()),this._map&&v(this._map.getContainer(),"elechart-hover"),this.fire("elechart_leave")},_onRulerFilter({coords:t}){this._updateMapSegments(t)},_onToggleChart({name:t,enabled:e}){this._chartEnabled=this._chart._hasActiveLayers(),this._layers.eachLayer(i=>D(i.getElement&&i.getElement(),this.options.polyline.className+" "+this.options.theme,this._chartEnabled)),this.options[t]=!e&&this.options[t]=="disabled"?"enabled":"disabled",this._chartEnabled||(this._chart._hideDiagramIndicator(),this._marker.remove())},_parseFromGeoJSONString(t){try{return JSON.parse(t)}catch{}},_parseFromString(t){return new Promise(e=>this.import(this.__TOGEOJSON).then(()=>{let i;try{i=this._parseFromXMLString(t.trim())}catch{i=this._parseFromGeoJSONString(t.toString())}i&&(i.name=i.name||(this._downloadURL||"").split("/").pop().split("#")[0].split("?")[0]),e(i)}))},_parseFromXMLString(t){if(t.indexOf("<")!=0)throw"Invalid XML";let e=new DOMParser().parseFromString(t,"text/xml"),i=e.documentElement.tagName.toLowerCase(),s=e.getElementsByTagName("name");if(e.getElementsByTagName("parsererror").length)throw"Invalid XML";i in toGeoJSON||(i=e.documentElement.tagName=="TrainingCenterDatabase"?"tcx":"gpx");let a=toGeoJSON[i](e);return a.name=s.length>0?(Array.from(s).find(o=>o.parentElement.tagName=="trk")??s[0]).textContent:"",a},_registerAreaPath(t){this.on("elechart_init",()=>this._chart._registerAreaPath(t))},_registerAxisGrid(t){this.on("elechart_axis",()=>this._chart._registerAxisGrid(t))},_registerAxisScale(t){this.on("elechart_axis",()=>this._chart._registerAxisScale(t))},_registerCheckPoint(t){let e=()=>this._chart._registerCheckPoint(t);this.on("elechart_updated",e).once("eledata_clear",()=>this.off("elechart_updated",e))},_registerDataAttribute(t){t.coordPropsToMeta&&this.on("elepoint_init",r=>t.coordPropsToMeta.call(this,r));let e,i,s,a=t.attr||t.name,o={};this.on("elepoint_added",({index:r,point:n})=>{if(e=r,s=i??this._data[e],i=this._data[e],i[a]=t.pointToAttr.call(this,n,e),e>0&&isNaN(s[a])&&(!isNaN(o[a])&&!isNaN(i[a])?s[a]=(o[a]+i[a])/2:isNaN(o[a])?isNaN(i[a])||(s[a]=i[a]):s[a]=o[a],t.meta&&(s[t.meta]=s[a])),!isNaN(i[a])){if(o[a]=i[a],t.deltaMax&&(i[a]=V(i[a],s[a],t.deltaMax)),t.clampRange&&(i[a]=P(i[a],t.clampRange)),isNaN(t.decimals)||(i[a]=W(i[a],t.decimals)),t.stats)for(let h in t.stats){let l=(t.statsName||a)+(h!=""?"_":"");this.track_info[l+h]=t.stats[h].call(this,i[a],this.track_info[l+h],this._data.length)}t.onPointAdded&&t.onPointAdded.call(this,i[a],e,n)}})},_registerHandler(t){if(typeof t=="function")return this._registerHandler(t.call(this));let{name:e,attr:i,required:s,deltaMax:a,clampRange:o,decimals:r,meta:n,unit:h,coordinateProperties:l,coordPropsToMeta:u,pointToAttr:f,onPointAdded:c,stats:z,statsName:tt,grid:X,scale:Z,path:K,tooltip:Y,summary:w}=t;(this.options[e]||s)&&(this._registerDataAttribute({name:e,attr:i,meta:n,deltaMax:a,clampRange:o,decimals:r,coordPropsToMeta:R(l,n||e,u),pointToAttr:f,onPointAdded:c,stats:z,statsName:tt}),X&&this._registerAxisGrid(L.extend({name:e},X)),this.options[e]!=="summary"&&(Z&&this._registerAxisScale(L.extend({name:e,label:h},Z)),K&&this._registerAreaPath(L.extend({name:e},K))),(Y||t.tooltips)&&m([Y,...t.tooltips||[]],C=>C&&this._registerTooltip(L.extend({name:e},C))),w&&(m(w,(C,et)=>w[et]=L.extend({unit:h},C)),this._registerSummary(w)))},_registerMarker({latlng:t,sym:e,content:i}){let{wptIcons:s}=this.options;s.hasOwnProperty(e)||(s[e]=L.divIcon(L.extend({},s[""].options,{html:'<i class="elevation-waypoint-icon '+e+'"></i>'})));let a=L.marker(t,{icon:s[e]});return i&&(a.bindPopup(i,{className:"elevation-popup",keepInView:!0}).openPopup(),a.bindTooltip(i,{className:"elevation-tooltip",direction:"auto",sticky:!0,opacity:1}).openTooltip()),this._addMarker(a)},_registerTooltip(t){t.chart&&this.on("elechart_init",()=>this._chart._registerTooltip(L.extend({},t,{value:t.chart}))),t.marker&&this.on("elechart_marker",()=>this._marker._registerTooltip(L.extend({},t,{value:t.marker})))},_registerSummary(t){this.on("elechart_summary",()=>this._summary._registerSummary(t))},_resetDrag(){this._chart._resetDrag(),this._hideMarker()},_resetView(){this._map&&this._map._isFullscreen||(this._resetDrag(),this._hideMarker(),this.options.autofitBounds&&this.fitBounds())},_resizeChart(){if(this._container&&g(this._container,"display")!="none"){let t=this.options,e=t.detached?(this.eleDiv||this._container).offsetWidth:P(t._maxWidth,[0,this._map.getContainer().clientWidth-30]);e&&(t.width=e,this._chart&&this._chart._chart&&(this._chart._chart._resize(t),this._updateChart())),this._updateMapSegments()}},_toggle(){J(this._container,"elevation-expanded")?this._collapse():this._expand()},_setMapView(t){if(this._map&&this.options.followMarker){let e=this._map.getZoom(),i=this.options.zFollow;typeof i=="number"?this._map.setView(t.latlng,e<i?i:e,{animate:!0,duration:.25}):this._map.getBounds().contains(t.latlng)||this._map.setView(t.latlng,e,{animate:!0,duration:.25})}},_updateChart(){this._chart&&this._container&&(this.fire("elechart_axis"),this._chart.update({data:this._data,options:this.options}),this._x=this._chart._x,this._y=this._chart._y,this.fire("elechart_updated"))},_updateMarker(t){this._marker&&this._marker.update({map:this._map,item:t,yCoordMin:this._yCoordMin,yCoordMax:this._yCoordMax||0,options:this.options})},_rotateMarker(){this._marker&&this._marker.update()},_updateMapSegments(t){this._markedSegments.setLatLngs(t||[]),t&&this._map&&!this._map.hasLayer(this._markedSegments)&&this._markedSegments.addTo(this._map)},_updateSummary(){this._summary&&(this._summary.reset(),this.options.summary&&(this.fire("elechart_summary"),this._summary.update()),this.options.downloadLink&&this._downloadURL&&(this._summary._container.innerHTML+='<span class="download"><a href="#">'+L._("Download")+"</a></span>",T(".download a",this._summary._container).onclick=t=>{t.preventDefault();let e={downloadLink:this.options.downloadLink,confirm:B.bind(this,this._downloadURL)};this.options.downloadLink=="modal"&&typeof CustomEvent=="function"?document.dispatchEvent(new CustomEvent("eletrack_download",{detail:e})):(this.options.downloadLink=="link"||this.options.downloadLink===!0)&&e.confirm(),this.fire("eletrack_download",e)}))},_width(){if(this._chart)return this._chart._width();let{width:t,margins:e}=this.options;return t-e.left-e.right},_height(){if(this._chart)return this._chart._height();let{height:t,margins:e}=this.options;return t-e.top-e.bottom}});_.Utils=I;L.control.elevation=t=>new _(t);})();
1
+ (()=>{var it=Object.defineProperty;var at=(t,e)=>{for(var i in e)it(t,i,{get:e[i],enumerable:!0})};var z={};at(z,{Colors:()=>E,addClass:()=>v,append:()=>P,clamp:()=>F,cloneDeep:()=>I,coordPropsToMeta:()=>U,create:()=>M,drawCanvas:()=>rt,each:()=>f,formatDate:()=>ot,formatTime:()=>st,hasClass:()=>W,iAvg:()=>_t,iMax:()=>ht,iMin:()=>dt,iSum:()=>ct,insert:()=>j,off:()=>w,on:()=>d,parseDate:()=>nt,parseNumeric:()=>$,randomId:()=>H,removeClass:()=>k,replaceClass:()=>A,resolveURL:()=>D,round:()=>V,saveFile:()=>R,select:()=>T,setAttributes:()=>tt,style:()=>y,throttle:()=>J,toggleClass:()=>O,toggleEvent:()=>N,toggleStyle:()=>lt,wrapDelta:()=>X,wrapNum:()=>mt});var E={lightblue:{area:"#3366CC",alpha:.45,stroke:"#3366CC"},magenta:{area:"#FF005E"},yellow:{area:"#FF0"},purple:{area:"#732C7B"},steelblue:{area:"#4682B4"},red:{area:"#F00"},lime:{area:"#9CC222",line:"#566B13"}},Q=1e3,B=Q*60,x=B*60,b=x*24;function D(t,e){return new URL(t,t.startsWith("../")||t.startsWith("./")?e:void 0).toString()}function st(t){let e=Math.floor(t/b),i=Math.floor((t-e*b)/x),s=Math.floor((t-e*b-i*x)/B),a=Math.round((t-e*b-i*x-s*B)/Q);return a===60&&(s++,a=0),s===60&&(i++,s=0),i===24&&(e++,i=0),(e?e+"d ":"")+i.toString().padStart(2,0)+":"+s.toString().padStart(2,0)+"'"+a.toString().padStart(2,0)+'"'}function ot(t){if(t){if(t=="time")return e=>new Date(e).toLocaleTimeString();if(t=="date")return e=>new Date(e).toLocaleDateString()}else return e=>new Date(e).toLocaleString().replaceAll("/","-").replaceAll(","," ");return e=>t(e)}function R(t,e){let i=M("a","",{href:t,target:"_new",download:e||"",style:"display:none;"}),s=document.body;s.appendChild(i),i.click(),s.removeChild(i)}function rt(t,e){e.classed("canvas-path",!0),t.beginPath(),t.moveTo(0,0);let i=new Path2D(e.attr("d"));t.strokeStyle=e.__strokeStyle||e.attr("stroke"),t.fillStyle=e.__fillStyle||e.attr("fill"),t.lineWidth=1.25,t.globalCompositeOperation="source-over",t.globalAlpha=e.attr("stroke-opacity")||.3,t.stroke(i),t.globalAlpha=e.attr("fill-opacity")||.45,t.fill(i),t.globalAlpha=1,t.closePath()}function U(t,e,i){return t&&(({props:s,point:a,id:o,isMulti:r})=>{if(s){for(let n of t)if(n in s){a.meta[e]=(i||$).call(this,r?s[n][r]:s[n],o);break}}})}var $=(t,e)=>parseInt(typeof t=="object"?t[e]:t),nt=(t,e)=>new Date(Date.parse(typeof t=="object"?t[e]:t)),v=(t,e)=>t&&e.split(" ").every(i=>i&&L.DomUtil.addClass(t,i)),k=(t,e)=>t&&e.split(" ").every(i=>i&&L.DomUtil.removeClass(t,i)),O=(t,e,i)=>(i?v:k)(t,e),A=(t,e,i)=>e&&k(t,e)||i&&v(t,i),y=(t,e,i)=>typeof i>"u"&&L.DomUtil.getStyle(t,e)||t.style.setProperty(e,i),lt=(t,e,i,s)=>y(t,e,s?i:""),tt=(t,e)=>{for(let i in e)t.setAttribute(i,e[i])},N=(t,e,i,s)=>t[s?"on":"off"](e,i),M=(t,e,i,s)=>{let a=L.DomUtil.create(t,e||"");return i&&tt(a,i),s&&P(s,a),a},P=(t,e)=>t.appendChild(e),j=(t,e,i)=>t.insertAdjacentElement(i,e),T=(t,e)=>(e||document).querySelector(t),f=(t,e)=>{for(let i in t)e(t[i],i)},H=()=>Math.random().toString(36).substr(2,9),ht=(t,e=-1/0)=>t>e?t:e,dt=(t,e=1/0)=>t<e?t:e,_t=(t,e=0,i=1)=>(t+e*(i-1))/i,ct=(t,e=0)=>t+e,{on:d,off:w}=L.DomEvent,{throttle:J,wrapNum:mt}=L.Util,{hasClass:W}=L.DomUtil,V=L.Util.formatNum,F=(t,e)=>e?t<e[0]?e[0]:t>e[1]?e[1]:t:t,X=(t,e,i)=>Math.abs(t-e)>i?e+i*Math.sign(t-e):t;function I(t,e=[],i=[]){switch(!t||typeof t){case"object":let s=i.filter(o=>t===o.original)[0];if(s)return s.copy;let a=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return i.push({original:t,copy:a}),Object.getOwnPropertyNames(t).forEach(function(o){let r=Object.getOwnPropertyDescriptor(t,o);Object.defineProperty(a,o,r.get||r.set?r:{writable:r.writable,configurable:r.configurable,enumerable:r.enumerable,value:e.includes(o)?r.value:I(r.value,e,i)})}),a;case"function":case"symbol":console.warn("cloneDeep: "+typeof t+"s not fully supported:",t);default:return t}}var u={autofitBounds:!0,autohide:!1,autohideMarker:!0,almostover:!0,altitude:!0,closeBtn:!0,collapsed:!1,detached:!0,distance:!0,distanceMarkers:{lazy:!0,distance:!0,direction:!0},dragging:!L.Browser.mobile,downloadLink:"link",elevationDiv:"#elevation-div",edgeScale:{bar:!0,icon:!1,coords:!1},followMarker:!0,imperial:!1,legend:!0,handlers:["Distance","Time","Altitude","Slope","Speed","Acceleration"],hotline:"elevation",marker:"elevation-line",markerIcon:L.divIcon({className:"elevation-position-marker",html:'<i class="elevation-position-icon"></i>',iconSize:[32,32],iconAnchor:[16,16]}),position:"topright",polyline:{className:"elevation-polyline",color:"#000",opacity:.75,weight:5,lineCap:"round"},polylineSegments:{className:"elevation-polyline-segments",color:"#F00",interactive:!1},preferCanvas:!1,reverseCoords:!1,ruler:!0,theme:"lightblue-theme",summary:"inline",slope:!1,speed:!1,time:!0,timeFactor:3600,timestamps:!1,trkStart:{className:"start-marker",radius:6,weight:2,color:"#fff",fillColor:"#00d800",fillOpacity:1,interactive:!1},trkEnd:{className:"end-marker",radius:6,weight:2,color:"#fff",fillColor:"#ff0606",fillOpacity:1,interactive:!1},waypoints:!0,wptIcons:{"":L.divIcon({className:"elevation-waypoint-marker",html:'<i class="elevation-waypoint-icon default"></i>',iconSize:[30,30],iconAnchor:[8,30]})},wptLabels:!0,xAttr:"dist",xLabel:"km",yAttr:"z",yLabel:"m",zFollow:!1,zooming:!L.Browser.Mobile,margins:{top:30,right:30,bottom:30,left:40},height:screen.height*.3||200,width:screen.width*.6||600,xTicks:void 0,yTicks:void 0,decimalsX:2,decimalsY:0,forceAxisBounds:!1,interpolation:"curveLinear",yAxisMax:void 0,yAxisMin:void 0,srcFolder:(document.currentScript&&document.currentScript.src||null||document.baseURI).split("/").slice(0,-1).join("/")+"/"};(!L._||!L.i18n)&&(L._=L.i18n=(t,e)=>t);var _=L.Control.Elevation=L.Control.extend({includes:L.Evented?L.Evented.prototype:L.Mixin.Events,options:u,__mileFactor:.621371,__footFactor:3.28084,__D3:"https://unpkg.com/d3@7.8.4/dist/d3.min.js",__TOGEOJSON:"https://unpkg.com/@tmcw/togeojson@5.6.2/dist/togeojson.umd.js",__LGEOMUTIL:"https://unpkg.com/leaflet-geometryutil@0.10.1/src/leaflet.geometryutil.js",__LALMOSTOVER:"https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js",__LHOTLINE:"../libs/leaflet-hotline.min.js",__LDISTANCEM:"../libs/leaflet-distance-marker.min.js",__LEDGESCALE:"../libs/leaflet-edgescale.min.js",__LCHART:"../src/components/chart.js",__LMARKER:"../src/components/marker.js",__LSUMMARY:"../src/components/summary.js",__modulesFolder:"../src/handlers/",__btnIcon:"../images/elevation.svg",addData(t,e){return this.import(this.__D3).then(()=>{if(!this._modulesLoaded)return new Promise(i=>this.once("modules_loaded",()=>i(this.addData(t,e))));e=e??(t.on&&t),this._addData(t),this._addLayer(e),this._fireEvt("eledata_added",{data:t,layer:e,track_info:this.track_info})})},addTo(t){if(this.options.detached){let e=T(this.options.elevationDiv),i=this.onAdd(t);e?P(e,i):j(t.getContainer(),i,"afterend")}else L.Control.prototype.addTo.call(this,t);return this},clear(){this._marker&&this._marker.remove(),this._chart&&this._clearChart(),this._layers&&this._clearLayers(this._layers),this._markers&&this._clearLayers(this._markers),this._circleMarkers&&this._circleMarkers.remove(),this._hotline&&this._hotline.eachLayer(t=>t.options.renderer.remove()),this._hotline&&this._clearLayers(this._hotline),this._data=[],this.track_info={},this._yCoordMin=0,this._yCoordMax=-1/0,this._fireEvt("eledata_clear"),this._updateChart()},_clearChart(){this._events&&this._events.elechart_updated&&this._events.elechart_updated.forEach(({fn:t,ctx:e})=>this.off("elechart_updated",t,e)),this._chart&&this._chart._container&&(this._chart._container.selectAll("g.point .point").remove(),this._chart.clear())},_clearLayers(t){t=t||this._layers,t&&t.eachLayer&&(t.eachLayer(e=>e.remove()),t.clearLayers())},disableBrush(){this._chart._brushEnabled=!1,this._resetDrag()},enableBrush(){this._chart._brushEnabled=!0},disableZoom(){this._chart._zoomEnabled=!1,this._chart._resetZoom()},enableZoom(){this._chart._zoomEnabled=!0},fitBounds(t){t=t||this.getBounds(),this._map&&t.isValid()&&this._map.fitBounds(t)},getBounds(t){return L.latLngBounds((t||this._data).map(e=>e.latlng))},getZFollow(){return this.options.zFollow},hide(){y(this._container,"display","none")},initialize(t){t=L.setOptions(this,L.extend({},I(u),t)),this._data=[],this._layers=L.featureGroup(),this._markers=L.featureGroup(),this._hotline=L.featureGroup(),this._circleMarkers=L.featureGroup(),this._markedSegments=L.polyline([]),this._start=L.circleMarker([0,0],t.trkStart||u.trkStart),this._end=L.circleMarker([0,0],t.trkEnd||u.trkEnd),this._chartEnabled=!0,this._yCoordMin=0,this._yCoordMax=-1/0,this.track_info={},t.followMarker&&(this._setMapView=J(this._setMapView,300,this)),t.legend&&(t.margins.bottom+=30),t.theme&&(t.polylineSegments.className+=" "+t.theme),t.wptIcons===!0&&(t.wptIcons=u.wptIcons),t.distanceMarkers===!0&&(t.distanceMarkers=u.distanceMarkers),t.trkStart&&this._start.addTo(this._circleMarkers),t.trkEnd&&this._end.addTo(this._circleMarkers),this._markedSegments.setStyle(t.polylineSegments),L.extend(E,t.colors||{}),this._fixCanvasPaths(),this._fixTooltipSize()},import(t,e){if(Array.isArray(t))return Promise.all(t.map(i=>this.import(i)));switch(t){case this.__D3:e=typeof d3!="object";break;case this.__TOGEOJSON:e=typeof toGeoJSON!="object";break;case this.__LGEOMUTIL:e=typeof L.GeometryUtil!="object";break;case this.__LALMOSTOVER:e=typeof L.Handler.AlmostOver!="function";break;case this.__LDISTANCEM:e=typeof L.DistanceMarkers!="function";break;case this.__LEDGESCALE:e=typeof L.Control.EdgeScale!="function";break;case this.__LHOTLINE:e=typeof L.Hotline!="function";break}return e!==!1?import(D(t,this.options.srcFolder)):Promise.resolve()},load(t){this._parseFromString(t).then(e=>e?this._loadLayer(e):this._loadFile(t))},onAdd(t){this._map=t;let e=this._container=M("div","elevation-control "+this.options.theme+" "+(this.options.detached?"elevation-detached":"leaflet-control"),this.options.detached?{id:"elevation-"+H()}:{});return this.eleDiv=e,this._loadModules(this.options.handlers).then(()=>{this._initChart(e),this._initButton(e),this._initSummary(e),this._initMarker(t),this._initLayer(t),this._modulesLoaded=!0,this.fire("modules_loaded")}),this.fire("add"),e},onRemove(t){this._container=null,t.off("zoom viewreset zoomanim",this._hideMarker,this).off("resize",this._resetView,this).off("resize",this._resizeChart,this).off("mousedown",this._resetDrag,this),w(t.getContainer(),"mousewheel",this._resetDrag,this),w(t.getContainer(),"touchstart",this._resetDrag,this),w(document,"keydown",this._onKeyDown,this),this.off("eledata_added eledata_loaded",this._updateChart,this).off("eledata_added eledata_loaded",this._updateSummary,this),this.fire("remove")},redraw(){this._resizeChart()},setZFollow(t){this.options.zFollow=t},show(){y(this._container,"display","block")},_addData(t){if(t){if(t.type==="FeatureCollection")return f(t.features,e=>this._addData(e));if(t.type==="Feature"){let e=t.geometry;if(e)switch(e.type){case"LineString":return this._addGeoJSONData(e.coordinates,t.properties);case"MultiLineString":return f(e.coordinates,(i,s)=>this._addGeoJSONData(i,t.properties,s));default:return console.warn("Unsopperted GeoJSON feature geometry type:"+e.type)}}if(t._latlngs)return this._addGeoJSONData(t._latlngs,t.feature&&t.feature.properties)}},_addGeoJSONData(t,e,i){let s=e&&e.coordinateProperties||e;t.forEach((a,o)=>{a.meta=a.meta??{time:null,ele:null},a.prev=r=>r?this._data[o>0?o-1:0][r]:this._data[o>0?o-1:0],this.fire("elepoint_init",{point:a,props:s,id:o,isMulti:i}),this._addPoint(a.lat??a[1],a.lng??a[0],a.alt??a.meta.ele??a[2]),this.fire("elepoint_added",{point:a,index:this._data.length-1}),this._yCoordMin>this._data[this._data.length-1][this.options.yAttr]&&(this._yCoordMin=this._data[this._data.length-1][this.options.yAttr]),this._yCoordMax<this._data[this._data.length-1][this.options.yAttr]&&(this._yCoordMax=this._data[this._data.length-1][this.options.yAttr])}),this.fire("eletrack_added",{coords:t,index:this._data.length-1})},_addPoint(t,e,i){this.options.reverseCoords&&([t,e]=[e,t]),this._data.push({x:t,y:e,z:i,latlng:L.latLng(t,e,i)}),this.fire("eledata_updated",{index:this._data.length-1})},_addLayer(t){return t&&this._layers.addLayer(t),t&&this.options.distanceMarkers&&this.options.distanceMarkers.lazy&&t.on("add remove",({target:e,type:i})=>L.DistanceMarkers&&e instanceof L.Polyline&&e[i+"DistanceMarkers"]()),t},_addMarker(t){return t&&this._markers.addLayer(t),t},_initAlmostOverHandler(t,e){return t&&this.options.almostOver&&!L.Browser.mobile?this.import([this.__LGEOMUTIL,this.__LALMOSTOVER]).then(()=>{t.addHandler("almostOver",L.Handler.AlmostOver),L.GeometryUtil&&t.almostOver&&t.almostOver.enabled()&&(t.almostOver.addLayer(e),t.on("almost:move",this._onMouseMoveLayer,this).on("almost:out",this._onMouseOut,this),this.once("eledata_clear",()=>{t.almostOver.removeLayer(e),t.off("almost:move",this._onMouseMoveLayer,this).off("almost:out",this._onMouseOut,this)}))}):Promise.resolve()},_initDistanceMarkers(){return this.options.distanceMarkers?this.import([this.__LGEOMUTIL,this.__LDISTANCEM]):Promise.resolve()},_initEdgeScale(t){return this.options.edgeScale?this.import(this.__LEDGESCALE).then(()=>{t.edgeScaleControl=t.edgeScaleControl||L.control.edgeScale(typeof this.options.edgeScale!="boolean"?this.options.edgeScale:{}).addTo(t)}):Promise.resolve()},_initHotLine(t){let e=typeof this.options.hotline=="string"?this.options.hotline:"elevation";return this.options.hotline?this.import(this.__LHOTLINE).then(()=>{t.eachLayer(i=>{if(i.feature.geometry.type!="Point"){let s=L.geoJson(i.toGeoJSON(),{coordsToLatLng:r=>L.latLng(r[0],r[1],r[2]*(this.options.altitudeFactor||1))}),a=L.hotline(s.toGeoJSON().features[0].geometry.coordinates,{renderer:L.Hotline.renderer(),min:isFinite(this.track_info[e+"_min"])?this.track_info[e+"_min"]:0,max:isFinite(this.track_info[e+"_max"])?this.track_info[e+"_max"]:1,palette:{0:"#008800",.5:"#ffff00",1:"#ff0000"},weight:5,outlineColor:"#000000",outlineWidth:1}).addTo(this._hotline),o=i.options.style&&i.options.style.opacity||1;i.on("add remove",({type:r})=>{i.setStyle({opacity:r=="add"?0:o}),a[r=="add"?"addTo":"removeFrom"](i._map),a._renderer&&a._renderer._container.parentElement.insertBefore(a._renderer._container,a._renderer._container.parentElement.firstChild)})}})}):Promise.resolve()},_initMapIntegrations(t){let e=this._map;e?(this._data.length&&(this._start.setLatLng(this._data[0].latlng),this._end.setLatLng(this._data[this._data.length-1].latlng)),Promise.all([this._initHotLine(t),this._initAlmostOverHandler(e,t),this._initDistanceMarkers(),this._initEdgeScale(e)]).then(()=>{this.options.polyline&&(this._layers.addLayer(t.addTo(e)),this._circleMarkers.addTo(e)),this.options.autofitBounds&&this.fitBounds(t.getBounds()),e.invalidateSize()})):this.once("add",()=>this._initMapIntegrations(t))},_collapse(){A(this._container,"elevation-expanded","elevation-collapsed"),this._map&&this._map.invalidateSize()},_expand(){A(this._container,"elevation-collapsed","elevation-expanded"),this._map&&this._map.invalidateSize()},_fixCanvasPaths(){let t=L.Canvas.prototype._fillStroke,e=this,i=this.options.theme.split(" ")[0].replace("-theme",""),s=E[i]||{};L.Canvas.include({_fillStroke(a,o){if(e._layers.hasLayer(o)){let r=o.options;if(r.color=e._chartEnabled?s.line||s.area||i:"#000",r.stroke=!!r.color,t.call(this,a,o),r.stroke&&r.weight!==0){let n=a.globalCompositeOperation||"source-over";a.globalCompositeOperation="destination-over",a.strokeStyle=s.outline||"#FFF",a.lineWidth=r.weight*1.75,a.stroke(),a.globalCompositeOperation=n}}else t.call(this,a,o)}})},_fixTooltipSize(){this.on("elechart_init",()=>this.once("elechart_change elechart_hover",({data:t,xCoord:e})=>{this._chartEnabled&&(this._chart._showDiagramIndicator(t,e),this._chart._showDiagramIndicator(t,e)),this._updateMarker(t)}))},_findItemForLatLng(t){return this._data[this._chart._findIndexForLatLng(t)]},_findItemForX(t){return this._data[this._chart._findIndexForXCoord(t)]},_fireEvt(t,e,i){this.fire&&this.fire(t,e,i),this._map&&this._map.fire(t,e,i)},_hideMarker(){this.options.autohideMarker&&this._marker&&this._marker.remove()},_initChart(t){let e=this.options,i=this._map;if(e.detached){let{offsetWidth:s,offsetHeight:a}=this.eleDiv;s>0&&(e.width=s),a>20&&(e.height=a-20)}else{let{clientWidth:s}=i.getContainer();e._maxWidth=e._maxWidth>e.width?e._maxWidth:e.width,this._container.style.maxWidth=e._maxWidth+"px",e._maxWidth>s&&(e.width=s-30)}this.import([this.__D3,this.__LCHART]).then(s=>{let a=this._chart=new(s[1]||_).Chart(e,this);this._x=this._chart._x,this._y=this._chart._y,d3.select(t).call(a.render()),a.on("reset_drag",this._hideMarker,this).on("mouse_enter",this._onMouseEnter,this).on("dragged",this._onDragEnd,this).on("mouse_move",this._onMouseMove,this).on("mouse_out",this._onMouseOut,this).on("ruler_filter",this._onRulerFilter,this).on("zoom",this._updateChart,this).on("elepath_toggle",this._onToggleChart,this).on("margins_updated",this._resizeChart,this),this.fire("elechart_init"),i.on("zoom viewreset zoomanim",this._hideMarker,this).on("resize",this._resetView,this).on("resize",this._resizeChart,this).on("rotate",this._rotateMarker,this).on("mousedown",this._resetDrag,this),d(i.getContainer(),"mousewheel",this._resetDrag,this),d(i.getContainer(),"touchstart",this._resetDrag,this),d(document,"keydown",this._onKeyDown,this),this.on("eledata_added eledata_loaded",this._updateChart,this).on("eledata_added eledata_loaded",this._updateSummary,this),this._updateChart(),this._updateSummary(),i.invalidateSize()})},_initLayer(){this._layers.on("layeradd layerremove",({layer:t,type:e})=>{let i=t.getElement&&t.getElement();O(i,this.options.polyline.className+" "+this.options.theme,e=="layeradd"),N(t,"mousemove",this._onMouseMoveLayer.bind(this),e=="layeradd"),N(t,"mouseout",this._onMouseOut.bind(this),e=="layeradd")})},_initMarker(t){let e=t.getPane("elevationPane");e||(e=this._pane=t.createPane("elevationPane",t.getPane("norotatePane")||t.getPane("mapPane")),e.style.zIndex=625,e.style.pointerEvents="none"),this._renderer&&this._renderer.remove(),this._renderer=L.svg({pane:"elevationPane"}).addTo(this._map),this.import([this.__D3,this.__LMARKER]).then(i=>{this._marker=new(i[1]||_).Marker(this.options,this),this.fire("elechart_marker")})},_initButton(t){if(L.DomEvent.disableClickPropagation(t).disableScrollPropagation(t),this.options.collapsed?this._collapse():this._expand(),this.options.autohide&&(d(t,"mouseover",this._expand,this),d(t,"mouseout",this._collapse,this),this._map.on("click",this._collapse,this)),this.options.closeBtn){let e=this._button=M("a","elevation-toggle-icon",{href:"#",title:L._("Elevation")},t);d(e,"click",L.DomEvent.stop),d(e,"click",this._toggle,this),d(e,"focus",this._toggle,this),fetch(D(this.__btnIcon,this.options.srcFolder)).then(i=>i.ok&&i.text().then(s=>e.innerHTML=s))}},_initSummary(t){this.import(this.__LSUMMARY).then(e=>{this._summary=new(e||_).Summary({summary:this.options.summary},this),this.on("elechart_init",()=>{d3.select(t).call(this._summary.render())})})},_loadFile(t){fetch(t).then(e=>e.text()).then(e=>{this._downloadURL=t,this._parseFromString(e).then(i=>i&&this._loadLayer(i))}).catch(e=>console.warn(e))},_loadModules(t){t=t.map(i=>typeof i=="string"&&typeof _[i]<"u"?_[i]:i);let e=t.map(i=>typeof i=="string"&&this.import(this.__modulesFolder+i.toLowerCase()+".js")||i instanceof Promise&&i||Promise.resolve());return Promise.all(e).then(i=>{f(i,(s,a)=>{let o=s&&Object.keys(s)[0];o&&(t[a]=_[o]=_[o]??s[o])}),f(t,s=>["function","object"].includes(typeof s)&&this._registerHandler(s))})},_loadLayer(t){let{polyline:e,theme:i,waypoints:s,wptIcons:a,wptLabels:o,distanceMarkers:r}=this.options,n=L.extend({},e),l=[];i&&(n.className+=" "+i),t.name&&(this.track_info.name=t.name);let c=L.geoJson(t,{distanceMarkers:r,style:n,pointToLayer:(h,g)=>{if(s){let{desc:p,name:m,sym:G}=h.properties;if(p=p||"",m=m||"",[!0,"dots"].includes(s)&&this._registerCheckPoint({latlng:g,label:[!0,"dots"].includes(o)?m:""}),[!0,"markers"].includes(s)&&a!=!1)return this._registerMarker({latlng:g,sym:(G??m).replace(/["']/g,"").replace(/ /g,"-").toLowerCase(),content:[!0,"markers"].includes(o)&&(m||p)&&decodeURI("<b>"+m+"</b>"+(p.length>0?"<br>"+p:""))})}},onEachFeature:(h,g)=>h.geometry&&h.geometry.type!="Point"&&l.push(this.addData(h,g))});return this.import(this.__D3).then(()=>Promise.all(l)).then(()=>{this._initMapIntegrations(c);let h={data:t,layer:c,name:this.track_info.name,track_info:this.track_info};this._modulesLoaded?this._fireEvt("eledata_loaded",h):this.once("modules_loaded",()=>this._fireEvt("eledata_loaded",h))}),c},_onDragEnd({dragstart:t,dragend:e}){this._hideMarker(),this.fitBounds(L.latLngBounds([t.latlng,e.latlng])),this.fire("elechart_dragged")},_onKeyDown({key:t}){!this.options.detached&&t==="Escape"&&this._collapse()},_onMouseEnter(){this.fire("elechart_enter")},_onMouseMove({xCoord:t}){if(this._chartEnabled&&this._data.length){let e=this._findItemForX(t);e&&(this._chartEnabled&&this._chart._showDiagramIndicator(e,t),this._updateMarker(e),this._setMapView(e),this._map&&v(this._map.getContainer(),"elechart-hover"),this.fire("elechart_change",{data:e,xCoord:t}),this.fire("elechart_hover",{data:e,xCoord:t}))}},_onMouseMoveLayer({latlng:t}){if(this._data.length){let e=this._findItemForLatLng(t);if(e){let i=e.xDiagCoord;this._chartEnabled&&this._chart._showDiagramIndicator(e,i),this._updateMarker(e),this.fire("elechart_change",{data:e,xCoord:i})}}},_onMouseOut(){this.options.detached||(this._hideMarker(),this._chart._hideDiagramIndicator()),this._map&&k(this._map.getContainer(),"elechart-hover"),this.fire("elechart_leave")},_onRulerFilter({coords:t}){this._updateMapSegments(t)},_onToggleChart({name:t,enabled:e}){this._chartEnabled=this._chart._hasActiveLayers(),this._layers.eachLayer(i=>{O(i.getElement&&i.getElement(),this.options.polyline.className+" "+this.options.theme,this._chartEnabled),i._renderer instanceof L.Canvas&&i.redraw()}),this.options[t]=!e&&this.options[t]=="disabled"?"enabled":"disabled",this._chartEnabled||(this._chart._hideDiagramIndicator(),this._marker.remove())},_parseFromGeoJSONString(t){try{return JSON.parse(t)}catch{}},_parseFromString(t){return new Promise(e=>this.import(this.__TOGEOJSON).then(()=>{let i;try{i=this._parseFromXMLString(t.trim())}catch{i=this._parseFromGeoJSONString(t.toString())}i&&(i.name=i.name||(this._downloadURL||"").split("/").pop().split("#")[0].split("?")[0]),e(i)}))},_parseFromXMLString(t){if(t.indexOf("<")!=0)throw"Invalid XML";let e=new DOMParser().parseFromString(t,"text/xml"),i=e.documentElement.tagName.toLowerCase(),s=e.getElementsByTagName("name");if(e.getElementsByTagName("parsererror").length)throw"Invalid XML";i in toGeoJSON||(i=e.documentElement.tagName=="TrainingCenterDatabase"?"tcx":"gpx");let a=toGeoJSON[i](e);return a.name=s.length>0?(Array.from(s).find(o=>o.parentElement.tagName=="trk")??s[0]).textContent:"",a},_registerAreaPath(t){this.on("elechart_init",()=>this._chart._registerAreaPath(t))},_registerAxisGrid(t){this.on("elechart_axis",()=>this._chart._registerAxisGrid(t))},_registerAxisScale(t){this.on("elechart_axis",()=>this._chart._registerAxisScale(t))},_registerCheckPoint(t){let e=()=>this._chart._registerCheckPoint(t);this.on("elechart_updated",e).once("eledata_clear",()=>this.off("elechart_updated",e))},_registerDataAttribute(t){t.coordPropsToMeta&&this.on("elepoint_init",r=>t.coordPropsToMeta.call(this,r));let e,i,s,a=t.attr||t.name,o={};this.on("elepoint_added",({index:r,point:n})=>{if(e=r,s=i??this._data[e],i=this._data[e],i[a]=t.pointToAttr.call(this,n,e),e>0&&isNaN(s[a])&&(!isNaN(o[a])&&!isNaN(i[a])?s[a]=(o[a]+i[a])/2:isNaN(o[a])?isNaN(i[a])||(s[a]=i[a]):s[a]=o[a],t.meta&&(s[t.meta]=s[a])),!isNaN(i[a])){if(o[a]=i[a],t.deltaMax&&(i[a]=X(i[a],s[a],t.deltaMax)),t.clampRange&&(i[a]=F(i[a],t.clampRange)),isNaN(t.decimals)||(i[a]=V(i[a],t.decimals)),t.stats)for(let l in t.stats){let c=(t.statsName||a)+(l!=""?"_":"");this.track_info[c+l]=t.stats[l].call(this,i[a],this.track_info[c+l],this._data.length)}t.onPointAdded&&t.onPointAdded.call(this,i[a],e,n)}})},_registerHandler(t){if(typeof t=="function")return this._registerHandler(t.call(this));let{name:e,attr:i,required:s,deltaMax:a,clampRange:o,decimals:r,meta:n,unit:l,coordinateProperties:c,coordPropsToMeta:h,pointToAttr:g,onPointAdded:p,stats:m,statsName:G,grid:Z,scale:K,path:Y,tooltip:q,summary:C}=t;(this.options[e]||s)&&(this._registerDataAttribute({name:e,attr:i,meta:n,deltaMax:a,clampRange:o,decimals:r,coordPropsToMeta:U(c,n||e,h),pointToAttr:g,onPointAdded:p,stats:m,statsName:G}),Z&&this._registerAxisGrid(L.extend({name:e},Z)),this.options[e]!=="summary"&&(K&&this._registerAxisScale(L.extend({name:e,label:l},K)),Y&&this._registerAreaPath(L.extend({name:e},Y))),(q||t.tooltips)&&f([q,...t.tooltips||[]],S=>S&&this._registerTooltip(L.extend({name:e},S))),C&&(f(C,(S,et)=>C[et]=L.extend({unit:l},S)),this._registerSummary(C)))},_registerMarker({latlng:t,sym:e,content:i}){let{wptIcons:s}=this.options;s.hasOwnProperty(e)||(s[e]=L.divIcon(L.extend({},s[""].options,{html:'<i class="elevation-waypoint-icon '+e+'"></i>'})));let a=L.marker(t,{icon:s[e]});return i&&(a.bindPopup(i,{className:"elevation-popup",keepInView:!0}).openPopup(),a.bindTooltip(i,{className:"elevation-tooltip",direction:"auto",sticky:!0,opacity:1}).openTooltip()),this._addMarker(a)},_registerTooltip(t){t.chart&&this.on("elechart_init",()=>this._chart._registerTooltip(L.extend({},t,{value:t.chart}))),t.marker&&this.on("elechart_marker",()=>this._marker._registerTooltip(L.extend({},t,{value:t.marker})))},_registerSummary(t){this.on("elechart_summary",()=>this._summary._registerSummary(t))},_resetDrag(){this._chart._resetDrag(),this._hideMarker()},_resetView(){this._map&&this._map._isFullscreen||(this._resetDrag(),this._hideMarker(),this.options.autofitBounds&&this.fitBounds())},_resizeChart(){if(this._container&&y(this._container,"display")!="none"){let t=this.options,e=t.detached?(this.eleDiv||this._container).offsetWidth:F(t._maxWidth,[0,this._map.getContainer().clientWidth-30]);e&&(t.width=e,this._chart&&this._chart._chart&&(this._chart._chart._resize(t),this._updateChart())),this._updateMapSegments()}},_toggle(){W(this._container,"elevation-expanded")?this._collapse():this._expand()},_setMapView(t){if(this._map&&this.options.followMarker){let e=this._map.getZoom(),i=this.options.zFollow;typeof i=="number"?this._map.setView(t.latlng,e<i?i:e,{animate:!0,duration:.25}):this._map.getBounds().contains(t.latlng)||this._map.setView(t.latlng,e,{animate:!0,duration:.25})}},_updateChart(){this._chart&&this._container&&(this.fire("elechart_axis"),this._chart.update({data:this._data,options:this.options}),this._x=this._chart._x,this._y=this._chart._y,this.fire("elechart_updated"))},_updateMarker(t){this._marker&&this._marker.update({map:this._map,item:t,yCoordMin:this._yCoordMin,yCoordMax:this._yCoordMax||0,options:this.options})},_rotateMarker(){this._marker&&this._marker.update()},_updateMapSegments(t){this._markedSegments.setLatLngs(t||[]),t&&this._map&&!this._map.hasLayer(this._markedSegments)&&this._markedSegments.addTo(this._map)},_updateSummary(){this._summary&&(this._summary.reset(),this.options.summary&&(this.fire("elechart_summary"),this._summary.update()),this.options.downloadLink&&this._downloadURL&&(this._summary._container.innerHTML+='<span class="download"><a href="#">'+L._("Download")+"</a></span>",T(".download a",this._summary._container).onclick=t=>{t.preventDefault();let e={downloadLink:this.options.downloadLink,confirm:R.bind(this,this._downloadURL)};this.options.downloadLink=="modal"&&typeof CustomEvent=="function"?document.dispatchEvent(new CustomEvent("eletrack_download",{detail:e})):(this.options.downloadLink=="link"||this.options.downloadLink===!0)&&e.confirm(),this.fire("eletrack_download",e)}))},_width(){if(this._chart)return this._chart._width();let{width:t,margins:e}=this.options;return t-e.left-e.right},_height(){if(this._chart)return this._chart._height();let{height:t,margins:e}=this.options;return t-e.top-e.bottom}});_.Utils=z;L.control.elevation=t=>new _(t);})();
@@ -195,7 +195,7 @@ https://github.com/iosphere/Leaflet.hotline/
195
195
  * @returns {Array.<number>} The RGB values as an array [r, g, b]
196
196
  */
197
197
  getRGBForValue: function (value) {
198
- var valueRelative = Math.min(Math.max((value - this._min) / (this._max - this._min), 0), 0.999);
198
+ var valueRelative = this._max === this._min ? 0 : Math.min(Math.max((value - this._min) / (this._max - this._min), 0), 0.999);
199
199
  var paletteIndex = Math.floor(valueRelative * 256) * 4;
200
200
 
201
201
  return [
@@ -248,6 +248,11 @@ https://github.com/iosphere/Leaflet.hotline/
248
248
  pointStart = path[j - 1];
249
249
  pointEnd = path[j];
250
250
 
251
+ // Keep only the outline where elevation is unknown, rather than treating it as zero.
252
+ if (!Number.isFinite(pointStart.z) || !Number.isFinite(pointEnd.z)) {
253
+ continue;
254
+ }
255
+
251
256
  // Create a gradient for each segment, pick start end end colors from palette gradient
252
257
  gradient = ctx.createLinearGradient(pointStart.x, pointStart.y, pointEnd.x, pointEnd.y);
253
258
  gradientStartRGB = this.getRGBForValue(pointStart.z);
@@ -1 +1 @@
1
- !function(root,plugin){"function"==typeof define&&define.amd?define(["leaflet"],plugin):"object"==typeof exports?module.exports=plugin:plugin(root.L)}(window,(function(L){if(L.Hotline)return L;var Hotline=function(canvas){if(!(this instanceof Hotline))return new Hotline(canvas);var defaultPalette={0:"green",.5:"yellow",1:"red"};this._canvas=canvas="string"==typeof canvas?document.getElementById(canvas):canvas,this._ctx=canvas.getContext("2d"),this._width=canvas.width,this._height=canvas.height,this._weight=5,this._outlineWidth=1,this._outlineColor="black",this._min=0,this._max=1,this._data=[],this.palette(defaultPalette)};Hotline.prototype={width:function(width){return this._width=width,this},height:function(height){return this._height=height,this},weight:function(weight){return this._weight=weight,this},outlineWidth:function(outlineWidth){return this._outlineWidth=outlineWidth,this},outlineColor:function(outlineColor){return this._outlineColor=outlineColor,this},palette:function(palette){var canvas=document.createElement("canvas"),ctx=canvas.getContext("2d"),gradient=ctx.createLinearGradient(0,0,0,256);for(var i in canvas.width=1,canvas.height=256,palette)gradient.addColorStop(i,palette[i]);return ctx.fillStyle=gradient,ctx.fillRect(0,0,1,256),this._palette=ctx.getImageData(0,0,1,256).data,this},min:function(min){return this._min=min,this},max:function(max){return this._max=max,this},data:function(data){return this._data=data,this},add:function(path){return this._data.push(path),this},draw:function(){var ctx=this._ctx;return ctx.globalCompositeOperation="source-over",ctx.lineCap="round",this._drawOutline(ctx),this._drawHotline(ctx),this},getRGBForValue:function(value){var valueRelative=Math.min(Math.max((value-this._min)/(this._max-this._min),0),.999),paletteIndex=4*Math.floor(256*valueRelative);return[this._palette[paletteIndex],this._palette[paletteIndex+1],this._palette[paletteIndex+2]]},_drawOutline:function(ctx){var i,j,dataLength,path,pathLength,pointStart,pointEnd;if(this._outlineWidth)for(i=0,dataLength=this._data.length;i<dataLength;i++)for(path=this._data[i],ctx.lineWidth=this._weight+2*this._outlineWidth,j=1,pathLength=path.length;j<pathLength;j++)pointStart=path[j-1],pointEnd=path[j],ctx.strokeStyle=this._outlineColor,ctx.beginPath(),ctx.moveTo(pointStart.x,pointStart.y),ctx.lineTo(pointEnd.x,pointEnd.y),ctx.stroke()},_drawHotline:function(ctx){var i,j,dataLength,path,pathLength,pointStart,pointEnd,gradient,gradientStartRGB,gradientEndRGB;for(ctx.lineWidth=this._weight,i=0,dataLength=this._data.length;i<dataLength;i++)for(j=1,pathLength=(path=this._data[i]).length;j<pathLength;j++)pointStart=path[j-1],pointEnd=path[j],gradient=ctx.createLinearGradient(pointStart.x,pointStart.y,pointEnd.x,pointEnd.y),gradientStartRGB=this.getRGBForValue(pointStart.z),gradientEndRGB=this.getRGBForValue(pointEnd.z),gradient.addColorStop(0,"rgb("+gradientStartRGB.join(",")+")"),gradient.addColorStop(1,"rgb("+gradientEndRGB.join(",")+")"),ctx.strokeStyle=gradient,ctx.beginPath(),ctx.moveTo(pointStart.x,pointStart.y),ctx.lineTo(pointEnd.x,pointEnd.y),ctx.stroke()}};var Renderer=L.Canvas.extend({_initContainer:function(){L.Canvas.prototype._initContainer.call(this),this._hotline=new Hotline(this._container)},_update:function(){L.Canvas.prototype._update.call(this),this._hotline.width(this._container.width),this._hotline.height(this._container.height)},_updatePoly:function(layer){if(this._drawing){var parts=layer._parts;parts.length&&(this._updateOptions(layer),this._hotline.data(parts).draw())}},_updateOptions:function(layer){null!=layer.options.min&&this._hotline.min(layer.options.min),null!=layer.options.max&&this._hotline.max(layer.options.max),null!=layer.options.weight&&this._hotline.weight(layer.options.weight),null!=layer.options.outlineWidth&&this._hotline.outlineWidth(layer.options.outlineWidth),null!=layer.options.outlineColor&&this._hotline.outlineColor(layer.options.outlineColor),layer.options.palette&&this._hotline.palette(layer.options.palette)}}),renderer=function(options){return L.Browser.canvas?new Renderer(options):null},Util={clipSegment:function(a,b,bounds,useLastCode,round){var codeA=useLastCode?this._lastCode:L.LineUtil._getBitCode(a,bounds),codeB=L.LineUtil._getBitCode(b,bounds),codeOut,p,newCode;for(this._lastCode=codeB;;){if(!(codeA|codeB))return[a,b];if(codeA&codeB)return!1;codeOut=codeA||codeB,p=L.LineUtil._getEdgeIntersection(a,b,codeOut,bounds,round),newCode=L.LineUtil._getBitCode(p,bounds),codeOut===codeA?(p.z=a.z,a=p,codeA=newCode):(p.z=b.z,b=p,codeB=newCode)}}};return L.Hotline=L.Polyline.extend({statics:{Renderer:Renderer,renderer:renderer},options:{renderer:renderer(),min:0,max:1,palette:{0:"green",.5:"yellow",1:"red"},weight:5,outlineColor:"black",outlineWidth:1},getRGBForValue:function(value){return this._renderer._hotline.getRGBForValue(value)},_projectLatlngs:function(latlngs,result,projectedBounds){var flat=latlngs[0]instanceof L.LatLng,len=latlngs.length,i,ring;if(flat){for(ring=[],i=0;i<len;i++)ring[i]=this._map.latLngToLayerPoint(latlngs[i]),ring[i].z=latlngs[i].alt,projectedBounds.extend(ring[i]);result.push(ring)}else for(i=0;i<len;i++)this._projectLatlngs(latlngs[i],result,projectedBounds)},_clipPoints:function(){if(this.options.noClip)this._parts=this._rings;else{this._parts=[];var parts=this._parts,bounds=this._renderer._bounds,i,j,k,len,len2,segment,points;for(i=0,k=0,len=this._rings.length;i<len;i++)for(j=0,len2=(points=this._rings[i]).length;j<len2-1;j++)(segment=Util.clipSegment(points[j],points[j+1],bounds,j,!0))&&(parts[k]=parts[k]||[],parts[k].push(segment[0]),segment[1]===points[j+1]&&j!==len2-2||(parts[k].push(segment[1]),k++))}},_clickTolerance:function(){return this.options.weight/2+this.options.outlineWidth+(L.Browser.touch?10:0)}}),L.hotline=function(latlngs,options){return new L.Hotline(latlngs,options)},L}));
1
+ (function(root,plugin){typeof define=="function"&&define.amd?define(["leaflet"],plugin):typeof exports=="object"?module.exports=plugin:plugin(root.L)})(window,function(L){if(L.Hotline)return L;var Hotline=function(canvas){if(!(this instanceof Hotline))return new Hotline(canvas);var defaultPalette={0:"green",.5:"yellow",1:"red"};this._canvas=canvas=typeof canvas=="string"?document.getElementById(canvas):canvas,this._ctx=canvas.getContext("2d"),this._width=canvas.width,this._height=canvas.height,this._weight=5,this._outlineWidth=1,this._outlineColor="black",this._min=0,this._max=1,this._data=[],this.palette(defaultPalette)};Hotline.prototype={width:function(width){return this._width=width,this},height:function(height){return this._height=height,this},weight:function(weight){return this._weight=weight,this},outlineWidth:function(outlineWidth){return this._outlineWidth=outlineWidth,this},outlineColor:function(outlineColor){return this._outlineColor=outlineColor,this},palette:function(palette){var canvas=document.createElement("canvas"),ctx=canvas.getContext("2d"),gradient=ctx.createLinearGradient(0,0,0,256);canvas.width=1,canvas.height=256;for(var i in palette)gradient.addColorStop(i,palette[i]);return ctx.fillStyle=gradient,ctx.fillRect(0,0,1,256),this._palette=ctx.getImageData(0,0,1,256).data,this},min:function(min){return this._min=min,this},max:function(max){return this._max=max,this},data:function(data){return this._data=data,this},add:function(path){return this._data.push(path),this},draw:function(){var ctx=this._ctx;return ctx.globalCompositeOperation="source-over",ctx.lineCap="round",this._drawOutline(ctx),this._drawHotline(ctx),this},getRGBForValue:function(value){var valueRelative=this._max===this._min?0:Math.min(Math.max((value-this._min)/(this._max-this._min),0),.999),paletteIndex=Math.floor(valueRelative*256)*4;return[this._palette[paletteIndex],this._palette[paletteIndex+1],this._palette[paletteIndex+2]]},_drawOutline:function(ctx){var i,j,dataLength,path,pathLength,pointStart,pointEnd;if(this._outlineWidth)for(i=0,dataLength=this._data.length;i<dataLength;i++)for(path=this._data[i],ctx.lineWidth=this._weight+2*this._outlineWidth,j=1,pathLength=path.length;j<pathLength;j++)pointStart=path[j-1],pointEnd=path[j],ctx.strokeStyle=this._outlineColor,ctx.beginPath(),ctx.moveTo(pointStart.x,pointStart.y),ctx.lineTo(pointEnd.x,pointEnd.y),ctx.stroke()},_drawHotline:function(ctx){var i,j,dataLength,path,pathLength,pointStart,pointEnd,gradient,gradientStartRGB,gradientEndRGB;for(ctx.lineWidth=this._weight,i=0,dataLength=this._data.length;i<dataLength;i++)for(path=this._data[i],j=1,pathLength=path.length;j<pathLength;j++)pointStart=path[j-1],pointEnd=path[j],!(!Number.isFinite(pointStart.z)||!Number.isFinite(pointEnd.z))&&(gradient=ctx.createLinearGradient(pointStart.x,pointStart.y,pointEnd.x,pointEnd.y),gradientStartRGB=this.getRGBForValue(pointStart.z),gradientEndRGB=this.getRGBForValue(pointEnd.z),gradient.addColorStop(0,"rgb("+gradientStartRGB.join(",")+")"),gradient.addColorStop(1,"rgb("+gradientEndRGB.join(",")+")"),ctx.strokeStyle=gradient,ctx.beginPath(),ctx.moveTo(pointStart.x,pointStart.y),ctx.lineTo(pointEnd.x,pointEnd.y),ctx.stroke())}};var Renderer=L.Canvas.extend({_initContainer:function(){L.Canvas.prototype._initContainer.call(this),this._hotline=new Hotline(this._container)},_update:function(){L.Canvas.prototype._update.call(this),this._hotline.width(this._container.width),this._hotline.height(this._container.height)},_updatePoly:function(layer){if(this._drawing){var parts=layer._parts;parts.length&&(this._updateOptions(layer),this._hotline.data(parts).draw())}},_updateOptions:function(layer){layer.options.min!=null&&this._hotline.min(layer.options.min),layer.options.max!=null&&this._hotline.max(layer.options.max),layer.options.weight!=null&&this._hotline.weight(layer.options.weight),layer.options.outlineWidth!=null&&this._hotline.outlineWidth(layer.options.outlineWidth),layer.options.outlineColor!=null&&this._hotline.outlineColor(layer.options.outlineColor),layer.options.palette&&this._hotline.palette(layer.options.palette)}}),renderer=function(options){return L.Browser.canvas?new Renderer(options):null},Util={clipSegment:function(a,b,bounds,useLastCode,round){var codeA=useLastCode?this._lastCode:L.LineUtil._getBitCode(a,bounds),codeB=L.LineUtil._getBitCode(b,bounds),codeOut,p,newCode;for(this._lastCode=codeB;;)if(codeA|codeB){if(codeA&codeB)return!1;codeOut=codeA||codeB,p=L.LineUtil._getEdgeIntersection(a,b,codeOut,bounds,round),newCode=L.LineUtil._getBitCode(p,bounds),codeOut===codeA?(p.z=a.z,a=p,codeA=newCode):(p.z=b.z,b=p,codeB=newCode)}else return[a,b]}};return L.Hotline=L.Polyline.extend({statics:{Renderer,renderer},options:{renderer:renderer(),min:0,max:1,palette:{0:"green",.5:"yellow",1:"red"},weight:5,outlineColor:"black",outlineWidth:1},getRGBForValue:function(value){return this._renderer._hotline.getRGBForValue(value)},_projectLatlngs:function(latlngs,result,projectedBounds){var flat=latlngs[0]instanceof L.LatLng,len=latlngs.length,i,ring;if(flat){for(ring=[],i=0;i<len;i++)ring[i]=this._map.latLngToLayerPoint(latlngs[i]),ring[i].z=latlngs[i].alt,projectedBounds.extend(ring[i]);result.push(ring)}else for(i=0;i<len;i++)this._projectLatlngs(latlngs[i],result,projectedBounds)},_clipPoints:function(){if(this.options.noClip){this._parts=this._rings;return}this._parts=[];var parts=this._parts,bounds=this._renderer._bounds,i,j,k,len,len2,segment,points;for(i=0,k=0,len=this._rings.length;i<len;i++)for(points=this._rings[i],j=0,len2=points.length;j<len2-1;j++)segment=Util.clipSegment(points[j],points[j+1],bounds,j,!0),segment&&(parts[k]=parts[k]||[],parts[k].push(segment[0]),(segment[1]!==points[j+1]||j===len2-2)&&(parts[k].push(segment[1]),k++))},_clickTolerance:function(){return this.options.weight/2+this.options.outlineWidth+(L.Browser.touch?10:0)}}),L.hotline=function(latlngs,options){return new L.Hotline(latlngs,options)},L});
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@raruto/leaflet-elevation",
3
- "version": "2.7.1",
3
+ "version": "2.7.2",
4
4
  "description": "A Leaflet plugin that allows to add elevation profiles using d3js",
5
5
  "type": "module",
6
6
  "main": "dist/leaflet-elevation.min.js",
7
7
  "browser": "dist/leaflet-elevation.min.js",
8
8
  "module": "src/index.js",
9
9
  "scripts": {
10
- "test": "node --test --test-concurrency=1 \"examples/*.spec.js\" \"src/*.spec.js\"",
11
- "build": "node build/build.js",
12
10
  "dev": "node build/dev.js",
11
+ "build": "node build/build.js",
12
+ "test": "npm run build && cucumber-js",
13
13
  "version": "npm run build && git add -A"
14
14
  },
15
15
  "repository": {
@@ -48,6 +48,7 @@
48
48
  },
49
49
  "homepage": "https://github.com/Raruto/leaflet-elevation#readme",
50
50
  "devDependencies": {
51
+ "@cucumber/cucumber": "^13.3.0",
51
52
  "esbuild": "^0.28.2",
52
53
  "leaflet": "^1.7.1",
53
54
  "playwright": "^1.64.1"
@@ -101,6 +101,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
101
101
  this._hideDiagramIndicator()
102
102
  this._area.selectAll('path').attr("d", "M0 0");
103
103
  this._context.clearRect(0, 0, this._width(), this._height());
104
+ this._chart._renderCanvas();
104
105
  this._mask.selectAll(".gap").remove();
105
106
  this._maskGaps = [];
106
107
 
@@ -380,6 +381,8 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
380
381
  },
381
382
 
382
383
  _registerAxisScale(props) {
384
+ // Preserve scale aliases so they resolve again after zoom replaces the scale.
385
+ props = L.extend({}, props);
383
386
  if (props.scale == 'y') props.scale = this._y;
384
387
  else if (props.scale == 'x') props.scale = this._x;
385
388
 
@@ -456,6 +459,7 @@ export var Chart = L.Control.Elevation.Chart = L.Class.extend({
456
459
  // Reset and update chart profiles
457
460
  this._context.clearRect(0, 0, this._width(), this._height());
458
461
  _.each(this._paths, (path, i) => !path.classed('leaflet-hidden') && this._drawPath(i));
462
+ this._chart._renderCanvas();
459
463
  },
460
464
 
461
465
  _updateAxis() {
@@ -541,6 +541,7 @@ export const Chart = ({
541
541
  height,
542
542
  margins = {},
543
543
  ruler,
544
+ preferCanvas,
544
545
  }) => {
545
546
 
546
547
  const w = width - margins.left - margins.right;
@@ -572,6 +573,14 @@ export const Chart = ({
572
573
  const foreignObject = panes.area .append('svg:foreignObject').attr('mask', 'url(#' + mask.attr('id') + ')');
573
574
  const canvas = foreignObject.append('xhtml:canvas') .attr('class', 'canvas-plot');
574
575
  const context = canvas.node().getContext('2d');
576
+ const webkitCanvas = preferCanvas &&
577
+ /Mac|iPod|iPhone|iPad/.test(navigator.platform) &&
578
+ /AppleWebkit/i.test(navigator.userAgent) &&
579
+ !/Chrome/.test(navigator.userAgent);
580
+ const canvasImage = webkitCanvas
581
+ ? panes.area.append('svg:image').attr('mask', 'url(#' + mask.attr('id') + ')').attr('pointer-events', 'none')
582
+ : null;
583
+ if (canvasImage) foreignObject.remove();
575
584
 
576
585
  // Add tooltip
577
586
  panes.tooltip.call(Tooltip({ xCoord: 0, yCoord: 0, height: h, width : w, labels: {} }));
@@ -598,6 +607,11 @@ export const Chart = ({
598
607
  scale,
599
608
  };
600
609
 
610
+ // ponytail: Safari encodes one PNG per redraw; use a separate HTML canvas layer if encoding becomes a bottleneck.
611
+ chart._renderCanvas = () => {
612
+ if (canvasImage) canvasImage.attr('href', canvas.node().toDataURL());
613
+ };
614
+
601
615
  // Resize
602
616
  chart._resize = ({
603
617
  width,
@@ -612,19 +626,10 @@ export const Chart = ({
612
626
  svg .attr("width", width).attr("height", height).attr("viewBox", `0 0 ${width} ${height}`);
613
627
  g .attr("transform", "translate(" + margins.left + "," + margins.top + ")");
614
628
 
615
- // Fix: https://github.com/Raruto/leaflet-elevation/issues/123
616
- // Fix: https://github.com/Raruto/leaflet-elevation/issues/232
617
- if (
618
- /Mac|iPod|iPhone|iPad/.test(navigator.platform) &&
619
- /AppleWebkit/i.test(navigator.userAgent) &&
620
- !/Chrome/.test(navigator.userAgent)
621
- ) {
622
- canvas .style("transform", "translate(" + margins.left + "px," + margins.top + "px)");
623
- }
624
-
625
629
  maskRect .attr("width", w).attr("height", h).attr("x", 0).attr("y", 0);
626
630
  foreignObject.attr('width', w).attr('height', h);
627
631
  canvas .attr('width', w).attr('height', h);
632
+ if (canvasImage) canvasImage.attr('width', w).attr('height', h).attr('href', null);
628
633
 
629
634
  if (ruler) {
630
635
  panes.ruler.call(Ruler({ height: h, width: w }));
@@ -643,7 +648,7 @@ export const Chart = ({
643
648
  chart.pane = (name) => (panes[name] || (panes[name] = g.append('g').attr("class", name)));
644
649
  chart.get = (name) => utils[name];
645
650
 
646
- chart._resize({ width, height, margins});
651
+ chart._resize({ width, height, margins, ruler});
647
652
 
648
653
  return chart;
649
654
  };
package/src/control.js CHANGED
@@ -30,17 +30,15 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
30
30
  * Add data to the diagram either from GPX or GeoJSON and update the axis domain and data
31
31
  */
32
32
  addData(d, layer) {
33
- this.import(this.__D3)
34
- .then(() => {
35
- if (this._modulesLoaded) {
36
- layer = layer ?? (d.on && d);
37
- this._addData(d);
38
- this._addLayer(layer);
39
- this._fireEvt("eledata_added", { data: d, layer: layer, track_info: this.track_info });
40
- } else {
41
- this.once('modules_loaded', () => this.addData(d,layer));
42
- }
43
- });
33
+ return this.import(this.__D3).then(() => {
34
+ if (!this._modulesLoaded) {
35
+ return new Promise(resolve => this.once('modules_loaded', () => resolve(this.addData(d, layer))));
36
+ }
37
+ layer = layer ?? (d.on && d);
38
+ this._addData(d);
39
+ this._addLayer(layer);
40
+ this._fireEvt("eledata_added", { data: d, layer: layer, track_info: this.track_info });
41
+ });
44
42
  },
45
43
 
46
44
  /**
@@ -248,7 +246,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
248
246
 
249
247
  let container = this._container = _.create("div", "elevation-control " + this.options.theme + " " + (this.options.detached ? 'elevation-detached' : 'leaflet-control'), this.options.detached ? { id: 'elevation-' + _.randomId() } : {});
250
248
 
251
- if (!this.eleDiv) this.eleDiv = container;
249
+ this.eleDiv = container;
252
250
 
253
251
  this._loadModules(this.options.handlers).then(() => { // Inject here required modules (data handlers)
254
252
  this._initChart(container);
@@ -536,7 +534,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
536
534
 
537
535
  let options = layer.options;
538
536
 
539
- options.color = color.line || color.area || theme;
537
+ options.color = control._chartEnabled ? (color.line || color.area || theme) : '#000';
540
538
  options.stroke = !!options.color;
541
539
 
542
540
  oldProto.call(this, ctx, layer);
@@ -600,7 +598,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
600
598
  * Hides the position/height indicator marker drawn onto the map
601
599
  */
602
600
  _hideMarker() {
603
- if (this.options.autohideMarker) {
601
+ if (this.options.autohideMarker && this._marker) {
604
602
  this._marker.remove();
605
603
  }
606
604
  },
@@ -667,6 +665,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
667
665
 
668
666
  this._updateChart();
669
667
  this._updateSummary();
668
+ map.invalidateSize();
670
669
  });
671
670
 
672
671
 
@@ -773,6 +772,7 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
773
772
  _loadLayer(geojson) {
774
773
  let { polyline, theme, waypoints, wptIcons, wptLabels, distanceMarkers } = this.options;
775
774
  let style = L.extend({}, polyline);
775
+ let dataAdded = [];
776
776
 
777
777
  if (theme) {
778
778
  style.className += ' ' + theme;
@@ -807,10 +807,10 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
807
807
  }
808
808
  }
809
809
  },
810
- onEachFeature: (feature, layer) => feature.geometry && feature.geometry.type != 'Point' && this.addData(feature, layer),
810
+ onEachFeature: (feature, layer) => feature.geometry && feature.geometry.type != 'Point' && dataAdded.push(this.addData(feature, layer)),
811
811
  });
812
812
 
813
- this.import(this.__D3).then(() => {
813
+ this.import(this.__D3).then(() => Promise.all(dataAdded)).then(() => {
814
814
  this._initMapIntegrations(layer);
815
815
  const event_data = { data: geojson, layer: layer, name: this.track_info.name, track_info: this.track_info };
816
816
  if (this._modulesLoaded) {
@@ -914,7 +914,10 @@ export const Elevation = L.Control.Elevation = L.Control.extend({
914
914
  this._chartEnabled = this._chart._hasActiveLayers();
915
915
 
916
916
  // toggle layer visibility on empty chart
917
- this._layers.eachLayer(layer => _.toggleClass(layer.getElement && layer.getElement(), this.options.polyline.className + ' ' + this.options.theme, this._chartEnabled));
917
+ this._layers.eachLayer(layer => {
918
+ _.toggleClass(layer.getElement && layer.getElement(), this.options.polyline.className + ' ' + this.options.theme, this._chartEnabled);
919
+ if (layer._renderer instanceof L.Canvas) layer.redraw();
920
+ });
918
921
 
919
922
  // toggle option value (eg. altitude = { 'disabled' || 'enabled' })
920
923
  this.options[name] = !enabled && this.options[name] == 'disabled' ? 'enabled' : 'disabled';
@@ -16,6 +16,7 @@
16
16
  * },
17
17
  * })
18
18
  * ```
19
+ * `min` and `max` can also be numeric bounds.
19
20
  */
20
21
  export function LinearGradient() {
21
22
 
@@ -80,8 +81,8 @@ export function LinearGradient() {
80
81
  const { defs } = chart._chart.utils;
81
82
 
82
83
  const palette = get_palette({
83
- min: isFinite(this.track_info[min]) ? this.track_info[min] : 0,
84
- max: isFinite(this.track_info[max]) ? this.track_info[max] : 1,
84
+ min: isFinite(min) ? Number(min) : (isFinite(this.track_info[min]) ? this.track_info[min] : 0),
85
+ max: isFinite(max) ? Number(max) : (isFinite(this.track_info[max]) ? this.track_info[max] : 1),
85
86
  range,
86
87
  });
87
88
 
@@ -98,8 +99,14 @@ export function LinearGradient() {
98
99
  }
99
100
 
100
101
  // Generate gradient for each segment picking colors from palette
101
- for (let i = 0, data = this._data; i < data.length; i++) {
102
- gradient.addColorStop((i) / data.length, palette.getRGBColor(data[i][attr]));
102
+ const data = this._data;
103
+ const xAttr = chart._props.areas[path_name].xAttr;
104
+ const minX = data[0][xAttr];
105
+ const xRange = data[data.length - 1][xAttr] - minX;
106
+
107
+ for (let i = 0; i < data.length; i++) {
108
+ const offset = xRange ? (data[i][xAttr] - minX) / xRange : 0;
109
+ gradient.addColorStop(offset, palette.getRGBColor(data[i][attr]));
103
110
  }
104
111
 
105
112
  });
@@ -40,7 +40,7 @@ export function Time() {
40
40
  if (!point.meta || !point.meta.time) {
41
41
  point.meta = point.meta || {};
42
42
  if (i > 0) {
43
- let dx = (this._data[i].dist - this._data[i - 1].dist);
43
+ let dx = this._data[i].latlng.distanceTo(this._data[i - 1].latlng) / 1000;
44
44
  let t0 = this._data[i - 1].time.getTime();
45
45
  point.meta.time = new Date(t0 + ( dx / this._timeAVGSpeed) * this.options.timeFactor * 1000);
46
46
  } else {
@@ -57,16 +57,24 @@ export function Time() {
57
57
  scale: (opts.time && opts.time != "summary" && !L.Browser.mobile) && {
58
58
  axis : "x",
59
59
  position : "top",
60
- scale : {
61
- attr : "duration",
62
- min : 0,
63
- },
60
+ scale : "x",
64
61
  label : time.label,
65
62
  labelY : -10,
66
63
  labelX : () => this._width(),
67
64
  name : "time",
68
65
  ticks : () => _.clamp(this._chart._xTicks() / 2, [4, +Infinity]),
69
- tickFormat : (d) => (d == 0 ? '' : opts.xTimeFormat(d)),
66
+ tickFormat : (distance) => {
67
+ const data = this._data;
68
+ if (!data.length) return '';
69
+ const i = d3.bisector(point => point[opts.xAttr]).right(data, distance);
70
+ const start = data[Math.max(0, i - 1)];
71
+ const end = data[Math.min(i, data.length - 1)];
72
+ const span = end[opts.xAttr] - start[opts.xAttr];
73
+ // Time is only linear between consecutive recorded points, not across the whole track.
74
+ const fraction = span ? _.clamp((distance - start[opts.xAttr]) / span, [0, 1]) : 0;
75
+ const duration = start.duration + fraction * (end.duration - start.duration);
76
+ return duration == 0 ? '' : opts.xTimeFormat(duration);
77
+ },
70
78
  onAxisMount: axis => {
71
79
  axis.select(".domain")
72
80
  .remove();
package/src/utils.spec.js DELETED
@@ -1,48 +0,0 @@
1
- /**
2
- * src/utils.js
3
- */
4
-
5
- import { test } from 'node:test';
6
- import assert from 'node:assert/strict';
7
-
8
- // Importing utils requires Leaflet namespaces, but these arithmetic tests do not use them.
9
- globalThis.L = { DomEvent: {}, Util: {}, DomUtil: {} };
10
- const { iAvg, iMin, iMax, iSum } = await import('./utils.js');
11
-
12
- const toFixed = (n) => +n.toFixed(2);
13
-
14
- test('iAvg()', () => {
15
- let avg;
16
- avg = iAvg(100, undefined, 1); assert.strictEqual(toFixed(avg), 100); // average for [100] is 100
17
- avg = iAvg(100, avg, 2); assert.strictEqual(toFixed(avg), 100); // average for [100, 100] is 100
18
- avg = iAvg(200, avg, 3); assert.strictEqual(toFixed(avg), 133.33); // average for [100, 100, 200] is 133.33
19
- avg = iAvg(200, avg, 4); assert.strictEqual(toFixed(avg), 150); // average for [100, 100, 200, 200] is 150
20
- avg = iAvg(NaN, avg, 5); assert.ok(isNaN(avg)); // average for [100, 100, 200, 200, NaN] is NaN
21
- });
22
-
23
- test('iMin()', () => {
24
- let min;
25
- min = iMin(100, undefined); assert.strictEqual(toFixed(min), 100); // min for [100] is 100
26
- min = iMin(NaN, min); assert.strictEqual(toFixed(min), 100); // min for [100, NaN] is 100
27
- min = iMin(0, min); assert.strictEqual(toFixed(min), 0); // min for [100, NaN, 0] is 0
28
- min = iMin(-200, min); assert.strictEqual(toFixed(min), -200); // min for [100, NaN, 0, -200] is -200
29
- min = iMin(200, min); assert.strictEqual(toFixed(min), -200); // min for [100, NaN, 0, -200, 200] is -200
30
- });
31
-
32
- test('iMax()', () => {
33
- let max;
34
- max = iMax(100, undefined); assert.strictEqual(toFixed(max), 100); // max for [100] is 100
35
- max = iMax(NaN, max); assert.strictEqual(toFixed(max), 100); // max for [100, NaN] is 100
36
- max = iMax(0, max); assert.strictEqual(toFixed(max), 100); // max for [100, NaN, 0] is 100
37
- max = iMax(-200, max); assert.strictEqual(toFixed(max), 100); // max for [100, NaN, 0, -200] is 100
38
- max = iMax(200, max); assert.strictEqual(toFixed(max), 200); // max for [100, NaN, 0, -200, 200] is 200
39
- });
40
-
41
- test('iSum()', () => {
42
- let sum;
43
- sum = iSum(10.25, undefined); assert.strictEqual(toFixed(sum), 10.25); // sum for [10.25] is 10.25
44
- sum = iSum(0, sum); assert.strictEqual(toFixed(sum), 10.25); // sum for [10.25, 0] is 10.25
45
- sum = iSum(-0.25, sum); assert.strictEqual(toFixed(sum), 10); // sum for [10.25, 0, -0.25] is 10
46
- sum = iSum(-10, sum); assert.strictEqual(toFixed(sum), 0); // sum for [10.25, 0, -0.25, -10] is 0
47
- sum = iSum(NaN, sum); assert.ok(isNaN(sum)); // sum for [10.25, 0, -0.25, -10, NaN] is NaN
48
- });