@raruto/leaflet-elevation 1.8.6 → 1.8.9
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 +2 -2
- package/dist/leaflet-elevation.js +122 -125
- package/dist/leaflet-elevation.js.map +1 -1
- package/dist/leaflet-elevation.min.js +2 -2
- package/dist/leaflet-elevation.min.js.map +1 -1
- package/package.json +1 -1
- package/src/components.js +1 -1
- package/src/control.js +65 -61
- package/src/index.js +10 -8
- package/libs/extended-ui.js +0 -107
- package/libs/extended-ui.min.js +0 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";!function(t,e){"function"==typeof define&&define.amd?define(["leaflet"],t):"object"==typeof exports&&(module.exports=t(require("leaflet"))),void 0!==e&&e.L&&t(e.L)}((function(t){return t.locales={},t.locale=null,t.registerLocale=function(e,i){t.locales[e]=t.Util.extend({},t.locales[e],i)},t.setLocale=function(e){t.locale=e},t.i18n=t._=function(e,i){t.locale&&t.locales[t.locale]&&t.locales[t.locale][e]&&(e=t.locales[t.locale][e]);try{e=t.Util.template(e,i)}catch(t){}return e}}),window);var t=6e4,e=60*t,i=24*e;function a(a){var n=Math.floor(a/i),r=Math.floor((a-n*i)/e),o=Math.floor((a-n*i-r*e)/t),s=Math.round((a-n*i-r*e-o*t)/1e3);return 60===s&&(o++,s=0),60===o&&(r++,o=0),24===r&&(n++,r=0),(n?n+"d ":"")+r.toString().padStart(2,0)+":"+o.toString().padStart(2,0)+"'"+s.toString().padStart(2,0)+'"'}function n(t,e){var i=m("a","",{href:t,target:"_new",download:e||"",style:"display:none;"}),a=document.body;a.appendChild(i),i.click(),a.removeChild(i)}function r(t,e,i){return!1===e?Promise.resolve():i instanceof Promise?i:new Promise((function(e,i){var a=document.createElement("script");a.addEventListener("load",e,{once:!0}),a.src=t,document.head.appendChild(a)}))}function o(t,e){e.classed("canvas-path",!0),t.beginPath(),t.moveTo(0,0);var i=new Path2D(e.attr("d"));t.strokeStyle=e.attr("stroke"),t.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 s(t,e){return e?t<e[0]?e[0]:t>e[1]?e[1]:t:t}function l(t,e){t&&e.split(" ").every((function(e){return e&&L.DomUtil.addClass(t,e)}))}function h(t,e){t&&e.split(" ").every((function(e){return e&&L.DomUtil.removeClass(t,e)}))}function c(t,e,i){return(i?l:h).call(null,t,e)}function d(t,e,i){e&&h(t,e),i&&l(t,i)}function u(t,e,i){return void 0===i?L.DomUtil.getStyle(t,e):t.style.setProperty(e,i)}function _(t,e,i,a){return u(t,e,a?i:"")}function p(t,e,i,a){return t[a?"on":"off"](e,i)}function m(t,e,i,a){var n=L.DomUtil.create(t,e||"");return i&&v(n,i),a&&f(a,n),n}function f(t,e){return t.appendChild(e)}function g(t,e,i){return t.insertAdjacentElement(i,e)}function v(t,e){for(var i in e)t.setAttribute(i,e[i])}function y(t,e){return(e||document).querySelector(t)}var x=L.DomEvent.on,b=L.DomEvent.off,k=L.DomUtil.hasClass;function w(){return Math.random().toString(36).substr(2,9)}function C(t,e){for(var i in t)e(t[i],i)}var M=Object.freeze({__proto__:null,formatTime:a,saveFile:n,lazyLoader:r,drawCanvas:o,clamp:s,addClass:l,removeClass:h,toggleClass:c,replaceClass:d,style:u,toggleStyle:_,toggleEvent:p,create:m,append:f,insert:g,setAttributes:v,select:y,on:x,off:b,hasClass:k,randomId:w,each:C}),S={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"}},A=function(t){t.width;var e=t.height,i=t.xAttr,a=t.yAttr,n=t.scaleX,r=t.scaleY,o=t.interpolation,s=void 0===o?"curveLinear":o;return d3.area().curve("string"==typeof s?d3[s]:s).x((function(t){return t.xDiagCoord=n(t[i])})).y0(e).y1((function(t){return r(t[a])}))},E=function(t){var e=t.name,i=t.color,a=t.strokeColor,n=t.strokeOpacity,r=t.fillOpacity,o=d3.create("svg:path");return e&&o.classed(e,!0),o.style("pointer-events","none"),o.attr("fill",i||"#3366CC").attr("stroke",a||"#000").attr("stroke-opacity",n||"1").attr("fill-opacity",r||"0.8"),o},z=function(t){var e=t.type,i=void 0===e?"axis":e,a=t.tickSize,n=void 0===a?6:a,r=t.tickPadding,o=void 0===r?3:r,s=t.position,l=t.height,h=t.width,c=t.axis,d=t.scale,u=t.ticks,_=t.tickFormat,p=t.label,m=t.labelX,f=t.labelY,g=t.name,v=void 0===g?"":g,y=t.onAxisMount;return function(t){var e=0,a=0;"bottom"==s&&(a=l),"right"==s&&(e=h),"x"==c&&"grid"==i?n=-l:"y"==c&&"grid"==i&&(n=-h);var r=d3["axis"+s.replace(/\b\w/g,(function(t){return t.toUpperCase()}))]().scale(d).ticks(u).tickPadding(o).tickSize(n).tickFormat(_),g=t.append("g").attr("class",[c,i,s,v].join(" ")).attr("transform","translate("+e+","+a+")").call(r);return p&&g.append("svg:text").attr("x",m).attr("y",f).text(p),y&&g.call(y),g}},D=function(t){return t.type="grid",z(t)},F=function(t){var e=t.theme,i=t.xCoord,a=void 0===i?0:i,n=t.yCoord,r=void 0===n?0:n,o=t.labels,s=void 0===o?{}:o,l=t.item,h=void 0===l?{}:l,c=t.length,d=void 0===c?0:c;return function(t){var i,n=t.select(".height-focus.line"),o=t.select(".height-focus.circle-lower"),l=t.select(".height-focus-label");if(n.node()||(n=t.append("svg:line")),o.node()||(o=t.append("svg:circle")),l.node()||(l=t.append("svg:text")),isNaN(a)||isNaN(r))return t;for(var c in o.attr("class",e+" height-focus circle-lower").attr("transform","translate("+a+","+r+")").attr("r",6).attr("cx",0).attr("cy",0),n.attr("class",e+" height-focus line").attr("x1",a).attr("x2",a).attr("y1",r).attr("y2",d),l.attr("class",e+" height-focus-label").style("pointer-events","none").attr("x",a+5).attr("y",d),s)(i=l.select(".height-focus-"+s[c].name)).size()||(i=l.append("svg:tspan").attr("class","height-focus-"+s[c].name).attr("dy","1.5em")),i.text("function"!=typeof s[c].value?s[c].value:s[c].value(h));return l.select("tspan").attr("dy",l.selectAll("tspan").size()>1?"-1.5em":"0em"),l.selectAll("tspan").attr("x",a+5),t}},T=function(t){var e=t.name,i=t.label,a=t.width,n=t.height,r=t.margins,o=void 0===r?{}:r,s=t.color,l=t.path;return function(t){return t.attr("class","legend-item legend-"+e.toLowerCase()).attr("data-name",e),t.on("click.legend",(function(){return d3.select(t.node().ownerSVGElement||t).dispatch("legend_clicked",{detail:{path:l.node(),name:e,legend:t.node(),enabled:!l.classed("leaflet-hidden")}})})),t.append("svg:rect").attr("x",a/2-50).attr("y",n+o.bottom/2).attr("width",50).attr("height",10).attr("fill",s).attr("stroke","#000").attr("stroke-opacity","0.5").attr("fill-opacity","0.25"),t.append("svg:text").text(L._(i||e)).attr("x",a/2+5).attr("font-size",10).style("text-decoration-thickness","2px").style("font-weight","700").attr("y",n+o.bottom/2).attr("dy","0.75em"),t}},I=function(t){var e=t.xCoord,i=t.yCoord,a=t.width,n=t.height,r=t.labels,o=void 0===r?{}:r,s=t.item,l=void 0===s?{}:s;return function(t){var r=t.select(".mouse-focus-line"),s=t.select(".mouse-focus-label");r.node()||(r=t.append("svg:line")),s.node()||(s=t.append("g"));var h=s.select(".mouse-focus-label-rect"),c=s.select(".mouse-focus-label-text");h.node()||(h=s.append("svg:rect")),c.node()||(c=s.append("svg:text"));var d,u=0,_=0,p={width:0,height:0};try{p=c.node().getBBox()}catch(e){return t}for(var m in e&&(u=e+(e<a/2?10:-p.width-10)),i&&(_=Math.max(i-p.height,L.Browser.webkit?0:-1/0)),r.attr("class","mouse-focus-line").attr("x2",e).attr("y2",0).attr("x1",e).attr("y1",n),s.attr("class","mouse-focus-label"),h.attr("class","mouse-focus-label-rect").attr("x",u-5).attr("y",_-5).attr("width",p.width+10).attr("height",p.height+10).attr("rx",3).attr("ry",3),c.attr("class","mouse-focus-label-text").style("font-weight","700").attr("y",_),o)(d=c.select(".mouse-focus-label-"+o[m].name)).size()||(d=c.append("svg:tspan",".mouse-focus-label-x").attr("class","mouse-focus-label-"+o[m].name).attr("dy","1.5em")),d.text("function"!=typeof o[m].value?o[m].value:o[m].value(l));return c.select("tspan").attr("dy","1em"),c.selectAll("tspan").attr("x",u),t}},P=function(t){var e=t.height,i=t.width;return function(t){t.data([{x:0,y:e}]).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"}));var a=t.selectAll(".horizontal-drag-rect").data([{w:i}]),n=t.selectAll(".horizontal-drag-line").data([{w:i}]),r=t.selectAll(".horizontal-drag-label").data([{w:i-8}]),o=t.selectAll(".horizontal-drag-symbol").data([{type:d3.symbolTriangle,x:i+7,y:0,angle:-90,size:50}]);return a.exit().remove(),n.exit().remove(),r.exit().remove(),o.exit().remove(),a.enter().append("svg:rect").attr("class","horizontal-drag-rect").attr("x",0).attr("y",-8).attr("height",8).attr("fill","none").attr("pointer-events","all").merge(a).attr("width",(function(t){return t.w})),n.enter().append("svg:line").attr("class","horizontal-drag-line").attr("x1",0).merge(n).attr("x2",(function(t){return t.w})),r.enter().append("svg:text").attr("class","horizontal-drag-label").attr("text-anchor","end").attr("y",-8).merge(r).attr("x",(function(t){return t.w})),o.enter().append("svg:path").attr("class","horizontal-drag-symbol").merge(o).attr("d",d3.symbol().type((function(t){return t.type})).size((function(t){return t.size}))).attr("transform",(function(t){return"translate("+t.x+","+t.y+") rotate("+t.angle+")"})),t}},O=function(t){var e=t.point,i=t.height,a=t.width,n=t.x,r=t.y;return function(t){return isNaN(n)||isNaN(r)||(e.item&&e.item.property("isConnected")||(e.position=e.position||"bottom",e.item=t.append("g"),e.item.append("svg:line").attr("y1",0).attr("x1",0).attr("style","stroke: rgb(51, 51, 51); stroke-width: 0.5; stroke-dasharray: 2, 2;"),e.item.append("svg:circle").attr("class"," height-focus circle-lower").attr("r",3),e.label&&e.item.append("svg:text").attr("dx","4px").attr("dy","-4px")),e.item.datum({pos:e.position,x:n,y:r}).attr("class",(function(t){return"point "+t.pos})).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"})),e.item.select("line").datum({y2:{top:-r,bottom:i-r}[e.position],x2:{left:-n,right:a-n}[e.position]||0}).attr("y2",(function(t){return t.y2})).attr("x2",(function(t){return t.x2})),e.label&&e.item.select("text").text(e.label)),t}},N=function(t){var e=t.min,i=t.max,a=t.attr,n=t.name,r=t.forceBounds,o=t.scale;return function(t){a=a||n,o&&o.attr&&(a=o.attr);var s=t&&t.length?d3.extent(t,(function(t){return t[a]})):[0,1];return void 0!==e&&(e<s[0]||r)&&(s[0]=e),void 0!==i&&(i>s[1]||r)&&(s[1]=i),s}},B=function(t){var e=t.axis;return function(t,i){return"x"==e?[0,t]:"y"==e?[i,0]:void 0}},G=function(t){var e=t.data,i=t.attr,a=t.min,n=t.max,r=t.forceBounds,o=t.range;return d3.scaleLinear().range(o).domain(N({min:a,max:n,attr:i,forceBounds:r})(e))},X=function(t){var e=t.width,i=t.height,a=t.margins,n=void 0===a?{}:a,r=(t.ruler,e-n.left-n.right),o=i-n.top-n.bottom,s=d3.create("svg:svg").attr("class","background"),l=s.append("g"),h={grid:l.append("g").attr("class","grid"),area:l.append("g").attr("class","area"),point:l.append("g").attr("class","point"),axis:l.append("g").attr("class","axis"),brush:l.append("g").attr("class","brush"),tooltip:l.append("g").attr("class","tooltip").attr("display","none"),ruler:l.append("g").attr("class","ruler"),legend:l.append("g").attr("class","legend")},c=h.area.append("svg:mask").attr("id","elevation-clipper").attr("fill-opacity",1),d=c.append("svg:rect").attr("class","zoom").attr("fill","white"),u=h.area.append("svg:foreignObject").attr("mask","url(#"+c.attr("id")+")"),_=u.append("xhtml:canvas").attr("class","canvas-plot"),p=_.node().getContext("2d");h.tooltip.call(I({xCoord:0,yCoord:0,height:o,width:r,labels:{}}));var m=d3.brushX().on("start.cursor end.cursor brush.cursor",(function(){return h.brush.select(".overlay").attr("cursor",null)})),f={mask:c,canvas:_,context:p,brush:m},g={svg:s,g:l,panes:h,utils:f,scale:function(t){return{x:G(t.x),y:G(t.y)}},_resize:function(t){var e=t.width,i=t.height,a=t.margins,n=void 0===a?{}:a,r=t.ruler,o=e-n.left-n.right,c=i-n.top-n.bottom;s.attr("viewBox","0 0 ".concat(e," ").concat(i)).attr("width",e).attr("height",i),l.attr("transform","translate("+n.left+","+n.top+")"),/Mac|iPod|iPhone|iPad/.test(navigator.platform)&&/AppleWebkit/i.test(navigator.userAgent)&&_.style("transform","translate("+n.left+"px,"+n.top+"px)"),d.attr("x",0).attr("y",0).attr("width",o).attr("height",c),u.attr("width",o).attr("height",c),_.attr("width",o).attr("height",c),r&&h.ruler.call(P({height:c,width:o})),h.brush.call(m.extent([[0,0],[o,c]])),h.brush.select(".overlay").attr("cursor",null),g._width=o,g._height=c,g.svg.dispatch("resize",{detail:{width:o,height:c}})},pane:function(t){return h[t]||(h[t]=l.append("g").attr("class",t)),h[t]},get:function(t){return f[t]}};return g._resize({width:e,height:i,margins:n}),g},H=Object.freeze({__proto__:null,Colors:S,Area:A,Path:E,Axis:z,Grid:D,PositionMarker:F,LegendItem:T,Tooltip:I,Ruler:P,CheckPoint:O,Domain:N,Range:B,Scale:G,Bisect:function(t){var e=t.data,i=void 0===e?[0,1]:e,a=t.scale,n=t.x,r=t.attr;return d3.bisector((function(t){return t[r]})).left(i,a.invert(n))},Chart:X}),U=L.Class.extend({includes:L.Evented?L.Evented.prototype:L.Mixin.Events,initialize:function(t,e){var i=this;this.options=t,this.control=e,this._data=[],this._props={scales:{},paths:{},areas:{},grids:{},axes:{},legendItems:{},tooltipItems:{}},this._scales={},this._domains={},this._ranges={},this._paths={},this._brushEnabled=t.dragging,this._zoomEnabled=t.zooming;var a=this._chart=X(t);this._container=a.svg;this._grid=a.pane("grid"),this._area=a.pane("area"),this._point=a.pane("point"),this._axis=a.pane("axis"),this._legend=a.pane("legend"),this._tooltip=a.pane("tooltip"),this._ruler=a.pane("ruler"),this._initScale(),this._mask=a.get("mask"),this._context=a.get("context"),this._brush=a.get("brush"),this._zoom=d3.zoom(),this._drag=d3.drag(),this._initInteractions(),this._maskGaps=[],e.on("eletrack_added",(function(t){i._maskGaps.push(t.index),e.once("eledata_updated",(function(t){return i._maskGaps.push(t.index)}))}))},update:function(t){return t&&(t.data&&(this._data=t.data),t.options&&(this.options=t.options)),this._updateScale(),this._updateArea(),this._updateAxis(),this._updateLegend(),this._updateClipper(),this},render:function(){var t=this;return function(e){return e.append((function(){return t._container.node()}))}},clear:function(){this._resetDrag(),this._hideDiagramIndicator(),this._area.selectAll("path").attr("d","M0 0"),this._context.clearRect(0,0,this._width(),this._height()),this._maskGaps=[],this._mask.selectAll(".gap").remove()},_drawPath:function(t){var e=this._paths[t],i=this._props.areas[t];e.datum(this._data).attr("d",A(L.extend({},i,{width:this._width(),height:this._height(),scaleX:this._scales[i.scaleX],scaleY:this._scales[i.scaleY]}))),e.classed("leaflet-hidden")||(this.options.preferCanvas?o(this._context,e):this._area.append((function(){return e.node()})))},_hasActiveLayers:function(){var t=this._paths;for(var e in t)if(!t[e].classed("leaflet-hidden"))return!0;return!1},_initBrush:function(t){var e=this,i=function(t){if(e._data.length&&("brush"!=t.type||t.sourceEvent)){var i=e._chart.panes.brush.select(".overlay").node(),a=d3.pointers(t,i)[0][0],n=e._data[e._findIndexForXCoord(a)];e.fire("mouse_move",{item:n,xCoord:a})}};this._brush.filter((function(t){return e._brushEnabled&&!t.shiftKey&&!t.button})).on("end.update",(function(t){if(e._data.length){var i=t.selection;if(i){var a=e._findIndexForXCoord(i[0]),n=e._findIndexForXCoord(i[1]);e.fire("dragged",{dragstart:e._data[a],dragend:e._data[n]})}}})).on("brush.update",i),this._chart.panes.brush.on("mouseenter.focus touchstart.focus",this.fire.bind(this,"mouse_enter")).on("mouseout.focus touchend.focus",this.fire.bind(this,"mouse_out")).on("mousemove.focus touchmove.focus",i)},_initClipper:function(){var t=this,e=this._container,i=this.options.margins,a=this._zoom;a.scaleExtent([1,10]).extent([[i.left,0],[this._width()-i.right,this._height()]]).translateExtent([[i.left,-1/0],[this._width()-i.right,1/0]]).filter((function(e){return t._zoomEnabled&&(e.shiftKey||4==e.buttons)})).on("start",(function(i){i.sourceEvent&&"mousedown"==i.sourceEvent.type&&e.style("cursor","grabbing"),1==i.transform.k&&0==i.transform.x&&(t._container.classed("zoomed",!0),t._mask&&t._point.attr("mask","url(#"+t._mask.attr("id")+")")),t.zooming=!0})).on("end",(function(i){1==i.transform.k&&0==i.transform.x&&(t._container.classed("zoomed",!1),t._mask&&t._point.attr("mask",null)),t.zooming=!1,e.style("cursor","")})).on("zoom",(function(e){t.zooming=!1,t._updateScale(),t.zooming=!0,t._scales.distance=t._x=e.transform.rescaleX(t._x),t._scales.time&&(t._scales.time=e.transform.rescaleX(t._scales.time)),t._resetDrag(),e.sourceEvent&&"mousemove"==e.sourceEvent.type&&t._hideDiagramIndicator(),t.fire("zoom")})),e.call(a)},_initInteractions:function(){this._initBrush(),this._initRuler(),this._initClipper(),this._initLegend()},_initLegend:function(){var t=this;this._container.on("legend_clicked",(function(e){var i=e.detail,a=i.path,n=i.legend,r=i.name,o=i.enabled;if(a){var s=y("text",n),l=y("rect",n);_(s,"text-decoration-line","line-through",o),_(l,"fill-opacity","0",o),c(a,"leaflet-hidden",o),t._updateArea(),t.fire("elepath_toggle",{path:a,name:r,legend:n,enabled:o})}}))},_initRuler:function(){var t=this;if(this.options.ruler){var e=d3.format(".0f"),i=this._drag;i.on("start end",(function(e,i){var a=t._height(),n=t._ruler.data()[0].y;(n>=a||n<=0)&&t._ruler.select(".horizontal-drag-label").text(""),t._hideDiagramIndicator()})).on("drag",(function(i,a){var n=t._height(),r=d3.pointers(i,t._area.node())[0][1],o=r>0?r<n?r:n:0,s=t._y.invert(o),l=L.extend(t._ruler.data()[0],{y:o});t._ruler.data([l]).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"})).classed("active",o<n),t._container.select(".horizontal-drag-label").text(e(s)+" "+(t.options.imperial?"ft":"m")),t.fire("ruler_filter",{coords:r<n&&r>0?t._findCoordsForY(r):[]})})),this._ruler.call(i)}},_initScale:function(){var t=this.options;this._registerAxisScale({axis:"x",position:"bottom",attr:t.xAttr,min:t.xAxisMin,max:t.xAxisMax,name:"distance"}),this._registerAxisScale({axis:"y",position:"left",attr:t.yAttr,min:t.yAxisMin,max:t.yAxisMax,name:"altitude"}),this._x=this._scales.distance,this._y=this._scales.altitude},_registerAreaPath:function(t){var e=this.options;t.xAttr||(t.xAttr=e.xAttr),t.yAttr||(t.yAttr=e.yAttr),void 0===t.preferCanvas&&(t.preferCanvas=e.preferCanvas);var i=E(t);this._paths[t.name]=i,this._props.areas[t.name]=t,e.legend&&(this._props.legendItems[t.name]={name:t.name,label:t.label,color:t.color,path:i})},_registerAxisGrid:function(t){this._props.grids[t.name||t.axis]=t},_registerAxisScale:function(t){var e=this.options,i=t.scale;if("function"==typeof this._scales[t.name])t.scale=this._scales[t.name];else if("function"!=typeof i){(i=L.extend({data:this._data,forceBounds:e.forceAxisBounds},i)).attr=i.attr||t.name;var a=this._domains[t.name]=N(t),n=this._ranges[t.name]=B(t);i.range=i.range||n(this._width(),this._height()),i.domain=i.domain||a(this._data),this._props.scales[t.name]=i,t.scale=this._scales[t.name]=G(i)}return t.ticks||("x"==t.axis?t.ticks=e.xTicks:"y"==t.axis&&(t.ticks=e.yTicks)),this._props.axes[t.name]=t,i},_registerCheckPoint:function(t){var e,i,a;this._data.length&&(t.latlng?(e=this._data[this._findIndexForLatLng(t.latlng)],i=this._x(e.dist),a=this._y(e.z)):isNaN(t.dist)||(i=this._x(t.dist),e=this._data[this._findIndexForXCoord(i)],a=this._y(e.z)),this._point.call(O({point:t,width:this._width(),height:this._height(),x:i,y:a})))},_registerTooltip:function(t){this._props.tooltipItems[t.name]=t},_updateArea:function(){var t=this._paths;for(var e in this._context.clearRect(0,0,this._width(),this._height()),t)t[e].classed("leaflet-hidden")||this._drawPath(e)},_updateAxis:function(){var t=this.options;this._grid.selectAll("g").remove(),this._axis.selectAll("g").remove();var e,i,a,n=this._props.grids,r=this._props.axes,o={width:this._width(),height:this._height(),tickFormat:""},s={width:this._width(),height:this._height()};for(var l in n)e=L.extend({},o,n[l]),a=D(e),this._grid.call(a);for(var h in r)!1!==t[h]&&"summary"!==t[h]&&(e=L.extend({},s,r[h]),i=z(e),this._axis.call(i));this._axis.selectAll(".y.axis.right").each((function(t,e,i){var a=d3.select(i[e]),n=a.attr("transform"),r=n.substring(n.indexOf("(")+1,n.indexOf(")")).split(",");a.attr("transform","translate("+(+r[0]+40*e)+","+r[1]+")"),e>0&&(a.select(":scope > path").attr("opacity",.25),a.selectAll(":scope > .tick line").attr("opacity",.75))}))},_updateClipper:function(){var t=this,e=this.options.margins;this._zoom.scaleExtent([1,10]).extent([[e.left,0],[this._width()-e.right,this._height()]]).translateExtent([[e.left,-1/0],[this._width()-e.right,1/0]]),this._mask.selectAll(".gap").remove(),this._maskGaps.forEach((function(e,i){if(!(i>=t._maskGaps.length-2)){var a=t._data[t._maskGaps[i]],n=t._data[t._maskGaps[i+1]],r=t._x(t._data[t._findIndexForLatLng(a.latlng)].dist),o=t._x(t._data[t._findIndexForLatLng(n.latlng)].dist);t._mask.append("rect").attr("x",r).attr("y",0).attr("width",o-r).attr("height",t._height()).attr("class","gap").attr("fill-opacity","0.8").attr("fill","black")}}))},_updateLegend:function(){var t=this;if(!1!==this.options.legend){var e,i=this._props.legendItems;for(var a in this._legend.selectAll("g").remove(),i)e=T(L.extend({width:this._width(),height:this._height(),margins:this.options.margins},i[a])),this._legend.append("g").call(e);var n=this._legend.selectAll(".legend-item"),r=n.nodes().length,o=Array(Math.floor(r/2)).fill(null).map((function(t,e){return 2*(e+1)-(1-Math.sign(r%2))})),s=o.slice().reverse().map((function(t){return-t}));r%2!=0&&s.push(0),o=s.concat(o);var l=this._axis.selectAll(".x.axis.bottom").nodes().length,h=30+2*l,c=30*r;r&&this.options.margins.right<c&&(this.options.margins.right=c,this.fire("margins_updated")),l&&this.options.margins.bottom<h&&(this.options.margins.bottom=h,this.fire("margins_updated")),n.each((function(e,i,a){var n=d3.select(a[i]),r=(n.select("rect"),n.attr("data-name")),s=t._paths[r],h=55*o[i],c=2*l;n.attr("transform","translate("+h+", "+c+")"),r in t.options&&"disabled"==t.options[r]&&(s.classed("leaflet-hidden",!0),n.select("text").style("text-decoration-line","line-through"),n.select("rect").style("fill-opacity","0")),t._mask&&s.attr("mask","url(#"+t._mask.attr("id")+")")}))}},_updateScale:function(){if(this.zooming)return{x:this._x,y:this._y};for(var t in this._scales)this._scales[t].domain(this._domains[t](this._data)).range(this._ranges[t](this._width(),this._height()));return{x:this._x,y:this._y}},_width:function(){return this._chart._width},_height:function(){return this._chart._height},_findCoordsForY:function(t){var e,i=this._data,a=this._y.invert(t),n=i.reduce((function(t,e,i){return e.z>=a&&t.push(i),t}),[]),r=0;return n.reduce((function(t,a,o){return n[e=o+1]===n[o]+1&&e!==n.length||(t.push(n.slice(r,e).map((function(t){return i[t].latlng}))),r=e),t}),[])},_findIndexForXCoord:function(t){var e=this;return d3.bisector((function(t){return t[e.options.xAttr]})).left(this._data||[0,1],this._x.invert(t))},_findIndexForLatLng:function(t){var e=null,i=1/0;return this._data.forEach((function(a,n){var r=t.distanceTo(a.latlng);r<i&&(i=r,e=n)})),e},_resetDrag:function(){this._chart.panes.brush.select(".selection").attr("width")&&(this._chart.panes.brush.call(this._brush.clear),this._hideDiagramIndicator(),this.fire("reset_drag"))},_resetZoom:function(){this._zoom&&this._zoom.transform(this._chart.svg,d3.zoomIdentity)},_showDiagramIndicator:function(t,e){this._tooltip.attr("display",null).call(I({xCoord:e,yCoord:this._y(t[this.options.yAttr]),height:this._height(),width:this._width(),labels:this._props.tooltipItems,item:t}))},_hideDiagramIndicator:function(){this._tooltip.attr("display","none")}});function R(t){return(R="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var j,V=L.Class.extend({initialize:function(t){switch(this.options=t,this.options.marker){case"elevation-line":this._container=d3.select(map.getPane("elevationPane")).select("svg > g").attr("class","height-focus-group");break;case"position-marker":this._marker=L.marker([0,0],{icon:this.options.markerIcon,zIndexOffset:1e6,interactive:!1})}return this._labels={},this},addTo:function(t){switch(this._map=t,this.options.marker){case"elevation-line":this._container.call(F({}));break;case"position-marker":this._marker.addTo(t,{pane:"overlayPane"})}return this},update:function(t){if(t?this._props=t:t=this._props,t)switch(t.options&&(this.options=t.options),this._map||this.addTo(t.map),this._latlng=t.item.latlng,this.options.marker){case"elevation-line":var e=this._map.latLngToLayerPoint(this._latlng);e=L.extend({},t.item,this._map._rotate?this._map.rotatedPointToMapPanePoint(e):e),this._container.classed("leaflet-hidden",!1),this._container.call(F({theme:this.options.theme,xCoord:e.x,yCoord:e.y,length:e.y-this._height()/t.maxElevation*e.z,labels:this._labels,item:e}));break;case"position-marker":h(this._marker.getElement(),"leaflet-hidden"),this._marker.setLatLng(this._latlng)}},remove:function(){switch(this._props=null,this.options.marker){case"elevation-line":this._container&&this._container.classed("leaflet-hidden",!0);break;case"position-marker":l(this._marker.getElement(),"leaflet-hidden")}},getLatLng:function(){return this._latlng},_height:function(){var t=this.options;return t.height-t.margins.top-t.margins.bottom},_registerTooltip:function(t){this._labels[t.name]=t}}),Y=L.Class.extend({initialize:function(t,e){this.options=t,this.control=e,u(this._container=m("div","elevation-summary "+(t.summary?t.summary+"-summary":"")),"max-width",t.width?t.width+"px":"")},render:function(){var t=this;return function(e){return e.append((function(){return t._container}))}},reset:function(){this._container.innerHTML=""},append:function(t,e,i){return this._container.innerHTML+='<span class="'.concat(t,'"><span class="summarylabel">').concat(e,'</span><span class="summaryvalue">').concat(i,"</span></span>"),this},_registerSummary:function(t){for(var e in t)this.append(e,L._(t[e].label),"function"!=typeof t[e].value?t[e].value:t[e].value(this.control.track_info))}}),J={autofitBounds:!0,autohide:!L.Browser.mobile,autohideMarker:!0,almostover:!0,altitude:!0,collapsed:!1,detached:!0,distance:!0,distanceMarkers:!1,decimalsX:2,decimalsY:0,dragging:!L.Browser.mobile,downloadLink:"link",elevationDiv:"#elevation-div",followMarker:!0,forceAxisBounds:!1,height:200,imperial:!1,interpolation:"curveLinear",lazyLoadJS:!0,legend:!0,margins:{top:30,right:30,bottom:30,left:40},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,skipNullZCoords:!1,theme:"lightblue-theme",summary:"inline",slope:!1,speed:!1,sLimit:void 0,time:!1,timeFactor:3600,timeFormat:!1,timestamps:!1,sDeltaMax:void 0,sInterpolation:"curveStepAfter",sRange:void 0,width:600,waypoints:!0,wptIcons:{"":L.divIcon({className:"elevation-waypoint-marker",html:'<i class="elevation-waypoint-icon"></i>',iconSize:[30,30],iconAnchor:[8,30]})},wptLabels:!0,xAttr:"dist",xLabel:"km",xTicks:void 0,yAttr:"z",yAxisMax:void 0,yAxisMin:void 0,yLabel:"m",yTicks:void 0,zFollow:!1,zooming:!L.Browser.Mobile},W=L.Control.Elevation=L.Control.extend({includes:L.Evented?L.Evented.prototype:L.Mixin.Events,options:J,__mileFactor:.621371,__footFactor:3.28084,__D3:"https://unpkg.com/d3@6.5.0/dist/d3.min.js",__TOGEOJSON:"https://unpkg.com/@tmcw/togeojson@4.3.0/dist/togeojson.umd.js",__LGEOMUTIL:"https://unpkg.com/leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js",__LALMOSTOVER:"https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js",__LDISTANCEM:"https://unpkg.com/@raruto/leaflet-elevation@1.8.5/libs/leaflet-distance-marker.min.js",addData:function(t,e){var i=this;this.lazyLoad(this.__D3).then((function(){void 0===e&&t.on&&(e=t),i._addData(t),i._addLayer(e),i._fireEvt("eledata_added",{data:t,layer:e,track_info:i.track_info})}))},addTo:function(t){if(this.options.detached){var e=this._initElevationDiv();e.isConnected||g(t.getContainer(),e,"afterend"),f(e,this.onAdd(t))}else L.Control.prototype.addTo.call(this,t);return this},clear:function(){this._marker&&this._marker.remove(),this._chart&&this._clearChart(),this._layers&&this._clearLayers(),this._markers&&this._clearMarkers(),this._data=[],this.track_info={},this._fireEvt("eledata_clear"),this._updateChart()},_clearChart:function(){var t=this;this._events&&this._events.elechart_updated&&this._events.elechart_updated.forEach((function(e){return t.off("elechart_updated",e.fn,e.ctx)})),this._chart&&this._chart._container&&(this._chart._container.selectAll("g.point .point").remove(),this._chart.clear())},_clearLayers:function(){this._layers&&this._layers.eachLayer&&(this._layers.eachLayer((function(t){return t.remove()})),this._layers.clearLayers())},_clearMarkers:function(){this._markers&&this._markers.eachLayer&&(this._markers.eachLayer((function(t){return t.remove()})),this._markers.clearLayers())},disableBrush:function(){this._chart._brushEnabled=!1,this._resetDrag()},enableBrush:function(){this._chart._brushEnabled=!0},disableZoom:function(){this._chart._zoomEnabled=!1,this._chart._resetZoom()},enableZoom:function(){this._chart._zoomEnabled=!0},fitBounds:function(t){t=t||this.getBounds(),this._map&&t.isValid()&&this._map.fitBounds(t)},getBounds:function(t){return t=t||this._data,L.latLngBounds(t.map((function(t){return t.latlng})))},getZFollow:function(){return this.options.zFollow},hide:function(){u(this._container,"display","none")},initialize:function(t){this._data=[],this._layers=L.featureGroup(),this._markers=L.featureGroup(),this._markedSegments=L.polyline([]),this._chartEnabled=!0,this.track_info={},L.setOptions(this,t),this.options.followMarker&&(this._setMapView=L.Util.throttle(this._setMapView,300,this)),this.options.legend&&(this.options.margins.bottom+=30),this.options.theme&&(this.options.polylineSegments.className+=" "+this.options.theme),!0===this.options.wptIcons&&(this.options.wptIcons=J.wptIcons),!0===this.options.distanceMarkers&&(this.options.distanceMarkers={lazy:!0}),this._markedSegments.setStyle(this.options.polylineSegments),L.extend(S,this.options.colors||{}),this._fixCanvasPaths(),this._fixTooltipSize()},lazyLoad:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(!this.options.lazyLoadJS)return Promise.resolve();switch(t){case this.__D3:i="_d3LazyLoader",e="object"!==("undefined"==typeof d3?"undefined":R(d3));break;case this.__TOGEOJSON:i="_togeojsonLazyLoader",e="object"!==("undefined"==typeof toGeoJSON?"undefined":R(toGeoJSON));break;case this.__LGEOMUTIL:i="_geomutilLazyLoader",e="object"!==R(L.GeometryUtil);break;case this.__LALMOSTOVER:i="_almostoverLazyLoader",e="function"!=typeof L.Handler.AlmostOver;break;case this.__LDISTANCEM:i="_distanceMarkersLazyLoader",e="function"!=typeof L.DistanceMarkers}return L.Control.Elevation[i]=r(t,e,L.Control.Elevation[i])},load:function(t){var e=this;this._parseFromString(t).then((function(i){return i?e._loadLayer(i):e._loadFile(t)}))},onAdd:function(t){var e=this;this._map=t;var i=this._container=m("div","elevation-control elevation "+this.options.theme+" "+(this.options.detached?"":"leaflet-control"));return this.lazyLoad(this.__D3).then((function(){e._initButton(i),e._initChart(i),e._initSummary(i),e._initMarker(t),e._initLayer(t),t.on("zoom viewreset zoomanim",e._hideMarker,e).on("resize",e._resetView,e).on("resize",e._resizeChart,e).on("rotate",e._rotateMarker,e).on("mousedown",e._resetDrag,e),x(t.getContainer(),"mousewheel",e._resetDrag,e),x(t.getContainer(),"touchstart",e._resetDrag,e),x(document,"keydown",e._keydownHandler,e),e.on("eledata_added eledata_loaded",e._updateChart,e).on("eledata_added eledata_loaded",e._updateSummary,e),e._updateChart(),e._updateSummary()})),i},onRemove:function(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),b(t.getContainer(),"mousewheel",this._resetDrag,this),b(t.getContainer(),"touchstart",this._resetDrag,this),b(document,"keydown",this._keydownHandler,this),this.off("eledata_added eledata_loaded",this._updateChart,this).off("eledata_added eledata_loaded",this._updateSummary,this)},redraw:function(){this._resizeChart()},setZFollow:function(t){this.options.zFollow=t},show:function(){u(this._container,"display","block")},_addData:function(t){var e=this;if(t){var i=t.geometry;if(i)switch(i.type){case"LineString":this._addGeoJSONData(i.coordinates);break;case"MultiLineString":C(i.coordinates,(function(t){return e._addGeoJSONData(t)}));break;default:console.warn("Unsopperted GeoJSON feature geometry type:"+i.type)}"FeatureCollection"===t.type&&C(t.features,(function(t){return e._addData(t)})),t._latlngs&&this._addGPXData(t._latlngs)}},_addGeoJSONData:function(t){var e=this;C(t,(function(t){e._addPoint(t[1],t[0],t[2]),e._fireEvt("elepoint_added",{point:t,index:e._data.length-1})})),this._fireEvt("eletrack_added",{coords:t,index:this._data.length-1})},_addGPXData:function(t){var e=this;C(t,(function(t){var i;e._addPoint(t.lat,t.lng,null!==(i=t.alt)&&void 0!==i?i:t.meta.ele),e._fireEvt("elepoint_added",{point:t,index:e._data.length-1})})),this._fireEvt("eletrack_added",{coords:t,index:this._data.length-1})},_addPoint:function(t,e,i){if(this.options.reverseCoords){var a=[e,t];t=a[0],e=a[1]}this._data.push({x:t,y:e,z:i,latlng:L.latLng(t,e,i)}),this._fireEvt("eledata_updated",{index:this._data.length-1})},_addLayer:function(t){t&&this._layers.addLayer(t),t&&this.options.distanceMarkers&&this.options.distanceMarkers.lazy&&t.on("add remove",(function(t){return L.DistanceMarkers&&t.target instanceof L.Polyline&&t.target[t.type+"DistanceMarkers"]()}))},_addMarker:function(t){t&&this._markers.addLayer(t)},_bindPopup:function(t){var e=t._popup;e&&(e.options.className="elevation-popup",e._content&&(e._content=decodeURI(e._content),e.bindTooltip(e._content,{direction:"auto",sticky:!0,opacity:1,className:"elevation-tooltip"}).openTooltip()))},_initAlmostOverHandler:function(t,e){var i=this;t&&this.options.almostOver&&this.lazyLoad(this.__LGEOMUTIL).then((function(){return i.lazyLoad(i.__LALMOSTOVER)})).then((function(){t.addHandler("almostOver",L.Handler.AlmostOver),L.GeometryUtil&&t.almostOver&&t.almostOver.enabled()&&(t.almostOver.addLayer(e),t.on("almost:move",(function(t){return i._mousemoveLayerHandler(t)})).on("almost:out",(function(t){return i._mouseoutHandler(t)})))}))},_initDistanceMarkers:function(t,e){var i=this;t&&(this.options.distanceMarkers?this.lazyLoad(this.__LGEOMUTIL).then((function(){return i.lazyLoad(i.__LDISTANCEM)})).then((function(){return i.options.polyline&&e.addTo(t)})):this.options.polyline&&e.addTo(t))},_initElevationDiv:function(){var t=y(this.options.elevationDiv);return t||(this.options.elevationDiv="#elevation-div_"+w(),t=m("div","leaflet-control elevation elevation-div",{id:this.options.elevationDiv.substr(1)})),this.options.detached&&d(t,"leaflet-control","elevation-detached"),this.eleDiv=t},_collapse:function(){d(this._container,"elevation-expanded","elevation-collapsed")},_expand:function(){d(this._container,"elevation-collapsed","elevation-expanded")},_fixCanvasPaths:function(){var t=L.Canvas.prototype._fillStroke,e=this;L.Canvas.include({_fillStroke:function(i,a){if(e._layers.hasLayer(a)){var n=e.options.theme.replace("-theme",""),r=S[n]||{},o=a.options;if(o.color=r.line||r.area||n,o.stroke=!!o.color,t.call(this,i,a),o.stroke&&0!==o.weight){var s=i.globalCompositeOperation||"source-over";i.globalCompositeOperation="destination-over",i.strokeStyle=r.outline||"#FFF",i.lineWidth=1.75*o.weight,i.stroke(),i.globalCompositeOperation=s}}else t.call(this,i,a)}})},_fixTooltipSize:function(){var t=this;this.on("elechart_init",(function(){return t.once("elechart_change elechart_hover",(function(e){t._chartEnabled&&(t._chart._showDiagramIndicator(e.data,e.xCoord),t._chart._showDiagramIndicator(e.data,e.xCoord)),t._updateMarker(e.data)}))}))},_findItemForLatLng:function(t){return this._data[this._chart._findIndexForLatLng(t)]},_findItemForX:function(t){return this._data[this._chart._findIndexForXCoord(t)]},_fireEvt:function(t,e,i){this.fire&&this.fire(t,e,i),this._map&&this._map.fire(t,e,i)},_height:function(){if(this._chart)return this._chart._height();var t=this.options;return t.height-t.margins.top-t.margins.bottom},_hideMarker:function(){this.options.autohideMarker&&this._marker.remove()},_initChart:function(t){var e=this.options;if(e.xTicks=this._xTicks(),e.yTicks=this._yTicks(),e.detached){var i=this.eleDiv,a=i.offsetWidth,n=i.offsetHeight;a>0&&(e.width=a),n>20&&(e.height=n-20)}else{var r=this._map.getContainer().clientWidth;e._maxWidth=e._maxWidth>e.width?e._maxWidth:e.width,this._container.style.maxWidth=e._maxWidth+"px",e._maxWidth>r&&(e.width=r-30)}var o=this._chart=new U(e,this);this._x=this._chart._x,this._y=this._chart._y,d3.select(t).call(o.render()),o.on("reset_drag",this._hideMarker,this).on("mouse_enter",this._fireEvt.bind("elechart_enter"),this).on("dragged",this._dragendHandler,this).on("mouse_move",this._mousemoveHandler,this).on("mouse_out",this._mouseoutHandler,this).on("ruler_filter",this._rulerFilterHandler,this).on("zoom",this._updateChart,this).on("elepath_toggle",this._toggleChartHandler,this).on("margins_updated",this._resizeChart,this),this._fireEvt("elechart_axis"),this.options.legend&&this._fireEvt("elechart_legend"),this._fireEvt("elechart_init")},_initLayer:function(){var t=this;this._layers.on("layeradd layerremove",(function(e){var i=e.layer;c(i.getElement&&i.getElement(),t.options.polyline.className+" "+t.options.theme,"layeradd"==e.type),p(i,"mousemove",t._mousemoveLayerHandler.bind(t),"layeradd"==e.type),p(i,"mouseout",t._mouseoutHandler.bind(t),"layeradd"==e.type)}))},_initMarker:function(t){var e=t.getPane("elevationPane");e||((e=this._pane=t.createPane("elevationPane",t.getPane("norotatePane")||t.getPane("mapPane"))).style.zIndex=625,e.style.pointerEvents="none"),this._renderer&&this._renderer.remove(),this._renderer=L.svg({pane:"elevationPane"}).addTo(this._map),this._marker=new V(this.options),this._fireEvt("elechart_marker")},_initButton:function(t){if(!L.Browser.mobile&&this.options.detached||L.DomEvent.disableClickPropagation(t).disableScrollPropagation(t),!this.options.detached){var e=this._button=m("a","elevation-toggle elevation-toggle-icon"+(this.options.autohide?"":" close-button"),{href:"#",title:L._("Elevation")},t);this.options.collapsed&&(this._collapse(),this.options.autohide?(x(t,"mouseover",this._expand,this),x(t,"mouseout",this._collapse,this)):(x(e,"click",L.DomEvent.stop),x(e,"click",this._toggle,this)),x(e,"focus",this._toggle,this),this._map.on("click",this._collapse,this))}},_initSummary:function(t){this._summary=new Y({summary:this.options.summary},this),d3.select(t).call(this._summary.render())},_keydownHandler:function(t){this.options.detached||"Escape"!==t.key||this._collapse()},_loadFile:function(t){var e=this;fetch(t).then((function(t){return t.text()})).then((function(i){e._downloadURL=t,e._parseFromString(i).then((function(t){return t&&e._loadLayer(t)}))})).catch((function(t){return console.warn(t)}))},_loadLayer:function(t){var e=this,i=e.options,a=i.wptIcons,n=i.wptLabels,r=L.geoJson(t,{distanceMarkers:e.options.distanceMarkers,style:function(t){var i=L.extend({},e.options.polyline);return e.options.theme&&(i.className+=" "+e.options.theme),i},pointToLayer:function(t,i){var r,o,s;if(e.options.waypoints){var l=t.properties,h=null!==(r=l.desc)&&void 0!==r?r:"",c=null!==(o=l.name)&&void 0!==o?o:"",d=(null!==(s=l.sym)&&void 0!==s?s:c).replace(" ","-").replace('"',"").replace("'","").toLowerCase();if([!0,"dots"].includes(e.options.waypoints)&&e._registerCheckPoint({latlng:i,label:[!0,"dots"].includes(n)?c:""}),[!0,"markers"].includes(e.options.waypoints)&&0!=a){a.hasOwnProperty(d)||(a[d]=L.divIcon(L.extend({},a[""].options,{html:'<i class="elevation-waypoint-icon '+d+'"></i>'})));var u=L.marker(i,{icon:a[d]});return[!0,"markers"].includes(n)&&(c||h)&&u.bindPopup("<b>"+c+"</b>"+(h.length>0?"<br>"+h:"")).openPopup(),e._addMarker(u),e._bindPopup(u),e.fire("waypoint_added",{point:u,element:i,properties:l}),u}}},onEachFeature:function(i,a){i.geometry&&"Point"==i.geometry.type||(a._latlngs.forEach((function(t,e){if(t.meta={time:null,ele:null,hr:null,cad:null,atemp:null},"alt"in t&&(t.meta.ele=t.alt),i.properties){var a=i.properties;"coordTimes"in a?t.meta.time=new Date(Date.parse(a.coordTimes[e])):"times"in a?t.meta.time=new Date(Date.parse(a.times[e])):"time"in a&&(t.meta.time=new Date(Date.parse("object"===R(a.time)?a.time[e]:a.time))),"heartRates"in a?t.meta.hr=parseInt(a.heartRates[e]):"heartRate"in a&&(t.meta.hr=parseInt("object"===R(a.heartRate)?a.heartRate[e]:a.heartRate))}})),e.addData(a),e.track_info=L.extend({},e.track_info,{name:t.name}))}});return e.lazyLoad(e.__D3).then((function(){var i=e._map;i?(i.once("layeradd",(function(t){return e.options.autofitBounds&&e.fitBounds(r.getBounds())})),L.Browser.mobile?e.options.polyline&&r.addTo(i):(e._initAlmostOverHandler(i,r),e._initDistanceMarkers(i,r))):console.warn("Undefined elevation map object"),e._fireEvt("eledata_loaded",{data:t,layer:r,name:e.track_info.name,track_info:e.track_info})})),r},_dragendHandler:function(t){this._hideMarker(),this.fitBounds(L.latLngBounds([t.dragstart.latlng,t.dragend.latlng])),this._fireEvt("elechart_dragged")},_mousemoveHandler:function(t){if(this._data.length&&this._chartEnabled){var e=this._findItemForX(t.xCoord);if(e){var i=t.xCoord;this._chartEnabled&&this._chart._showDiagramIndicator(e,i),this._updateMarker(e),this._setMapView(e),this._map&&l(this._map.getContainer(),"elechart-hover"),this._fireEvt("elechart_change",{data:e,xCoord:i}),this._fireEvt("elechart_hover",{data:e,xCoord:i})}}},_mousemoveLayerHandler:function(t){if(this._data.length){var e=this._findItemForLatLng(t.latlng);if(e){var i=e.xDiagCoord;this._chartEnabled&&this._chart._showDiagramIndicator(e,i),this._updateMarker(e),this._fireEvt("elechart_change",{data:e,xCoord:i})}}},_mouseoutHandler:function(){this.options.detached||(this._hideMarker(),this._chart._hideDiagramIndicator()),this._map&&h(this._map.getContainer(),"elechart-hover"),this._fireEvt("elechart_leave")},_parseFromGeoJSONString:function(t){try{return JSON.parse(t)}catch(t){}},_parseFromString:function(t){var e=this;return new Promise((function(i){return e.lazyLoad(e.__TOGEOJSON).then((function(){var a;try{a=e._parseFromXMLString(t.trim())}catch(i){a=e._parseFromGeoJSONString(t.toString())}a&&(a=e._prepareMultiLineStrings(a),a=e._prepareAdditionalProperties(a)),i(a)}))}))},_parseFromXMLString:function(t){var e;if(0!=t.indexOf("<"))throw"Invalid XML";var i=(new DOMParser).parseFromString(t,"text/xml"),a=i.documentElement.tagName.toLowerCase(),n=i.getElementsByTagName("name");if(i.getElementsByTagName("parsererror").length)throw"Invalid XML";a in toGeoJSON||(a="TrainingCenterDatabase"==i.documentElement.tagName?"tcx":"gpx");var r=toGeoJSON[a](i);return r.name=n.length>0?(null!==(e=Array.from(n).find((function(t){return"trk"==t.parentElement.tagName})))&&void 0!==e?e:n[0]).textContent:"",r},_prepareAdditionalProperties:function(t){return!t.name&&this._downloadURL&&(t.name=this._downloadURL.split("/").pop().split("#")[0].split("?")[0]),t},_prepareMultiLineStrings:function(t){return t.features.forEach((function(e){"MultiLineString"==e.geometry.type&&e.geometry.coordinates.forEach((function(i){t.features.push({geometry:{type:"LineString",coordinates:i},properties:e.properties,type:"Feature"})}))})),t.features.filter((function(t){return"MultiLineString"!=t.geometry.type}))},_registerCheckPoint:function(t){var e=this;this.on("elechart_updated",(function(){return e._chart._registerCheckPoint(t)}))},_registerAreaPath:function(t){var e=this;this.on("elechart_init",(function(){return e._chart._registerAreaPath(t)}))},_registerAxisGrid:function(t){var e=this;this.on("elechart_axis",(function(){return e._chart._registerAxisGrid(t)}))},_registerAxisScale:function(t){var e=this;this.on("elechart_axis",(function(){return e._chart._registerAxisScale(t)}))},_registerTooltip:function(t){var e=this;if(t.chart){var i=L.extend({},t,{value:t.chart});this.on("elechart_init",(function(){return e._chart._registerTooltip(i)}))}if(t.marker){var a=L.extend({},t,{value:t.marker});this.on("elechart_marker",(function(){return e._marker._registerTooltip(a)}))}},_registerSummary:function(t){var e=this;this.on("elechart_summary",(function(){return e._summary._registerSummary(t)}))},_resetDrag:function(){this._chart._resetDrag(),this._hideMarker()},_resetView:function(){this._map&&this._map._isFullscreen||(this._resetDrag(),this._hideMarker(),this.options.autofitBounds&&this.fitBounds())},_resizeChart:function(){if(this._container&&"none"!=u(this._container,"display")){var t,e=this.options;if(e.detached)t=(this.eleDiv||this._container).offsetWidth;else{var i=this._map.getContainer().clientWidth;t=e._maxWidth>i?i-30:e._maxWidth}if(t){var a=this._chart;e.width=t,a&&a._chart&&(a._chart._resize(e),e.xTicks=this._xTicks(),e.yTicks=this._yTicks(),this._updateChart())}this._updateMapSegments()}},_rulerFilterHandler:function(t){this._updateMapSegments(t.coords)},_toggle:function(){k(this._container,"elevation-expanded")?this._collapse():this._expand()},_setMapView:function(t){if(this.options.followMarker&&this._map){var e=this._map.getZoom(),i=this.options.zFollow;"number"==typeof i?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})}},_toggleChartHandler:function(t){var e=this,i=(t.path,t.name),a=t.enabled;this._chartEnabled=this._chart._hasActiveLayers(),this._layers.eachLayer((function(t){c(t.getElement&&t.getElement(),e.options.polyline.className+" "+e.options.theme,e._chartEnabled)})),this.options[i]=a||"disabled"!=this.options[i]?"disabled":"enabled",this._chartEnabled||(this._chart._hideDiagramIndicator(),this._marker.remove())},_updateChart:function(){
|
|
1
|
+
!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";!function(t,e){"function"==typeof define&&define.amd?define(["leaflet"],t):"object"==typeof exports&&(module.exports=t(require("leaflet"))),void 0!==e&&e.L&&t(e.L)}((function(t){return t.locales={},t.locale=null,t.registerLocale=function(e,i){t.locales[e]=t.Util.extend({},t.locales[e],i)},t.setLocale=function(e){t.locale=e},t.i18n=t._=function(e,i){t.locale&&t.locales[t.locale]&&t.locales[t.locale][e]&&(e=t.locales[t.locale][e]);try{e=t.Util.template(e,i)}catch(t){}return e}}),window);var t=6e4,e=60*t,i=24*e;function a(a){var n=Math.floor(a/i),r=Math.floor((a-n*i)/e),o=Math.floor((a-n*i-r*e)/t),s=Math.round((a-n*i-r*e-o*t)/1e3);return 60===s&&(o++,s=0),60===o&&(r++,o=0),24===r&&(n++,r=0),(n?n+"d ":"")+r.toString().padStart(2,0)+":"+o.toString().padStart(2,0)+"'"+s.toString().padStart(2,0)+'"'}function n(t,e){var i=m("a","",{href:t,target:"_new",download:e||"",style:"display:none;"}),a=document.body;a.appendChild(i),i.click(),a.removeChild(i)}function r(t,e,i){return!1===e?Promise.resolve():i instanceof Promise?i:new Promise((function(e,i){var a=document.createElement("script");a.addEventListener("load",e,{once:!0}),a.src=t,document.head.appendChild(a)}))}function o(t,e){e.classed("canvas-path",!0),t.beginPath(),t.moveTo(0,0);var i=new Path2D(e.attr("d"));t.strokeStyle=e.attr("stroke"),t.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 s(t,e){return e?t<e[0]?e[0]:t>e[1]?e[1]:t:t}function l(t,e){t&&e.split(" ").every((function(e){return e&&L.DomUtil.addClass(t,e)}))}function h(t,e){t&&e.split(" ").every((function(e){return e&&L.DomUtil.removeClass(t,e)}))}function c(t,e,i){return(i?l:h).call(null,t,e)}function d(t,e,i){e&&h(t,e),i&&l(t,i)}function u(t,e,i){return void 0===i?L.DomUtil.getStyle(t,e):t.style.setProperty(e,i)}function _(t,e,i,a){return u(t,e,a?i:"")}function p(t,e,i,a){return t[a?"on":"off"](e,i)}function m(t,e,i,a){var n=L.DomUtil.create(t,e||"");return i&&v(n,i),a&&f(a,n),n}function f(t,e){return t.appendChild(e)}function g(t,e,i){return t.insertAdjacentElement(i,e)}function v(t,e){for(var i in e)t.setAttribute(i,e[i])}function y(t,e){return(e||document).querySelector(t)}var x=L.DomEvent.on,b=L.DomEvent.off,k=L.DomUtil.hasClass;function w(){return Math.random().toString(36).substr(2,9)}function C(t,e){for(var i in t)e(t[i],i)}var M=Object.freeze({__proto__:null,formatTime:a,saveFile:n,lazyLoader:r,drawCanvas:o,clamp:s,addClass:l,removeClass:h,toggleClass:c,replaceClass:d,style:u,toggleStyle:_,toggleEvent:p,create:m,append:f,insert:g,setAttributes:v,select:y,on:x,off:b,hasClass:k,randomId:w,each:C}),S={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"}},A=function(t){t.width;var e=t.height,i=t.xAttr,a=t.yAttr,n=t.scaleX,r=t.scaleY,o=t.interpolation,s=void 0===o?"curveLinear":o;return d3.area().curve("string"==typeof s?d3[s]:s).x((function(t){return t.xDiagCoord=n(t[i])})).y0(e).y1((function(t){return r(t[a])}))},z=function(t){var e=t.name,i=t.color,a=t.strokeColor,n=t.strokeOpacity,r=t.fillOpacity,o=d3.create("svg:path");return e&&o.classed(e,!0),o.style("pointer-events","none"),o.attr("fill",i||"#3366CC").attr("stroke",a||"#000").attr("stroke-opacity",n||"1").attr("fill-opacity",r||"0.8"),o},E=function(t){var e=t.type,i=void 0===e?"axis":e,a=t.tickSize,n=void 0===a?6:a,r=t.tickPadding,o=void 0===r?3:r,s=t.position,l=t.height,h=t.width,c=t.axis,d=t.scale,u=t.ticks,_=t.tickFormat,p=t.label,m=t.labelX,f=t.labelY,g=t.name,v=void 0===g?"":g,y=t.onAxisMount;return function(t){var e=0,a=0;"bottom"==s&&(a=l),"right"==s&&(e=h),"x"==c&&"grid"==i?n=-l:"y"==c&&"grid"==i&&(n=-h);var r=d3["axis"+s.replace(/\b\w/g,(function(t){return t.toUpperCase()}))]().scale(d).ticks(u).tickPadding(o).tickSize(n).tickFormat(_),g=t.append("g").attr("class",[c,i,s,v].join(" ")).attr("transform","translate("+e+","+a+")").call(r);return p&&g.append("svg:text").attr("x",m).attr("y",f).text(p),y&&g.call(y),g}},F=function(t){return t.type="grid",E(t)},D=function(t){var e=t.theme,i=t.xCoord,a=void 0===i?0:i,n=t.yCoord,r=void 0===n?0:n,o=t.labels,s=void 0===o?{}:o,l=t.item,h=void 0===l?{}:l,c=t.length,d=void 0===c?0:c;return function(t){var i,n=t.select(".height-focus.line"),o=t.select(".height-focus.circle-lower"),l=t.select(".height-focus-label");if(n.node()||(n=t.append("svg:line")),o.node()||(o=t.append("svg:circle")),l.node()||(l=t.append("svg:text")),isNaN(a)||isNaN(r))return t;for(var c in o.attr("class",e+" height-focus circle-lower").attr("transform","translate("+a+","+r+")").attr("r",6).attr("cx",0).attr("cy",0),n.attr("class",e+" height-focus line").attr("x1",a).attr("x2",a).attr("y1",r).attr("y2",d),l.attr("class",e+" height-focus-label").style("pointer-events","none").attr("x",a+5).attr("y",d),s)(i=l.select(".height-focus-"+s[c].name)).size()||(i=l.append("svg:tspan").attr("class","height-focus-"+s[c].name).attr("dy","1.5em")),i.text("function"!=typeof s[c].value?s[c].value:s[c].value(h));return l.select("tspan").attr("dy",l.selectAll("tspan").size()>1?"-1.5em":"0em"),l.selectAll("tspan").attr("x",a+5),t}},T=function(t){var e=t.name,i=t.label,a=t.width,n=t.height,r=t.margins,o=void 0===r?{}:r,s=t.color,l=t.path;return function(t){return t.attr("class","legend-item legend-"+e.toLowerCase()).attr("data-name",e),t.on("click.legend",(function(){return d3.select(t.node().ownerSVGElement||t).dispatch("legend_clicked",{detail:{path:l.node(),name:e,legend:t.node(),enabled:!l.classed("leaflet-hidden")}})})),t.append("svg:rect").attr("x",a/2-50).attr("y",n+o.bottom/2).attr("width",50).attr("height",10).attr("fill",s).attr("stroke","#000").attr("stroke-opacity","0.5").attr("fill-opacity","0.25"),t.append("svg:text").text(L._(i||e)).attr("x",a/2+5).attr("font-size",10).style("text-decoration-thickness","2px").style("font-weight","700").attr("y",n+o.bottom/2).attr("dy","0.75em"),t}},I=function(t){var e=t.xCoord,i=t.yCoord,a=t.width,n=t.height,r=t.labels,o=void 0===r?{}:r,s=t.item,l=void 0===s?{}:s;return function(t){var r=t.select(".mouse-focus-line"),s=t.select(".mouse-focus-label");r.node()||(r=t.append("svg:line")),s.node()||(s=t.append("g"));var h=s.select(".mouse-focus-label-rect"),c=s.select(".mouse-focus-label-text");h.node()||(h=s.append("svg:rect")),c.node()||(c=s.append("svg:text"));var d,u=0,_=0,p={width:0,height:0};try{p=c.node().getBBox()}catch(e){return t}for(var m in e&&(u=e+(e<a/2?10:-p.width-10)),i&&(_=Math.max(i-p.height,L.Browser.webkit?0:-1/0)),r.attr("class","mouse-focus-line").attr("x2",e).attr("y2",0).attr("x1",e).attr("y1",n),s.attr("class","mouse-focus-label"),h.attr("class","mouse-focus-label-rect").attr("x",u-5).attr("y",_-5).attr("width",p.width+10).attr("height",p.height+10).attr("rx",3).attr("ry",3),c.attr("class","mouse-focus-label-text").style("font-weight","700").attr("y",_),o)(d=c.select(".mouse-focus-label-"+o[m].name)).size()||(d=c.append("svg:tspan",".mouse-focus-label-x").attr("class","mouse-focus-label-"+o[m].name).attr("dy","1.5em")),d.text("function"!=typeof o[m].value?o[m].value:o[m].value(l));return c.select("tspan").attr("dy","1em"),c.selectAll("tspan").attr("x",u),t}},P=function(t){var e=t.height,i=t.width;return function(t){t.data([{x:0,y:e}]).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"}));var a=t.selectAll(".horizontal-drag-rect").data([{w:i}]),n=t.selectAll(".horizontal-drag-line").data([{w:i}]),r=t.selectAll(".horizontal-drag-label").data([{w:i-8}]),o=t.selectAll(".horizontal-drag-symbol").data([{type:d3.symbolTriangle,x:i+7,y:0,angle:-90,size:50}]);return a.exit().remove(),n.exit().remove(),r.exit().remove(),o.exit().remove(),a.enter().append("svg:rect").attr("class","horizontal-drag-rect").attr("x",0).attr("y",-8).attr("height",8).attr("fill","none").attr("pointer-events","all").merge(a).attr("width",(function(t){return t.w})),n.enter().append("svg:line").attr("class","horizontal-drag-line").attr("x1",0).merge(n).attr("x2",(function(t){return t.w})),r.enter().append("svg:text").attr("class","horizontal-drag-label").attr("text-anchor","end").attr("y",-8).merge(r).attr("x",(function(t){return t.w})),o.enter().append("svg:path").attr("class","horizontal-drag-symbol").merge(o).attr("d",d3.symbol().type((function(t){return t.type})).size((function(t){return t.size}))).attr("transform",(function(t){return"translate("+t.x+","+t.y+") rotate("+t.angle+")"})),t}},O=function(t){var e=t.point,i=t.height,a=t.width,n=t.x,r=t.y;return function(t){return isNaN(n)||isNaN(r)||(e.item&&e.item.property("isConnected")||(e.position=e.position||"bottom",e.item=t.append("g"),e.item.append("svg:line").attr("y1",0).attr("x1",0).attr("style","stroke: rgb(51, 51, 51); stroke-width: 0.5; stroke-dasharray: 2, 2;"),e.item.append("svg:circle").attr("class"," height-focus circle-lower").attr("r",3),e.label&&e.item.append("svg:text").attr("dx","4px").attr("dy","-4px")),e.item.datum({pos:e.position,x:n,y:r}).attr("class",(function(t){return"point "+t.pos})).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"})),e.item.select("line").datum({y2:{top:-r,bottom:i-r}[e.position],x2:{left:-n,right:a-n}[e.position]||0}).attr("y2",(function(t){return t.y2})).attr("x2",(function(t){return t.x2})),e.label&&e.item.select("text").text(e.label)),t}},N=function(t){var e=t.min,i=t.max,a=t.attr,n=t.name,r=t.forceBounds,o=t.scale;return function(t){a=a||n,o&&o.attr&&(a=o.attr);var s=t&&t.length?d3.extent(t,(function(t){return t[a]})):[0,1];return void 0!==e&&(e<s[0]||r)&&(s[0]=e),void 0!==i&&(i>s[1]||r)&&(s[1]=i),s}},B=function(t){var e=t.axis;return function(t,i){return"x"==e?[0,t]:"y"==e?[i,0]:void 0}},G=function(t){var e=t.data,i=t.attr,a=t.min,n=t.max,r=t.forceBounds,o=t.range;return d3.scaleLinear().range(o).domain(N({min:a,max:n,attr:i,forceBounds:r})(e))},H=function(t){var e=t.width,i=t.height,a=t.margins,n=void 0===a?{}:a,r=(t.ruler,e-n.left-n.right),o=i-n.top-n.bottom,s=d3.create("svg:svg").attr("class","background"),l=s.append("g"),h={grid:l.append("g").attr("class","grid"),area:l.append("g").attr("class","area"),axis:l.append("g").attr("class","axis"),point:l.append("g").attr("class","point"),brush:l.append("g").attr("class","brush"),tooltip:l.append("g").attr("class","tooltip").attr("display","none"),ruler:l.append("g").attr("class","ruler"),legend:l.append("g").attr("class","legend")},c=h.area.append("svg:mask").attr("id","elevation-clipper").attr("fill-opacity",1),d=c.append("svg:rect").attr("class","zoom").attr("fill","white"),u=h.area.append("svg:foreignObject").attr("mask","url(#"+c.attr("id")+")"),_=u.append("xhtml:canvas").attr("class","canvas-plot"),p=_.node().getContext("2d");h.tooltip.call(I({xCoord:0,yCoord:0,height:o,width:r,labels:{}}));var m=d3.brushX().on("start.cursor end.cursor brush.cursor",(function(){return h.brush.select(".overlay").attr("cursor",null)})),f={mask:c,canvas:_,context:p,brush:m},g={svg:s,g:l,panes:h,utils:f,scale:function(t){return{x:G(t.x),y:G(t.y)}},_resize:function(t){var e=t.width,i=t.height,a=t.margins,n=void 0===a?{}:a,r=t.ruler,o=e-n.left-n.right,c=i-n.top-n.bottom;s.attr("viewBox","0 0 ".concat(e," ").concat(i)).attr("width",e).attr("height",i),l.attr("transform","translate("+n.left+","+n.top+")"),/Mac|iPod|iPhone|iPad/.test(navigator.platform)&&/AppleWebkit/i.test(navigator.userAgent)&&_.style("transform","translate("+n.left+"px,"+n.top+"px)"),d.attr("x",0).attr("y",0).attr("width",o).attr("height",c),u.attr("width",o).attr("height",c),_.attr("width",o).attr("height",c),r&&h.ruler.call(P({height:c,width:o})),h.brush.call(m.extent([[0,0],[o,c]])),h.brush.select(".overlay").attr("cursor",null),g._width=o,g._height=c,g.svg.dispatch("resize",{detail:{width:o,height:c}})},pane:function(t){return h[t]||(h[t]=l.append("g").attr("class",t)),h[t]},get:function(t){return f[t]}};return g._resize({width:e,height:i,margins:n}),g},X=Object.freeze({__proto__:null,Colors:S,Area:A,Path:z,Axis:E,Grid:F,PositionMarker:D,LegendItem:T,Tooltip:I,Ruler:P,CheckPoint:O,Domain:N,Range:B,Scale:G,Bisect:function(t){var e=t.data,i=void 0===e?[0,1]:e,a=t.scale,n=t.x,r=t.attr;return d3.bisector((function(t){return t[r]})).left(i,a.invert(n))},Chart:H}),U=L.Class.extend({includes:L.Evented?L.Evented.prototype:L.Mixin.Events,initialize:function(t,e){var i=this;this.options=t,this.control=e,this._data=[],this._props={scales:{},paths:{},areas:{},grids:{},axes:{},legendItems:{},tooltipItems:{}},this._scales={},this._domains={},this._ranges={},this._paths={},this._brushEnabled=t.dragging,this._zoomEnabled=t.zooming;var a=this._chart=H(t);this._container=a.svg;this._grid=a.pane("grid"),this._area=a.pane("area"),this._point=a.pane("point"),this._axis=a.pane("axis"),this._legend=a.pane("legend"),this._tooltip=a.pane("tooltip"),this._ruler=a.pane("ruler"),this._initScale(),this._mask=a.get("mask"),this._context=a.get("context"),this._brush=a.get("brush"),this._zoom=d3.zoom(),this._drag=d3.drag(),this._initInteractions(),this._maskGaps=[],e.on("eletrack_added",(function(t){i._maskGaps.push(t.index),e.once("eledata_updated",(function(t){return i._maskGaps.push(t.index)}))}))},update:function(t){return t&&(t.data&&(this._data=t.data),t.options&&(this.options=t.options)),this._updateScale(),this._updateArea(),this._updateAxis(),this._updateLegend(),this._updateClipper(),this},render:function(){var t=this;return function(e){return e.append((function(){return t._container.node()}))}},clear:function(){this._resetDrag(),this._hideDiagramIndicator(),this._area.selectAll("path").attr("d","M0 0"),this._context.clearRect(0,0,this._width(),this._height()),this._maskGaps=[],this._mask.selectAll(".gap").remove()},_drawPath:function(t){var e=this._paths[t],i=this._props.areas[t];e.datum(this._data).attr("d",A(L.extend({},i,{width:this._width(),height:this._height(),scaleX:this._scales[i.scaleX],scaleY:this._scales[i.scaleY]}))),e.classed("leaflet-hidden")||(this.options.preferCanvas?o(this._context,e):this._area.append((function(){return e.node()})))},_hasActiveLayers:function(){var t=this._paths;for(var e in t)if(!t[e].classed("leaflet-hidden"))return!0;return!1},_initBrush:function(t){var e=this,i=function(t){if(e._data.length&&("brush"!=t.type||t.sourceEvent)){var i=e._chart.panes.brush.select(".overlay").node(),a=d3.pointers(t,i)[0][0],n=e._data[e._findIndexForXCoord(a)];e.fire("mouse_move",{item:n,xCoord:a})}};this._brush.filter((function(t){return e._brushEnabled&&!t.shiftKey&&!t.button})).on("end.update",(function(t){if(e._data.length){var i=t.selection;if(i){var a=e._findIndexForXCoord(i[0]),n=e._findIndexForXCoord(i[1]);e.fire("dragged",{dragstart:e._data[a],dragend:e._data[n]})}}})).on("brush.update",i),this._chart.panes.brush.on("mouseenter.focus touchstart.focus",this.fire.bind(this,"mouse_enter")).on("mouseout.focus touchend.focus",this.fire.bind(this,"mouse_out")).on("mousemove.focus touchmove.focus",i)},_initClipper:function(){var t=this,e=this._container,i=this.options.margins,a=this._zoom;a.scaleExtent([1,10]).extent([[i.left,0],[this._width()-i.right,this._height()]]).translateExtent([[i.left,-1/0],[this._width()-i.right,1/0]]).filter((function(e){return t._zoomEnabled&&(e.shiftKey||4==e.buttons)})).on("start",(function(i){i.sourceEvent&&"mousedown"==i.sourceEvent.type&&e.style("cursor","grabbing"),1==i.transform.k&&0==i.transform.x&&(t._container.classed("zoomed",!0),t._mask&&t._point.attr("mask","url(#"+t._mask.attr("id")+")")),t.zooming=!0})).on("end",(function(i){1==i.transform.k&&0==i.transform.x&&(t._container.classed("zoomed",!1),t._mask&&t._point.attr("mask",null)),t.zooming=!1,e.style("cursor","")})).on("zoom",(function(e){t.zooming=!1,t._updateScale(),t.zooming=!0,t._scales.distance=t._x=e.transform.rescaleX(t._x),t._scales.time&&(t._scales.time=e.transform.rescaleX(t._scales.time)),t._resetDrag(),e.sourceEvent&&"mousemove"==e.sourceEvent.type&&t._hideDiagramIndicator(),t.fire("zoom")})),e.call(a)},_initInteractions:function(){this._initBrush(),this._initRuler(),this._initClipper(),this._initLegend()},_initLegend:function(){var t=this;this._container.on("legend_clicked",(function(e){var i=e.detail,a=i.path,n=i.legend,r=i.name,o=i.enabled;if(a){var s=y("text",n),l=y("rect",n);_(s,"text-decoration-line","line-through",o),_(l,"fill-opacity","0",o),c(a,"leaflet-hidden",o),t._updateArea(),t.fire("elepath_toggle",{path:a,name:r,legend:n,enabled:o})}}))},_initRuler:function(){var t=this;if(this.options.ruler){var e=d3.format(".0f"),i=this._drag;i.on("start end",(function(e,i){var a=t._height(),n=t._ruler.data()[0].y;(n>=a||n<=0)&&t._ruler.select(".horizontal-drag-label").text(""),t._hideDiagramIndicator()})).on("drag",(function(i,a){var n=t._height(),r=d3.pointers(i,t._area.node())[0][1],o=r>0?r<n?r:n:0,s=t._y.invert(o),l=L.extend(t._ruler.data()[0],{y:o});t._ruler.data([l]).attr("transform",(function(t){return"translate("+t.x+","+t.y+")"})).classed("active",o<n),t._container.select(".horizontal-drag-label").text(e(s)+" "+(t.options.imperial?"ft":"m")),t.fire("ruler_filter",{coords:r<n&&r>0?t._findCoordsForY(r):[]})})),this._ruler.call(i)}},_initScale:function(){var t=this.options;this._registerAxisScale({axis:"x",position:"bottom",attr:t.xAttr,min:t.xAxisMin,max:t.xAxisMax,name:"distance"}),this._registerAxisScale({axis:"y",position:"left",attr:t.yAttr,min:t.yAxisMin,max:t.yAxisMax,name:"altitude"}),this._x=this._scales.distance,this._y=this._scales.altitude},_registerAreaPath:function(t){var e=this.options;t.xAttr||(t.xAttr=e.xAttr),t.yAttr||(t.yAttr=e.yAttr),void 0===t.preferCanvas&&(t.preferCanvas=e.preferCanvas);var i=z(t);this._paths[t.name]=i,this._props.areas[t.name]=t,e.legend&&(this._props.legendItems[t.name]={name:t.name,label:t.label,color:t.color,path:i})},_registerAxisGrid:function(t){this._props.grids[t.name||t.axis]=t},_registerAxisScale:function(t){var e=this.options,i=t.scale;if("function"==typeof this._scales[t.name])t.scale=this._scales[t.name];else if("function"!=typeof i){(i=L.extend({data:this._data,forceBounds:e.forceAxisBounds},i)).attr=i.attr||t.name;var a=this._domains[t.name]=N(t),n=this._ranges[t.name]=B(t);i.range=i.range||n(this._width(),this._height()),i.domain=i.domain||a(this._data),this._props.scales[t.name]=i,t.scale=this._scales[t.name]=G(i)}return t.ticks||("x"==t.axis?t.ticks=e.xTicks:"y"==t.axis&&(t.ticks=e.yTicks)),this._props.axes[t.name]=t,i},_registerCheckPoint:function(t){var e,i,a;this._data.length&&(t.latlng?(e=this._data[this._findIndexForLatLng(t.latlng)],i=this._x(e.dist),a=this._y(e.z)):isNaN(t.dist)||(i=this._x(t.dist),e=this._data[this._findIndexForXCoord(i)],a=this._y(e.z)),this._point.call(O({point:t,width:this._width(),height:this._height(),x:i,y:a})))},_registerTooltip:function(t){this._props.tooltipItems[t.name]=t},_updateArea:function(){var t=this._paths;for(var e in this._context.clearRect(0,0,this._width(),this._height()),t)t[e].classed("leaflet-hidden")||this._drawPath(e)},_updateAxis:function(){var t=this.options;this._grid.selectAll("g").remove(),this._axis.selectAll("g").remove();var e,i,a,n=this._props.grids,r=this._props.axes,o={width:this._width(),height:this._height(),tickFormat:""},s={width:this._width(),height:this._height()};for(var l in n)e=L.extend({},o,n[l]),a=F(e),this._grid.call(a);for(var h in r)!1!==t[h]&&"summary"!==t[h]&&(e=L.extend({},s,r[h]),i=E(e),this._axis.call(i));this._axis.selectAll(".y.axis.right").each((function(t,e,i){var a=d3.select(i[e]),n=a.attr("transform"),r=n.substring(n.indexOf("(")+1,n.indexOf(")")).split(",");a.attr("transform","translate("+(+r[0]+40*e)+","+r[1]+")"),e>0&&(a.select(":scope > path").attr("opacity",.25),a.selectAll(":scope > .tick line").attr("opacity",.75))}))},_updateClipper:function(){var t=this,e=this.options.margins;this._zoom.scaleExtent([1,10]).extent([[e.left,0],[this._width()-e.right,this._height()]]).translateExtent([[e.left,-1/0],[this._width()-e.right,1/0]]),this._mask.selectAll(".gap").remove(),this._maskGaps.forEach((function(e,i){if(!(i>=t._maskGaps.length-2)){var a=t._data[t._maskGaps[i]],n=t._data[t._maskGaps[i+1]],r=t._x(t._data[t._findIndexForLatLng(a.latlng)].dist),o=t._x(t._data[t._findIndexForLatLng(n.latlng)].dist);t._mask.append("rect").attr("x",r).attr("y",0).attr("width",o-r).attr("height",t._height()).attr("class","gap").attr("fill-opacity","0.8").attr("fill","black")}}))},_updateLegend:function(){var t=this;if(!1!==this.options.legend){var e,i=this._props.legendItems;for(var a in this._legend.selectAll("g").remove(),i)e=T(L.extend({width:this._width(),height:this._height(),margins:this.options.margins},i[a])),this._legend.append("g").call(e);var n=this._legend.selectAll(".legend-item"),r=n.nodes().length,o=Array(Math.floor(r/2)).fill(null).map((function(t,e){return 2*(e+1)-(1-Math.sign(r%2))})),s=o.slice().reverse().map((function(t){return-t}));r%2!=0&&s.push(0),o=s.concat(o);var l=this._axis.selectAll(".x.axis.bottom").nodes().length,h=30+2*l,c=30*r;r&&this.options.margins.right<c&&(this.options.margins.right=c,this.fire("margins_updated")),l&&this.options.margins.bottom<h&&(this.options.margins.bottom=h,this.fire("margins_updated")),n.each((function(e,i,a){var n=d3.select(a[i]),r=(n.select("rect"),n.attr("data-name")),s=t._paths[r],h=55*o[i],c=2*l;n.attr("transform","translate("+h+", "+c+")"),r in t.options&&"disabled"==t.options[r]&&(s.classed("leaflet-hidden",!0),n.select("text").style("text-decoration-line","line-through"),n.select("rect").style("fill-opacity","0")),t._mask&&s.attr("mask","url(#"+t._mask.attr("id")+")")}))}},_updateScale:function(){if(this.zooming)return{x:this._x,y:this._y};for(var t in this._scales)this._scales[t].domain(this._domains[t](this._data)).range(this._ranges[t](this._width(),this._height()));return{x:this._x,y:this._y}},_width:function(){return this._chart._width},_height:function(){return this._chart._height},_findCoordsForY:function(t){var e,i=this._data,a=this._y.invert(t),n=i.reduce((function(t,e,i){return e.z>=a&&t.push(i),t}),[]),r=0;return n.reduce((function(t,a,o){return n[e=o+1]===n[o]+1&&e!==n.length||(t.push(n.slice(r,e).map((function(t){return i[t].latlng}))),r=e),t}),[])},_findIndexForXCoord:function(t){var e=this;return d3.bisector((function(t){return t[e.options.xAttr]})).left(this._data||[0,1],this._x.invert(t))},_findIndexForLatLng:function(t){var e=null,i=1/0;return this._data.forEach((function(a,n){var r=t.distanceTo(a.latlng);r<i&&(i=r,e=n)})),e},_resetDrag:function(){this._chart.panes.brush.select(".selection").attr("width")&&(this._chart.panes.brush.call(this._brush.clear),this._hideDiagramIndicator(),this.fire("reset_drag"))},_resetZoom:function(){this._zoom&&this._zoom.transform(this._chart.svg,d3.zoomIdentity)},_showDiagramIndicator:function(t,e){this._tooltip.attr("display",null).call(I({xCoord:e,yCoord:this._y(t[this.options.yAttr]),height:this._height(),width:this._width(),labels:this._props.tooltipItems,item:t}))},_hideDiagramIndicator:function(){this._tooltip.attr("display","none")}});function J(t){return(J="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var R,V=L.Class.extend({initialize:function(t){switch(this.options=t,this.options.marker){case"elevation-line":this._container=d3.select(map.getPane("elevationPane")).select("svg > g").attr("class","height-focus-group");break;case"position-marker":this._marker=L.marker([0,0],{icon:this.options.markerIcon,zIndexOffset:1e6,interactive:!1})}return this._labels={},this},addTo:function(t){switch(this._map=t,this.options.marker){case"elevation-line":this._container.call(D({}));break;case"position-marker":this._marker.addTo(t,{pane:"overlayPane"})}return this},update:function(t){if(t?this._props=t:t=this._props,t)switch(t.options&&(this.options=t.options),this._map||this.addTo(t.map),this._latlng=t.item.latlng,this.options.marker){case"elevation-line":var e=this._map.latLngToLayerPoint(this._latlng);e=L.extend({},t.item,this._map._rotate?this._map.rotatedPointToMapPanePoint(e):e),this._container.classed("leaflet-hidden",!1),this._container.call(D({theme:this.options.theme,xCoord:e.x,yCoord:e.y,length:e.y-this._height()/t.maxElevation*e.z,labels:this._labels,item:e}));break;case"position-marker":h(this._marker.getElement(),"leaflet-hidden"),this._marker.setLatLng(this._latlng)}},remove:function(){switch(this._props=null,this.options.marker){case"elevation-line":this._container&&this._container.classed("leaflet-hidden",!0);break;case"position-marker":l(this._marker.getElement(),"leaflet-hidden")}},getLatLng:function(){return this._latlng},_height:function(){var t=this.options;return t.height-t.margins.top-t.margins.bottom},_registerTooltip:function(t){this._labels[t.name]=t}}),Y=L.Class.extend({initialize:function(t,e){this.options=t,this.control=e,u(this._container=m("div","elevation-summary "+(t.summary?t.summary+"-summary":"")),"max-width",t.width?t.width+"px":"")},render:function(){var t=this;return function(e){return e.append((function(){return t._container}))}},reset:function(){this._container.innerHTML=""},append:function(t,e,i){return this._container.innerHTML+='<span class="'.concat(t,'"><span class="summarylabel">').concat(e,'</span><span class="summaryvalue">').concat(i,"</span></span>"),this},_registerSummary:function(t){for(var e in t)this.append(e,L._(t[e].label),"function"!=typeof t[e].value?t[e].value:t[e].value(this.control.track_info))}}),j={autofitBounds:!0,autohide:!L.Browser.mobile,autohideMarker:!0,almostover:!0,altitude:!0,collapsed:!1,detached:!0,distance:!0,distanceMarkers:!1,decimalsX:2,decimalsY:0,dragging:!L.Browser.mobile,downloadLink:"link",elevationDiv:"#elevation-div",followMarker:!0,forceAxisBounds:!1,height:200,imperial:!1,interpolation:"curveLinear",lazyLoadJS:!0,legend:!0,margins:{top:30,right:30,bottom:30,left:40},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,skipNullZCoords:!1,theme:"lightblue-theme",summary:"inline",slope:!1,speed:!1,sLimit:void 0,time:!1,timeFactor:3600,timeFormat:!1,timestamps:!1,sDeltaMax:void 0,sInterpolation:"curveStepAfter",sRange:void 0,width:600,waypoints:!0,wptIcons:{"":L.divIcon({className:"elevation-waypoint-marker",html:'<i class="elevation-waypoint-icon"></i>',iconSize:[30,30],iconAnchor:[8,30]})},wptLabels:!0,xAttr:"dist",xLabel:"km",xTicks:void 0,yAttr:"z",yAxisMax:void 0,yAxisMin:void 0,yLabel:"m",yTicks:void 0,zFollow:!1,zooming:!L.Browser.Mobile},W=L.Control.Elevation=L.Control.extend({includes:L.Evented?L.Evented.prototype:L.Mixin.Events,options:j,__mileFactor:.621371,__footFactor:3.28084,__D3:"https://unpkg.com/d3@6.5.0/dist/d3.min.js",__TOGEOJSON:"https://unpkg.com/@tmcw/togeojson@4.5.0/dist/togeojson.umd.js",__LGEOMUTIL:"https://unpkg.com/leaflet-geometryutil@0.9.3/src/leaflet.geometryutil.js",__LALMOSTOVER:"https://unpkg.com/leaflet-almostover@1.0.1/src/leaflet.almostover.js",__LDISTANCEM:"https://unpkg.com/@raruto/leaflet-elevation@1.8.9/libs/leaflet-distance-marker.min.js",addData:function(t,e){var i=this;this.lazyLoad(this.__D3).then((function(){void 0===e&&t.on&&(e=t),i._addData(t),i._addLayer(e),i._fireEvt("eledata_added",{data:t,layer:e,track_info:i.track_info})}))},addTo:function(t){if(this.options.detached){var e=this._initElevationDiv();e.isConnected||g(t.getContainer(),e,"afterend"),f(e,this.onAdd(t))}else L.Control.prototype.addTo.call(this,t);return this},clear:function(){this._marker&&this._marker.remove(),this._chart&&this._clearChart(),this._layers&&this._clearLayers(),this._markers&&this._clearMarkers(),this._data=[],this.track_info={},this._fireEvt("eledata_clear"),this._updateChart()},_clearChart:function(){var t=this;this._events&&this._events.elechart_updated&&this._events.elechart_updated.forEach((function(e){return t.off("elechart_updated",e.fn,e.ctx)})),this._chart&&this._chart._container&&(this._chart._container.selectAll("g.point .point").remove(),this._chart.clear())},_clearLayers:function(){this._layers&&this._layers.eachLayer&&(this._layers.eachLayer((function(t){return t.remove()})),this._layers.clearLayers())},_clearMarkers:function(){this._markers&&this._markers.eachLayer&&(this._markers.eachLayer((function(t){return t.remove()})),this._markers.clearLayers())},disableBrush:function(){this._chart._brushEnabled=!1,this._resetDrag()},enableBrush:function(){this._chart._brushEnabled=!0},disableZoom:function(){this._chart._zoomEnabled=!1,this._chart._resetZoom()},enableZoom:function(){this._chart._zoomEnabled=!0},fitBounds:function(t){t=t||this.getBounds(),this._map&&t.isValid()&&this._map.fitBounds(t)},getBounds:function(t){return t=t||this._data,L.latLngBounds(t.map((function(t){return t.latlng})))},getZFollow:function(){return this.options.zFollow},hide:function(){u(this._container,"display","none")},initialize:function(t){this._data=[],this._layers=L.featureGroup(),this._markers=L.featureGroup(),this._markedSegments=L.polyline([]),this._chartEnabled=!0,this.track_info={},L.setOptions(this,t),this.options.followMarker&&(this._setMapView=L.Util.throttle(this._setMapView,300,this)),this.options.legend&&(this.options.margins.bottom+=30),this.options.theme&&(this.options.polylineSegments.className+=" "+this.options.theme),!0===this.options.wptIcons&&(this.options.wptIcons=j.wptIcons),!0===this.options.distanceMarkers&&(this.options.distanceMarkers={lazy:!0}),this._markedSegments.setStyle(this.options.polylineSegments),L.extend(S,this.options.colors||{}),this._fixCanvasPaths(),this._fixTooltipSize()},lazyLoad:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(!this.options.lazyLoadJS)return Promise.resolve();switch(t){case this.__D3:i="_d3LazyLoader",e="object"!==("undefined"==typeof d3?"undefined":J(d3));break;case this.__TOGEOJSON:i="_togeojsonLazyLoader",e="object"!==("undefined"==typeof toGeoJSON?"undefined":J(toGeoJSON));break;case this.__LGEOMUTIL:i="_geomutilLazyLoader",e="object"!==J(L.GeometryUtil);break;case this.__LALMOSTOVER:i="_almostoverLazyLoader",e="function"!=typeof L.Handler.AlmostOver;break;case this.__LDISTANCEM:i="_distanceMarkersLazyLoader",e="function"!=typeof L.DistanceMarkers}return L.Control.Elevation[i]=r(t,e,L.Control.Elevation[i])},load:function(t){var e=this;this._parseFromString(t).then((function(i){return i?e._loadLayer(i):e._loadFile(t)}))},onAdd:function(t){var e=this;this._map=t;var i=this._container=m("div","elevation-control elevation "+this.options.theme+" "+(this.options.detached?"":"leaflet-control"));return this.lazyLoad(this.__D3).then((function(){e._initButton(i),e._initChart(i),e._initSummary(i),e._initMarker(t),e._initLayer(t),t.on("zoom viewreset zoomanim",e._hideMarker,e).on("resize",e._resetView,e).on("resize",e._resizeChart,e).on("rotate",e._rotateMarker,e).on("mousedown",e._resetDrag,e),x(t.getContainer(),"mousewheel",e._resetDrag,e),x(t.getContainer(),"touchstart",e._resetDrag,e),x(document,"keydown",e._keydownHandler,e),e.on("eledata_added eledata_loaded",e._updateChart,e).on("eledata_added eledata_loaded",e._updateSummary,e),e._updateChart(),e._updateSummary()})),i},onRemove:function(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),b(t.getContainer(),"mousewheel",this._resetDrag,this),b(t.getContainer(),"touchstart",this._resetDrag,this),b(document,"keydown",this._keydownHandler,this),this.off("eledata_added eledata_loaded",this._updateChart,this).off("eledata_added eledata_loaded",this._updateSummary,this)},redraw:function(){this._resizeChart()},setZFollow:function(t){this.options.zFollow=t},show:function(){u(this._container,"display","block")},_addData:function(t){var e=this;if(t){var i=t.geometry;if(i)switch(i.type){case"LineString":this._addGeoJSONData(i.coordinates);break;case"MultiLineString":C(i.coordinates,(function(t){return e._addGeoJSONData(t)}));break;default:console.warn("Unsopperted GeoJSON feature geometry type:"+i.type)}"FeatureCollection"===t.type&&C(t.features,(function(t){return e._addData(t)})),t._latlngs&&this._addGeoJSONData(t._latlngs,t.feature&&t.feature.properties)}},_addGeoJSONData:function(t,e){var i=this;t.forEach((function(t,a){var n,r,o,s,l;if(t.meta=null!==(n=t.meta)&&void 0!==n?n:{time:null,ele:null,hr:null,cad:null,atemp:null},"alt"in t&&(t.meta.ele=t.alt),e&&e.coordinateProperties){var h=e.coordinateProperties;"times"in h&&(t.meta.time=new Date(Date.parse(h.times[a]))),"heart"in h&&(t.meta.hr=parseInt(h.heart[a]))}i._addPoint(null!==(r=t.lat)&&void 0!==r?r:t[1],null!==(o=t.lng)&&void 0!==o?o:t[0],null!==(s=null!==(l=t.alt)&&void 0!==l?l:t.meta.ele)&&void 0!==s?s:t[2]),i._fireEvt("elepoint_added",{point:t,index:i._data.length-1})})),this._fireEvt("eletrack_added",{coords:t,index:this._data.length-1})},_addPoint:function(t,e,i){if(this.options.reverseCoords){var a=[e,t];t=a[0],e=a[1]}this._data.push({x:t,y:e,z:i,latlng:L.latLng(t,e,i)}),this._fireEvt("eledata_updated",{index:this._data.length-1})},_addLayer:function(t){t&&this._layers.addLayer(t),t&&this.options.distanceMarkers&&this.options.distanceMarkers.lazy&&t.on("add remove",(function(t){return L.DistanceMarkers&&t.target instanceof L.Polyline&&t.target[t.type+"DistanceMarkers"]()}))},_addMarker:function(t){t&&this._markers.addLayer(t)},_bindPopup:function(t){var e=t._popup;e&&(e.options.className="elevation-popup",e._content&&(e._content=decodeURI(e._content),e.bindTooltip(e._content,{direction:"auto",sticky:!0,opacity:1,className:"elevation-tooltip"}).openTooltip()))},_initAlmostOverHandler:function(t,e){var i=this;t&&this.options.almostOver&&this.lazyLoad(this.__LGEOMUTIL).then((function(){return i.lazyLoad(i.__LALMOSTOVER)})).then((function(){t.addHandler("almostOver",L.Handler.AlmostOver),L.GeometryUtil&&t.almostOver&&t.almostOver.enabled()&&(t.almostOver.addLayer(e),t.on("almost:move",(function(t){return i._mousemoveLayerHandler(t)})).on("almost:out",(function(t){return i._mouseoutHandler(t)})))}))},_initDistanceMarkers:function(t,e){var i=this;t&&(this.options.distanceMarkers?this.lazyLoad(this.__LGEOMUTIL).then((function(){return i.lazyLoad(i.__LDISTANCEM)})).then((function(){return i.options.polyline&&e.addTo(t)})):this.options.polyline&&e.addTo(t))},_initElevationDiv:function(){var t=y(this.options.elevationDiv);return t||(this.options.elevationDiv="#elevation-div_"+w(),t=m("div","leaflet-control elevation elevation-div",{id:this.options.elevationDiv.substr(1)})),this.options.detached&&d(t,"leaflet-control","elevation-detached"),this.eleDiv=t},_initMapIntegrations:function(t,e){var i=t._map;t._map?(i.once("layeradd",(function(i){return t.options.autofitBounds&&t.fitBounds(e.getBounds())})),L.Browser.mobile?t.options.polyline&&e.addTo(i):(t._initAlmostOverHandler(i,e),t._initDistanceMarkers(i,e))):console.warn("Undefined elevation map object")},_collapse:function(){d(this._container,"elevation-expanded","elevation-collapsed")},_expand:function(){d(this._container,"elevation-collapsed","elevation-expanded")},_fixCanvasPaths:function(){var t=L.Canvas.prototype._fillStroke,e=this;L.Canvas.include({_fillStroke:function(i,a){if(e._layers.hasLayer(a)){var n=e.options.theme.replace("-theme",""),r=S[n]||{},o=a.options;if(o.color=r.line||r.area||n,o.stroke=!!o.color,t.call(this,i,a),o.stroke&&0!==o.weight){var s=i.globalCompositeOperation||"source-over";i.globalCompositeOperation="destination-over",i.strokeStyle=r.outline||"#FFF",i.lineWidth=1.75*o.weight,i.stroke(),i.globalCompositeOperation=s}}else t.call(this,i,a)}})},_fixTooltipSize:function(){var t=this;this.on("elechart_init",(function(){return t.once("elechart_change elechart_hover",(function(e){t._chartEnabled&&(t._chart._showDiagramIndicator(e.data,e.xCoord),t._chart._showDiagramIndicator(e.data,e.xCoord)),t._updateMarker(e.data)}))}))},_findItemForLatLng:function(t){return this._data[this._chart._findIndexForLatLng(t)]},_findItemForX:function(t){return this._data[this._chart._findIndexForXCoord(t)]},_fireEvt:function(t,e,i){this.fire&&this.fire(t,e,i),this._map&&this._map.fire(t,e,i)},_height:function(){if(this._chart)return this._chart._height();var t=this.options;return t.height-t.margins.top-t.margins.bottom},_hideMarker:function(){this.options.autohideMarker&&this._marker.remove()},_initChart:function(t){var e=this.options;if(e.xTicks=this._xTicks(),e.yTicks=this._yTicks(),e.detached){var i=this.eleDiv,a=i.offsetWidth,n=i.offsetHeight;a>0&&(e.width=a),n>20&&(e.height=n-20)}else{var r=this._map.getContainer().clientWidth;e._maxWidth=e._maxWidth>e.width?e._maxWidth:e.width,this._container.style.maxWidth=e._maxWidth+"px",e._maxWidth>r&&(e.width=r-30)}var o=this._chart=new U(e,this);this._x=this._chart._x,this._y=this._chart._y,d3.select(t).call(o.render()),o.on("reset_drag",this._hideMarker,this).on("mouse_enter",this._fireEvt.bind("elechart_enter"),this).on("dragged",this._dragendHandler,this).on("mouse_move",this._mousemoveHandler,this).on("mouse_out",this._mouseoutHandler,this).on("ruler_filter",this._rulerFilterHandler,this).on("zoom",this._updateChart,this).on("elepath_toggle",this._toggleChartHandler,this).on("margins_updated",this._resizeChart,this),this._fireEvt("elechart_axis"),this.options.legend&&this._fireEvt("elechart_legend"),this._fireEvt("elechart_init")},_initLayer:function(){var t=this;this._layers.on("layeradd layerremove",(function(e){var i=e.layer;c(i.getElement&&i.getElement(),t.options.polyline.className+" "+t.options.theme,"layeradd"==e.type),p(i,"mousemove",t._mousemoveLayerHandler.bind(t),"layeradd"==e.type),p(i,"mouseout",t._mouseoutHandler.bind(t),"layeradd"==e.type)}))},_initMarker:function(t){var e=t.getPane("elevationPane");e||((e=this._pane=t.createPane("elevationPane",t.getPane("norotatePane")||t.getPane("mapPane"))).style.zIndex=625,e.style.pointerEvents="none"),this._renderer&&this._renderer.remove(),this._renderer=L.svg({pane:"elevationPane"}).addTo(this._map),this._marker=new V(this.options),this._fireEvt("elechart_marker")},_initButton:function(t){if(!L.Browser.mobile&&this.options.detached||L.DomEvent.disableClickPropagation(t).disableScrollPropagation(t),!this.options.detached){var e=this._button=m("a","elevation-toggle elevation-toggle-icon"+(this.options.autohide?"":" close-button"),{href:"#",title:L._("Elevation")},t);this.options.collapsed&&(this._collapse(),this.options.autohide?(x(t,"mouseover",this._expand,this),x(t,"mouseout",this._collapse,this)):(x(e,"click",L.DomEvent.stop),x(e,"click",this._toggle,this)),x(e,"focus",this._toggle,this),this._map.on("click",this._collapse,this))}},_initSummary:function(t){this._summary=new Y({summary:this.options.summary},this),d3.select(t).call(this._summary.render())},_keydownHandler:function(t){this.options.detached||"Escape"!==t.key||this._collapse()},_loadFile:function(t){var e=this;fetch(t).then((function(t){return t.text()})).then((function(i){e._downloadURL=t,e._parseFromString(i).then((function(t){return t&&e._loadLayer(t)}))})).catch((function(t){return console.warn(t)}))},_loadLayer:function(t){var e=this,i=e.options,a=i.wptIcons,n=i.wptLabels,r=L.geoJson(t,{distanceMarkers:e.options.distanceMarkers,style:function(t){var i=L.extend({},e.options.polyline);return e.options.theme&&(i.className+=" "+e.options.theme),i},pointToLayer:function(t,i){var r,o,s;if(e.options.waypoints){var l=t.properties,h=null!==(r=l.desc)&&void 0!==r?r:"",c=null!==(o=l.name)&&void 0!==o?o:"",d=(null!==(s=l.sym)&&void 0!==s?s:c).replace(" ","-").replace('"',"").replace("'","").toLowerCase();if([!0,"dots"].includes(e.options.waypoints)&&e._registerCheckPoint({latlng:i,label:[!0,"dots"].includes(n)?c:""}),[!0,"markers"].includes(e.options.waypoints)&&0!=a){a.hasOwnProperty(d)||(a[d]=L.divIcon(L.extend({},a[""].options,{html:'<i class="elevation-waypoint-icon '+d+'"></i>'})));var u=L.marker(i,{icon:a[d]});return[!0,"markers"].includes(n)&&(c||h)&&u.bindPopup("<b>"+c+"</b>"+(h.length>0?"<br>"+h:"")).openPopup(),e._addMarker(u),e._bindPopup(u),e.fire("waypoint_added",{point:u,element:i,properties:l}),u}}},onEachFeature:function(i,a){i.geometry&&"Point"!=i.geometry.type&&(e.addData(a),e.track_info=L.extend({},e.track_info,{name:t.name}))}});return e.lazyLoad(e.__D3).then((function(){e._initMapIntegrations(e,r),e._fireEvt("eledata_loaded",{data:t,layer:r,name:e.track_info.name,track_info:e.track_info})})),r},_dragendHandler:function(t){this._hideMarker(),this.fitBounds(L.latLngBounds([t.dragstart.latlng,t.dragend.latlng])),this._fireEvt("elechart_dragged")},_mousemoveHandler:function(t){if(this._data.length&&this._chartEnabled){var e=this._findItemForX(t.xCoord);if(e){var i=t.xCoord;this._chartEnabled&&this._chart._showDiagramIndicator(e,i),this._updateMarker(e),this._setMapView(e),this._map&&l(this._map.getContainer(),"elechart-hover"),this._fireEvt("elechart_change",{data:e,xCoord:i}),this._fireEvt("elechart_hover",{data:e,xCoord:i})}}},_mousemoveLayerHandler:function(t){if(this._data.length){var e=this._findItemForLatLng(t.latlng);if(e){var i=e.xDiagCoord;this._chartEnabled&&this._chart._showDiagramIndicator(e,i),this._updateMarker(e),this._fireEvt("elechart_change",{data:e,xCoord:i})}}},_mouseoutHandler:function(){this.options.detached||(this._hideMarker(),this._chart._hideDiagramIndicator()),this._map&&h(this._map.getContainer(),"elechart-hover"),this._fireEvt("elechart_leave")},_parseFromGeoJSONString:function(t){try{return JSON.parse(t)}catch(t){}},_parseFromString:function(t){var e=this;return new Promise((function(i){return e.lazyLoad(e.__TOGEOJSON).then((function(){var a;try{a=e._parseFromXMLString(t.trim())}catch(i){a=e._parseFromGeoJSONString(t.toString())}a&&(a=e._prepareMultiLineStrings(a),a=e._prepareAdditionalProperties(a)),i(a)}))}))},_parseFromXMLString:function(t){var e;if(0!=t.indexOf("<"))throw"Invalid XML";var i=(new DOMParser).parseFromString(t,"text/xml"),a=i.documentElement.tagName.toLowerCase(),n=i.getElementsByTagName("name");if(i.getElementsByTagName("parsererror").length)throw"Invalid XML";a in toGeoJSON||(a="TrainingCenterDatabase"==i.documentElement.tagName?"tcx":"gpx");var r=toGeoJSON[a](i);return r.name=n.length>0?(null!==(e=Array.from(n).find((function(t){return"trk"==t.parentElement.tagName})))&&void 0!==e?e:n[0]).textContent:"",r},_prepareAdditionalProperties:function(t){return!t.name&&this._downloadURL&&(t.name=this._downloadURL.split("/").pop().split("#")[0].split("?")[0]),t},_prepareMultiLineStrings:function(t){return t.features.forEach((function(e){"MultiLineString"==e.geometry.type&&e.geometry.coordinates.forEach((function(i){t.features.push({geometry:{type:"LineString",coordinates:i},properties:e.properties,type:"Feature"})}))})),t.features.filter((function(t){return"MultiLineString"!=t.geometry.type}))},_registerCheckPoint:function(t){var e=this;this.on("elechart_updated",(function(){return e._chart._registerCheckPoint(t)}))},_registerAreaPath:function(t){var e=this;this.on("elechart_init",(function(){return e._chart._registerAreaPath(t)}))},_registerAxisGrid:function(t){var e=this;this.on("elechart_axis",(function(){return e._chart._registerAxisGrid(t)}))},_registerAxisScale:function(t){var e=this;this.on("elechart_axis",(function(){return e._chart._registerAxisScale(t)}))},_registerTooltip:function(t){var e=this;if(t.chart){var i=L.extend({},t,{value:t.chart});this.on("elechart_init",(function(){return e._chart._registerTooltip(i)}))}if(t.marker){var a=L.extend({},t,{value:t.marker});this.on("elechart_marker",(function(){return e._marker._registerTooltip(a)}))}},_registerSummary:function(t){var e=this;this.on("elechart_summary",(function(){return e._summary._registerSummary(t)}))},_resetDrag:function(){this._chart._resetDrag(),this._hideMarker()},_resetView:function(){this._map&&this._map._isFullscreen||(this._resetDrag(),this._hideMarker(),this.options.autofitBounds&&this.fitBounds())},_resizeChart:function(){if(this._container&&"none"!=u(this._container,"display")){var t,e=this.options;if(e.detached)t=(this.eleDiv||this._container).offsetWidth;else{var i=this._map.getContainer().clientWidth;t=e._maxWidth>i?i-30:e._maxWidth}if(t){var a=this._chart;e.width=t,a&&a._chart&&(a._chart._resize(e),e.xTicks=this._xTicks(),e.yTicks=this._yTicks(),this._updateChart())}this._updateMapSegments()}},_rulerFilterHandler:function(t){this._updateMapSegments(t.coords)},_toggle:function(){k(this._container,"elevation-expanded")?this._collapse():this._expand()},_setMapView:function(t){if(this.options.followMarker&&this._map){var e=this._map.getZoom(),i=this.options.zFollow;"number"==typeof i?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})}},_toggleChartHandler:function(t){var e=this,i=t.name,a=t.enabled;this._chartEnabled=this._chart._hasActiveLayers(),this._layers.eachLayer((function(t){return c(t.getElement&&t.getElement(),e.options.polyline.className+" "+e.options.theme,e._chartEnabled)})),this.options[i]=a||"disabled"!=this.options[i]?"disabled":"enabled",this._chartEnabled||(this._chart._hideDiagramIndicator(),this._marker.remove())},_updateChart:function(){
|
|
2
2
|
/*!this._data.length ||*/
|
|
3
|
-
this._chart&&this._container&&(this._fireEvt("elechart_axis"),this._fireEvt("elechart_area"),this._chart.update({data:this._data,options:this.options}),this._x=this._chart._x,this._y=this._chart._y,this._fireEvt("elechart_updated"))},_updateMarker:function(t){this._marker&&this._marker.update({map:this._map,item:t,maxElevation:this.track_info.elevation_max||0,options:this.options})},_rotateMarker:function(){this._marker&&this._marker.update()},_updateMapSegments:function(t){this._markedSegments.setLatLngs(t||[]),t&&this._map&&!this._map.hasLayer(this._markedSegments)&&this._markedSegments.addTo(this._map)},_updateSummary:function(){var t=this;this._summary.reset(),this.options.summary&&this._fireEvt("elechart_summary"),this.options.downloadLink&&this._downloadURL&&(this._summary._container.innerHTML+='<span class="download"><a href="#">'+L._("Download")+"</a></span>",y(".download a",this._summary._container).onclick=function(e){e.preventDefault(),"modal"==e.downloadLink&&"function"==typeof CustomEvent?document.dispatchEvent(new CustomEvent("eletrack_download",{detail:e})):"link"!=e.downloadLink&&!0!==e.downloadLink||e.confirm(),t._fireEvt("eletrack_download",{downloadLink:t.options.downloadLink,confirm:n.bind(t,t._downloadURL)})})},_width:function(){if(this._chart)return this._chart._width();var t=this.options;return t.width-t.margins.left-t.margins.right},_xTicks:function(){return this.__xTicks&&(this.__xTicks=this.options.xTicks),this.__xTicks||Math.round(this._width()/75)},_yTicks:function(){return this.__yTicks&&(this.__yTicks=this.options.yTicks),this.__yTicks||Math.round(this._height()/30)}});W.addInitHook((function(){var t=this.options,e={};t.imperial?(t.altitudeFactor=this.__footFactor,e.label="ft"):(t.altitudeFactor=t.heightFactor||t.altitudeFactor||1,e.label=t.yLabel),this.on("eledata_updated",(function(e){var i=this._data,a=e.index,n=i[a].z*t.altitudeFactor,r=this.track_info,o=r.elevation_max||-1/0,s=r.elevation_min||1/0;if(!this.options.skipNullZCoords&&a>0){var l=i[a-1].z;if(isNaN(l)){var h=this._lastValidZ,c=n;if(isNaN(h)||isNaN(c)?isNaN(h)?isNaN(c)||(l=c):l=h:l=(h+c)/2,!isNaN(l))return i.splice(a-1,1);i[a-1].z=l}}isNaN(n)||(this._lastValidZ=n),r.elevation_max=n>o?n:o,r.elevation_min=n<s?n:s,i[a].z=n})),this.on("elechart_axis",(function(){this._chart._registerAxisGrid({axis:"y",position:"left",scale:this._chart._y})})),"summary"!=this.options.altitude&&(this.on("elechart_axis",(function(){this._chart._registerAxisScale({axis:"y",position:"left",scale:this._chart._y,label:e.label,labelX:-3,labelY:-8,name:"altitude"})})),this.on("elechart_init",(function(){var t=this.options.theme.replace("-theme",""),e=S[t]||{};this._chart._registerAreaPath({name:"altitude",label:"Altitude",scaleX:"distance",scaleY:"altitude",color:e.area||t,strokeColor:this.options.detached?e.stroke:"#000",strokeOpacity:"1",fillOpacity:this.options.detached?e.alpha||"0.8":1,preferCanvas:this.options.preferCanvas})}))),this._registerTooltip({name:"y",chart:function(i){return L._("y: ")+d3.format("."+t.decimalsY+"f")(i[t.yAttr])+" "+e.label},marker:function(i){return d3.format("."+t.decimalsY+"f")(i[t.yAttr])+" "+e.label}}),this._registerSummary({maxele:{label:"Max Elevation: ",value:function(t){return(t.elevation_max||0).toFixed(2)+" "+e.label}},minele:{label:"Min Elevation: ",value:function(t){return(t.elevation_min||0).toFixed(2)+" "+e.label}}})})),W.addInitHook((function(){var t=this.options,e={};t.imperial?(t.distanceFactor=this.__mileFactor,e.label="mi"):(t.distanceFactor=t.distanceFactor||1,e.label=t.xLabel),this.on("eledata_updated",(function(e){var i=this._data,a=e.index,n=this.track_info,r=n.distance||0,o=i[a].latlng,s=a>0?i[a-1].latlng:o,l=o.distanceTo(s)*t.distanceFactor;r+=Math.round(l/1e3*1e5)/1e5,n.distance=r,i[a].dist=r})),this.on("elechart_axis",(function(){this._chart._registerAxisGrid({axis:"x",position:"bottom",scale:this._chart._x})})),"summary"!=this.options.distance&&this.on("elechart_axis",(function(){var t=this;this._chart._registerAxisScale({axis:"x",position:"bottom",scale:this._chart._x,label:e.label,labelY:25,labelX:function(){return t._width()+6},name:"distance"})})),this._registerTooltip({name:"x",chart:function(i){return L._("x: ")+d3.format("."+t.decimalsX+"f")(i[t.xAttr])+" "+e.label}}),this._registerSummary({totlen:{label:"Total Length: ",value:function(t){return(t.distance||0).toFixed(2)+" "+e.label}}})})),W.addInitHook((function(){var t=this,e=this.options,i={};i.label=e.timeLabel||"t",e.timeFactor=e.timeFactor||3600,this._timeAVGSpeed=(e.timeAVGSpeed||3.6)*(e.speedFactor||1),e.timeFormat?"time"==e.timeFormat?e.timeFormat=function(t){return new Date(t).toLocaleTimeString()}:"date"==e.timeFormat&&(e.timeFormat=function(t){return new Date(t).toLocaleDateString()}):e.timeFormat=function(t){return new Date(t).toLocaleString().replaceAll("/","-").replaceAll(","," ")},e.xTimeFormat=e.xTimeFormat||function(t){return a(t).split("'")[0]},e.time&&"summary"!=e.time&&!L.Browser.mobile&&this._registerAxisScale({axis:"x",position:"top",scale:{attr:"duration",min:0},label:i.label,labelY:-10,labelX:function(){return t._width()},name:"time",tickFormat:function(t){return 0==t?"":e.xTimeFormat(t)},onAxisMount:function(e){e.select(".domain").remove(),e.selectAll("text").attr("opacity",.65).style("font-family","Monospace").style("font-size","110%"),e.selectAll(".tick line").attr("y2",t._height()).attr("stroke-dasharray",2).attr("opacity",.75)}}),this.on("elepoint_added",(function(t){var i=this._data,a=t.index;if(!t.point.meta||!t.point.meta.time){t.point.meta=t.point.meta||{};var n=i[a].dist-i[a>0?a-1:a].dist,r=this._timeAVGSpeed;t.point.meta.time=new Date(a>0?i[a-1].time.getTime()+n/r*e.timeFactor*1e3:Date.now())}var o=t.point.meta.time;o.getTime()-60*o.getTimezoneOffset()*1e3==0&&(o=0);var s=o,l=a>0?i[a-1].time:s,h=Math.abs(s-l),c=(this.track_info.time||0)+h;this.track_info.time=c,i[a].time=o,i[a].duration=c})),this.options.timestamps&&this._registerTooltip({name:"date",chart:function(e){return L._("t: ")+t.options.timeFormat(e.time)}}),this.options.time&&(this._registerTooltip({name:"time",chart:function(t){return L._("T: ")+a(t.duration||0)}}),this._registerSummary({tottime:{label:"Total Time: ",value:function(t){return a(t.time||0)}}}))})),W.addInitHook((function(){var t=this;if(this.options.slope){var e=this.options,i={};i.label=e.slopeLabel||"%","summary"!=this.options.slope&&(this._registerAxisScale({axis:"y",position:"right",scale:{min:-1,max:1},tickPadding:16,label:i.label,labelX:25,labelY:-8,name:"slope"}),this._registerAreaPath({name:"slope",label:"Slope",yAttr:"slope",scaleX:"distance",scaleY:"slope",color:"#F00",strokeColor:"#000",strokeOpacity:"0.5",fillOpacity:"0.25"})),this.on("eledata_updated",(function(t){var e=this._data,i=t.index,a=e[i].z,n=1e3*(e[i].dist-e[i>0?i-1:i].dist),r=this.track_info,o=r.ascent||0,l=r.descent||0,h=r.slope_max||0,c=r.slope_min||0,d=0;if(!isNaN(a)){var u=i>0?a-e[i-1].z:0;u>0?o+=u:u<0&&(l-=u),0!==n&&(d=u/n*100)}if(this.options.sDeltaMax){var _=i>0?d-e[i-1].slope:0,p=this.options.sDeltaMax;Math.abs(_)>p&&(d=e[i-1].slope+p*Math.sign(_))}d=s(d,this.options.sRange),r.ascent=o,r.descent=l,r.slope_max=d>h?d:h,r.slope_min=d<c?d:c,e[i].slope=L.Util.formatNum(d,2)})),this._registerTooltip({name:"slope",chart:function(t){return L._("m: ")+t.slope+i.label},marker:function(t){return Math.round(t.slope)+i.label}}),this._registerSummary({ascent:{label:"Total Ascent: ",value:function(e){return Math.round(e.ascent||0)+" "+(t.options.imperial?"ft":"m")}},descent:{label:"Total Descent: ",value:function(e){return Math.round(e.descent||0)+" "+(t.options.imperial?"ft":"m")}},minslope:{label:"Min Slope: ",value:function(t){return Math.round(t.slope_min||0)+" "+i.label}},maxslope:{label:"Max Slope: ",value:function(t){return Math.round(t.slope_max||0)+" "+i.label}}})}})),W.addInitHook((function(){if(this.options.speed||this.options.acceleration){var t=this.options,e={};e.label=t.speedLabel||L._(t.imperial?"mph":"km/h"),t.speedFactor=t.speedFactor||1,this.options.speed&&"summary"!=this.options.speed&&(this._registerAxisScale({axis:"y",position:"right",scale:{min:0,max:1},tickPadding:16,label:e.label,labelX:25,labelY:-8,name:"speed"}),this._registerAreaPath({name:"speed",label:"Speed",yAttr:"speed",scaleX:"distance",scaleY:"speed",color:"#03ffff",strokeColor:"#000",strokeOpacity:"0.5",fillOpacity:"0.25"})),this.on("elepoint_added",(function(e){var i=this._data,a=e.index,n=i[a].time,r=n-(a>0?i[a-1].time:n),o=this.track_info,l=o.speed_max||-1/0,h=o.speed_min||1/0,c=o.speed_avg||0,d=0;if(r>0){var u=1e3*(i[a].dist-i[a>0?a-1:a].dist);d=Math.abs(u/r*t.timeFactor)*t.speedFactor}if(this.options.speedDeltaMax){var _=a>0?d-i[a-1].speed:0,p=this.options.speedDeltaMax;Math.abs(_)>p&&(d=i[a-1].speed+p*Math.sign(_))}d=s(d,this.options.speedRange),o.speed_max=d>l?d:l,o.speed_min=d<h?d:h,o.speed_avg=(d+c)/2,i[a].speed=L.Util.formatNum(d,2)})),this.options.speed&&(this._registerTooltip({name:"speed",chart:function(t){return L._("v: ")+t.speed+" "+e.label},marker:function(t){return Math.round(t.speed)+" "+e.label}}),this._registerSummary({minspeed:{label:"Min Speed: ",value:function(t){return Math.round(t.speed_min||0)+" "+e.label}},maxspeed:{label:"Max Speed: ",value:function(t){return Math.round(t.speed_max||0)+" "+e.label}},avgspeed:{label:"Avg Speed: ",value:function(t){return Math.round(t.speed_avg||0)+" "+e.label}}}))}})),W.addInitHook((function(){if(this.options.acceleration){var t=this.options,e={};e.label=t.accelerationLabel||L._(t.imperial?"ft/s²":"m/s²"),t.accelerationFactor=t.accelerationFactor||1,"summary"!=this.options.acceleration&&(this._registerAxisScale({axis:"y",position:"right",scale:{min:0,max:1},tickPadding:16,label:e.label,labelX:25,labelY:-8,name:"acceleration"}),this._registerAreaPath({name:"acceleration",label:"Acceleration",yAttr:"acceleration",scaleX:"distance",scaleY:"acceleration",color:"#050402",strokeColor:"#000",strokeOpacity:"0.5",fillOpacity:"0.25"})),this.on("elepoint_added",(function(e){var i=this._data,a=e.index,n=i[a].time,r=(n-(a>0?i[a-1].time:n))/1e3,o=this.track_info,l=o.acceleration_max||-1/0,h=o.acceleration_min||1/0,c=o.acceleration_avg||0,d=0;if(r>0){var u=i[a].speed,_=(u-(a>0?i[a-1].speed:u))*(1e3/t.timeFactor);d=Math.abs(_/r)*t.accelerationFactor}if(this.options.accelerationDeltaMax){var p=a>0?d-i[a-1].acceleration:0,m=this.options.accelerationDeltaMax;Math.abs(p)>m&&(d=i[a-1].acceleration+m*Math.sign(p))}d=s(d,this.options.accelerationRange),o.acceleration_max=d>l?d:l,o.acceleration_min=d<h?d:h,o.acceleration_avg=(d+c)/2,i[a].acceleration=L.Util.formatNum(d,2)})),this._registerTooltip({name:"acceleration",chart:function(t){return L._("a: ")+t.acceleration+" "+e.label},marker:function(t){return Math.round(t.acceleration)+" "+e.label}}),this._registerSummary({minacceleration:{label:"Min Acceleration: ",value:function(t){return Math.round(t.acceleration_min||0)+" "+e.label}},maxacceleration:{label:"Max Acceleration: ",value:function(t){return Math.round(t.acceleration_max||0)+" "+e.label}},avgacceleration:{label:"Avg Acceleration: ",value:function(t){return Math.round(t.acceleration_avg||0)+" "+e.label}}})}})),W.Utils=M,W.Components=H,W.Chart=U,j=L.i18n.bind({}),L.i18n=L._=function(t,e){return L.locale&&L.locales[L.locale]&&""==L.locales[L.locale][t]&&(L.locales[L.locale][t]=""),j.call(null,t,e)},W.addInitHook((function(){this.enableDragging=this.enableBrush,this.disableDragging=this.disableBrush,this.loadChart=this.addTo,this.loadData=this.load,this.loadGPX=this.load,this.loadGeoJSON=this.load,this.loadXML=this.load,this.loadFile=this.load})),L.control.elevation=function(t){return new W(t)}}));
|
|
3
|
+
this._chart&&this._container&&(this._fireEvt("elechart_axis"),this._fireEvt("elechart_area"),this._chart.update({data:this._data,options:this.options}),this._x=this._chart._x,this._y=this._chart._y,this._fireEvt("elechart_updated"))},_updateMarker:function(t){this._marker&&this._marker.update({map:this._map,item:t,maxElevation:this.track_info.elevation_max||0,options:this.options})},_rotateMarker:function(){this._marker&&this._marker.update()},_updateMapSegments:function(t){this._markedSegments.setLatLngs(t||[]),t&&this._map&&!this._map.hasLayer(this._markedSegments)&&this._markedSegments.addTo(this._map)},_updateSummary:function(){var t=this;this._summary.reset(),this.options.summary&&this._fireEvt("elechart_summary"),this.options.downloadLink&&this._downloadURL&&(this._summary._container.innerHTML+='<span class="download"><a href="#">'+L._("Download")+"</a></span>",y(".download a",this._summary._container).onclick=function(e){e.preventDefault(),"modal"==e.downloadLink&&"function"==typeof CustomEvent?document.dispatchEvent(new CustomEvent("eletrack_download",{detail:e})):"link"!=e.downloadLink&&!0!==e.downloadLink||e.confirm(),t._fireEvt("eletrack_download",{downloadLink:t.options.downloadLink,confirm:n.bind(t,t._downloadURL)})})},_width:function(){if(this._chart)return this._chart._width();var t=this.options;return t.width-t.margins.left-t.margins.right},_xTicks:function(){return this.__xTicks&&(this.__xTicks=this.options.xTicks),this.__xTicks||Math.round(this._width()/75)},_yTicks:function(){return this.__yTicks&&(this.__yTicks=this.options.yTicks),this.__yTicks||Math.round(this._height()/30)}});W.addInitHook((function(){var t=this.options,e={};t.imperial?(t.altitudeFactor=this.__footFactor,e.label="ft"):(t.altitudeFactor=t.heightFactor||t.altitudeFactor||1,e.label=t.yLabel),this.on("eledata_updated",(function(e){var i=this._data,a=e.index,n=i[a].z*t.altitudeFactor,r=this.track_info,o=r.elevation_max||-1/0,s=r.elevation_min||1/0;if(!this.options.skipNullZCoords&&a>0){var l=i[a-1].z;if(isNaN(l)){var h=this._lastValidZ,c=n;if(isNaN(h)||isNaN(c)?isNaN(h)?isNaN(c)||(l=c):l=h:l=(h+c)/2,!isNaN(l))return i.splice(a-1,1);i[a-1].z=l}}isNaN(n)||(this._lastValidZ=n),r.elevation_max=n>o?n:o,r.elevation_min=n<s?n:s,i[a].z=n})),this.on("elechart_axis",(function(){this._chart._registerAxisGrid({axis:"y",position:"left",scale:this._chart._y})})),"summary"!=this.options.altitude&&(this.on("elechart_axis",(function(){this._chart._registerAxisScale({axis:"y",position:"left",scale:this._chart._y,label:e.label,labelX:-3,labelY:-8,name:"altitude"})})),this.on("elechart_init",(function(){var t=this.options.theme.replace("-theme",""),e=S[t]||{};this._chart._registerAreaPath({name:"altitude",label:"Altitude",scaleX:"distance",scaleY:"altitude",color:e.area||t,strokeColor:this.options.detached?e.stroke:"#000",strokeOpacity:"1",fillOpacity:this.options.detached?e.alpha||"0.8":1,preferCanvas:this.options.preferCanvas})}))),this._registerTooltip({name:"y",chart:function(i){return L._("y: ")+d3.format("."+t.decimalsY+"f")(i[t.yAttr])+" "+e.label},marker:function(i){return d3.format("."+t.decimalsY+"f")(i[t.yAttr])+" "+e.label}}),this._registerSummary({maxele:{label:"Max Elevation: ",value:function(t){return(t.elevation_max||0).toFixed(2)+" "+e.label}},minele:{label:"Min Elevation: ",value:function(t){return(t.elevation_min||0).toFixed(2)+" "+e.label}}})})),W.addInitHook((function(){var t=this.options,e={};t.imperial?(t.distanceFactor=this.__mileFactor,e.label="mi"):(t.distanceFactor=t.distanceFactor||1,e.label=t.xLabel),this.on("eledata_updated",(function(e){var i=this._data,a=e.index,n=this.track_info,r=n.distance||0,o=i[a].latlng,s=a>0?i[a-1].latlng:o,l=o.distanceTo(s)*t.distanceFactor;r+=Math.round(l/1e3*1e5)/1e5,n.distance=r,i[a].dist=r})),this.on("elechart_axis",(function(){this._chart._registerAxisGrid({axis:"x",position:"bottom",scale:this._chart._x})})),"summary"!=this.options.distance&&this.on("elechart_axis",(function(){var t=this;this._chart._registerAxisScale({axis:"x",position:"bottom",scale:this._chart._x,label:e.label,labelY:25,labelX:function(){return t._width()+6},name:"distance"})})),this._registerTooltip({name:"x",chart:function(i){return L._("x: ")+d3.format("."+t.decimalsX+"f")(i[t.xAttr])+" "+e.label}}),this._registerSummary({totlen:{label:"Total Length: ",value:function(t){return(t.distance||0).toFixed(2)+" "+e.label}}})})),W.addInitHook((function(){var t=this,e=this.options,i={};i.label=e.timeLabel||"t",e.timeFactor=e.timeFactor||3600,this._timeAVGSpeed=(e.timeAVGSpeed||3.6)*(e.speedFactor||1),e.timeFormat?"time"==e.timeFormat?e.timeFormat=function(t){return new Date(t).toLocaleTimeString()}:"date"==e.timeFormat&&(e.timeFormat=function(t){return new Date(t).toLocaleDateString()}):e.timeFormat=function(t){return new Date(t).toLocaleString().replaceAll("/","-").replaceAll(","," ")},e.xTimeFormat=e.xTimeFormat||function(t){return a(t).split("'")[0]},e.time&&"summary"!=e.time&&!L.Browser.mobile&&this._registerAxisScale({axis:"x",position:"top",scale:{attr:"duration",min:0},label:i.label,labelY:-10,labelX:function(){return t._width()},name:"time",tickFormat:function(t){return 0==t?"":e.xTimeFormat(t)},onAxisMount:function(e){e.select(".domain").remove(),e.selectAll("text").attr("opacity",.65).style("font-family","Monospace").style("font-size","110%"),e.selectAll(".tick line").attr("y2",t._height()).attr("stroke-dasharray",2).attr("opacity",.75)}}),this.on("elepoint_added",(function(t){var i=this._data,a=t.index;if(!t.point.meta||!t.point.meta.time){t.point.meta=t.point.meta||{};var n=i[a].dist-i[a>0?a-1:a].dist,r=this._timeAVGSpeed;t.point.meta.time=new Date(a>0?i[a-1].time.getTime()+n/r*e.timeFactor*1e3:Date.now())}var o=t.point.meta.time;o.getTime()-60*o.getTimezoneOffset()*1e3==0&&(o=0);var s=o,l=a>0?i[a-1].time:s,h=Math.abs(s-l),c=(this.track_info.time||0)+h;this.track_info.time=c,i[a].time=o,i[a].duration=c})),this.options.timestamps&&this._registerTooltip({name:"date",chart:function(e){return L._("t: ")+t.options.timeFormat(e.time)}}),this.options.time&&(this._registerTooltip({name:"time",chart:function(t){return L._("T: ")+a(t.duration||0)}}),this._registerSummary({tottime:{label:"Total Time: ",value:function(t){return a(t.time||0)}}}))})),W.addInitHook((function(){var t=this;if(this.options.slope){var e=this.options,i={};i.label=e.slopeLabel||"%","summary"!=this.options.slope&&(this._registerAxisScale({axis:"y",position:"right",scale:{min:-1,max:1},tickPadding:16,label:i.label,labelX:25,labelY:-8,name:"slope"}),this._registerAreaPath({name:"slope",label:"Slope",yAttr:"slope",scaleX:"distance",scaleY:"slope",color:"#F00",strokeColor:"#000",strokeOpacity:"0.5",fillOpacity:"0.25"})),this.on("eledata_updated",(function(t){var e=this._data,i=t.index,a=e[i].z,n=1e3*(e[i].dist-e[i>0?i-1:i].dist),r=this.track_info,o=r.ascent||0,l=r.descent||0,h=r.slope_max||0,c=r.slope_min||0,d=0;if(!isNaN(a)){var u=i>0?a-e[i-1].z:0;u>0?o+=u:u<0&&(l-=u),0!==n&&(d=u/n*100)}if(this.options.sDeltaMax){var _=i>0?d-e[i-1].slope:0,p=this.options.sDeltaMax;Math.abs(_)>p&&(d=e[i-1].slope+p*Math.sign(_))}d=s(d,this.options.sRange),r.ascent=o,r.descent=l,r.slope_max=d>h?d:h,r.slope_min=d<c?d:c,e[i].slope=L.Util.formatNum(d,2)})),this._registerTooltip({name:"slope",chart:function(t){return L._("m: ")+t.slope+i.label},marker:function(t){return Math.round(t.slope)+i.label}}),this._registerSummary({ascent:{label:"Total Ascent: ",value:function(e){return Math.round(e.ascent||0)+" "+(t.options.imperial?"ft":"m")}},descent:{label:"Total Descent: ",value:function(e){return Math.round(e.descent||0)+" "+(t.options.imperial?"ft":"m")}},minslope:{label:"Min Slope: ",value:function(t){return Math.round(t.slope_min||0)+" "+i.label}},maxslope:{label:"Max Slope: ",value:function(t){return Math.round(t.slope_max||0)+" "+i.label}}})}})),W.addInitHook((function(){if(this.options.speed||this.options.acceleration){var t=this.options,e={};e.label=t.speedLabel||L._(t.imperial?"mph":"km/h"),t.speedFactor=t.speedFactor||1,this.options.speed&&"summary"!=this.options.speed&&(this._registerAxisScale({axis:"y",position:"right",scale:{min:0,max:1},tickPadding:16,label:e.label,labelX:25,labelY:-8,name:"speed"}),this._registerAreaPath({name:"speed",label:"Speed",yAttr:"speed",scaleX:"distance",scaleY:"speed",color:"#03ffff",strokeColor:"#000",strokeOpacity:"0.5",fillOpacity:"0.25"})),this.on("elepoint_added",(function(e){var i=this._data,a=e.index,n=i[a].time,r=n-(a>0?i[a-1].time:n),o=this.track_info,l=o.speed_max||-1/0,h=o.speed_min||1/0,c=o.speed_avg||0,d=0;if(r>0){var u=1e3*(i[a].dist-i[a>0?a-1:a].dist);d=Math.abs(u/r*t.timeFactor)*t.speedFactor}if(this.options.speedDeltaMax){var _=a>0?d-i[a-1].speed:0,p=this.options.speedDeltaMax;Math.abs(_)>p&&(d=i[a-1].speed+p*Math.sign(_))}d=s(d,this.options.speedRange),o.speed_max=d>l?d:l,o.speed_min=d<h?d:h,o.speed_avg=(d+c)/2,i[a].speed=L.Util.formatNum(d,2)})),this.options.speed&&(this._registerTooltip({name:"speed",chart:function(t){return L._("v: ")+t.speed+" "+e.label},marker:function(t){return Math.round(t.speed)+" "+e.label}}),this._registerSummary({minspeed:{label:"Min Speed: ",value:function(t){return Math.round(t.speed_min||0)+" "+e.label}},maxspeed:{label:"Max Speed: ",value:function(t){return Math.round(t.speed_max||0)+" "+e.label}},avgspeed:{label:"Avg Speed: ",value:function(t){return Math.round(t.speed_avg||0)+" "+e.label}}}))}})),W.addInitHook((function(){if(this.options.acceleration){var t=this.options,e={};e.label=t.accelerationLabel||L._(t.imperial?"ft/s²":"m/s²"),t.accelerationFactor=t.accelerationFactor||1,"summary"!=this.options.acceleration&&(this._registerAxisScale({axis:"y",position:"right",scale:{min:0,max:1},tickPadding:16,label:e.label,labelX:25,labelY:-8,name:"acceleration"}),this._registerAreaPath({name:"acceleration",label:"Acceleration",yAttr:"acceleration",scaleX:"distance",scaleY:"acceleration",color:"#050402",strokeColor:"#000",strokeOpacity:"0.5",fillOpacity:"0.25"})),this.on("elepoint_added",(function(e){var i=this._data,a=e.index,n=i[a].time,r=(n-(a>0?i[a-1].time:n))/1e3,o=this.track_info,l=o.acceleration_max||-1/0,h=o.acceleration_min||1/0,c=o.acceleration_avg||0,d=0;if(r>0){var u=i[a].speed,_=(u-(a>0?i[a-1].speed:u))*(1e3/t.timeFactor);d=Math.abs(_/r)*t.accelerationFactor}if(this.options.accelerationDeltaMax){var p=a>0?d-i[a-1].acceleration:0,m=this.options.accelerationDeltaMax;Math.abs(p)>m&&(d=i[a-1].acceleration+m*Math.sign(p))}d=s(d,this.options.accelerationRange),o.acceleration_max=d>l?d:l,o.acceleration_min=d<h?d:h,o.acceleration_avg=(d+c)/2,i[a].acceleration=L.Util.formatNum(d,2)})),this._registerTooltip({name:"acceleration",chart:function(t){return L._("a: ")+t.acceleration+" "+e.label},marker:function(t){return Math.round(t.acceleration)+" "+e.label}}),this._registerSummary({minacceleration:{label:"Min Acceleration: ",value:function(t){return Math.round(t.acceleration_min||0)+" "+e.label}},maxacceleration:{label:"Max Acceleration: ",value:function(t){return Math.round(t.acceleration_max||0)+" "+e.label}},avgacceleration:{label:"Avg Acceleration: ",value:function(t){return Math.round(t.acceleration_avg||0)+" "+e.label}}})}})),W.Utils=M,W.Components=X,W.Chart=U,R=L.i18n.bind({}),L.i18n=L._=function(t,e){return L.locale&&L.locales[L.locale]&&""==L.locales[L.locale][t]&&(L.locales[L.locale][t]=""),R.call(null,t,e)},W.addInitHook((function(){this.enableDragging=this.enableBrush,this.disableDragging=this.disableBrush,this.loadChart=this.addTo,this.loadData=this.load,this.loadGPX=this.load,this.loadGeoJSON=this.load,this.loadXML=this.load,this.loadFile=this.load,this._addGPXData=this._addGeoJSONData,this._registerFocusLabel=this._registerTooltip})),L.control.elevation=function(t){return new W(t)}}));
|
|
4
4
|
//# sourceMappingURL=leaflet-elevation.min.js.map
|