From ebe123a6d40bf17ab2a35f331fb08c8c0fc76a3a Mon Sep 17 00:00:00 2001 From: Dennis Fink Date: Tue, 3 Nov 2026 23:18:23 +0100 Subject: Update vendored Leaflet Elevation and map dependencies --- assets/static/vendor/leaflet-elevation/libs/leaflet-ruler.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'assets/static/vendor/leaflet-elevation/libs/leaflet-ruler.min.js') diff --git a/assets/static/vendor/leaflet-elevation/libs/leaflet-ruler.min.js b/assets/static/vendor/leaflet-elevation/libs/leaflet-ruler.min.js index e732020..f88d334 100644 --- a/assets/static/vendor/leaflet-elevation/libs/leaflet-ruler.min.js +++ b/assets/static/vendor/leaflet-elevation/libs/leaflet-ruler.min.js @@ -1 +1 @@ -L.Control.Ruler=L.Control.extend({options:{position:"topright",circleMarker:{color:"red",radius:2},lineStyle:{color:"red",dashArray:"1,6"},lengthUnit:{display:"km",decimal:2,factor:.001,label:"Distance:"},angleUnit:{display:"°",decimal:2,factor:360,label:"Bearing:"}},initialize:function(options){L.setOptions(this,options),this._layers=L.layerGroup(),this._enabled=!1},onAdd:function(map){this._defaultCursor=map._container.style.cursor,this._map=map;let container=L.DomUtil.create("div","leaflet-bar");return container.classList.add("leaflet-ruler"),L.DomEvent.disableClickPropagation(container),L.DomEvent.on(container,"click",this._toggleMeasure,this),this._container=container},onRemove:function(){L.DomEvent.off(this._container,"click",this._toggleMeasure,this)},_attachMouseEvents:function(){let map=this._map;map.doubleClickZoom.disable(),L.DomEvent.on(map._container,"keydown",this._escape,this),L.DomEvent.on(map._container,"dblclick",this._closePath,this),map._container.style.cursor="crosshair",map.on("click",this._addPoint,this),map.on("mousemove",this._moving,this)},_removeMouseEvents:function(){let map=this._map;map.doubleClickZoom.enable(),L.DomEvent.off(map._container,"keydown",this._escape,this),L.DomEvent.off(map._container,"dblclick",this._closePath,this),map._container.style.cursor=this._defaultCursor,map.off("click",this._addPoint,this),map.off("mousemove",this._moving,this)},_disable:function(){this._enabled=!1,this._container.classList.remove("leaflet-ruler-clicked"),this._map.removeLayer(this._layers),this._layers=L.layerGroup(),this._latlngs=[],this._totalLength=0,this._removeMouseEvents()},_enable:function(){this._enabled=!0,this._container.classList.add("leaflet-ruler-clicked"),this._circles=L.featureGroup().addTo(this._layers),this._polyline=L.polyline([],this.options.lineStyle).addTo(this._layers),this._layers.addTo(this._map),this._latlngs=[],this._totalLength=0,this._attachMouseEvents()},_toggleMeasure:function(){this._enabled?this._disable():this._enable()},_drawTooltip:function(latlng,layer,incremental){let clickCount=this._latlngs.length,lastClick=clickCount?this._latlngs[clickCount-1]:latlng,bearing=this._calculateBearing(lastClick,latlng),distance=lastClick.distanceTo(latlng)*this.options.lengthUnit.factor,totalLength,plusLength;incremental?(totalLength=(clickCount?distance+this._totalLength||0:distance).toFixed(this.options.lengthUnit.decimal),plusLength=clickCount?'
(+'+distance.toFixed(this.options.lengthUnit.decimal)+")
":""):(this._totalLength+=distance,totalLength=(clickCount?this._totalLength:distance).toFixed(this.options.lengthUnit.decimal),plusLength="");var text=""+this.options.angleUnit.label+" "+bearing.toFixed(this.options.angleUnit.decimal)+" "+this.options.angleUnit.display+"
"+this.options.lengthUnit.label+" "+totalLength+" "+this.options.lengthUnit.display+plusLength;layer.setLatLng(latlng);let tooltip=layer.getTooltip();return tooltip?tooltip.setTooltipContent(text):layer.bindTooltip(text,incremental?{direction:"auto",sticky:!0,offset:L.point(0,-40),className:"moving-tooltip"}:{permanent:!0,className:"result-tooltip"}).openTooltip(),layer},_addPoint:function(e){let latlng=e.latlng||e,point=L.circleMarker(latlng,this.options.circleMarker).addTo(this._circles);this._polyline.addLatLng(latlng),this._latlngs.length&&!latlng.equals(this._latlngs[this._latlngs.length-1])&&this._drawTooltip(latlng,point,!1),this._latlngs.push(latlng)},_moving:function(e){if(this._latlngs.length){let lastCLick=this._latlngs[this._latlngs.length-1];this._tempLine||(this._tempLine=L.polyline([],this.options.lineStyle).addTo(this._map)),this._tempPoint||(this._tempPoint=L.circleMarker(e.latlng,this.options.circleMarker).addTo(this._map)),this._tempLine.setLatLngs([lastCLick,e.latlng]),this._drawTooltip(e.latlng,this._tempPoint,!0),L.DomEvent.off(this._container,"click",this._toggleMeasure,this)}},_escape:function(e){27===e.keyCode&&(this._latlngs.length?this._closePath():(this._enabled=!0,this._toggleMeasure()))},_calculateBearing:function(start,end){const toRad=L.DomUtil.DEG_TO_RAD,toDeg=this.options.angleUnit.factor/2/Math.PI;let y=Math.sin((end.lng-start.lng)*toRad)*Math.cos(end.lat*toRad),x=Math.cos(start.lat*toRad)*Math.sin(end.lat*toRad)-Math.sin(start.lat*toRad)*Math.cos(end.lat*toRad)*Math.cos((end.lng-start.lng)*toRad);return(Math.atan2(y,x)*toDeg+this.options.angleUnit.factor)%this.options.angleUnit.factor},_closePath:function(){this._tempLine&&(this._map.removeLayer(this._tempLine),this._tempLine=null),this._tempPoint&&(this._map.removeLayer(this._tempPoint),this._tempLine=null),this._latlngs.length<=1&&this._map.removeLayer(this._circles),this._enabled=!1,L.DomEvent.on(this._container,"click",this._toggleMeasure,this),this._toggleMeasure()}}),L.control.ruler=function(options){return new L.Control.Ruler(options)}; \ No newline at end of file +L.Control.Ruler=L.Control.extend({options:{position:"topright",circleMarker:{color:"red",radius:2},lineStyle:{color:"red",dashArray:"1,6"},lengthUnit:{display:"km",decimal:2,factor:.001,label:"Distance:"},angleUnit:{display:"°",decimal:2,factor:360,label:"Bearing:"}},initialize(t){L.Util.setOptions(this,t),this._layers=new L.LayerGroup,this._enabled=!1},onAdd(t){this._defaultCursor=t._container.style.cursor,this._map=t;let e=L.DomUtil.create("div","leaflet-bar");return e.classList.add("leaflet-ruler"),L.DomEvent.disableClickPropagation(e),L.DomEvent.on(e,"click",this._toggleMeasure,this),this._container=e},onRemove(){L.DomEvent.off(this._container,"click",this._toggleMeasure,this)},_attachMouseEvents(){let t=this._map;t.doubleClickZoom.disable(),L.DomEvent.on(t._container,"keydown",this._escape,this),L.DomEvent.on(t._container,"dblclick",this._closePath,this),t._container.style.cursor="crosshair",t.on("click",this._addPoint,this),t.on(L.version.startsWith("2")?"pointermove":"mousemove",this._moving,this)},_removeMouseEvents(){let t=this._map;t.doubleClickZoom.enable(),L.DomEvent.off(t._container,"keydown",this._escape,this),L.DomEvent.off(t._container,"dblclick",this._closePath,this),t._container.style.cursor=this._defaultCursor,t.off("click",this._addPoint,this),t.off(L.version.startsWith("2")?"pointermove":"mousemove",this._moving,this)},_disable(){this._enabled=!1,this._container.classList.remove("leaflet-ruler-clicked"),this._layers.remove().clearLayers(),this._latlngs=[],this._totalLength=0,this._removeMouseEvents()},_enable(){this._enabled=!0,this._container.classList.add("leaflet-ruler-clicked"),this._circles=new L.FeatureGroup().addTo(this._layers),this._polyline=new L.Polyline([],this.options.lineStyle).addTo(this._layers),this._layers.addTo(this._map),this._latlngs=[],this._totalLength=0,this._attachMouseEvents()},_toggleMeasure(){this._enabled?this._disable():this._enable()},_drawTooltip(t,e,i){let s=this._latlngs[this._latlngs.length-1]??t,o=this._calculateBearing(s,t),l=s.distanceTo(t)*this.options.lengthUnit.factor,n=this._totalLength+l,a=n.toFixed(this.options.lengthUnit.decimal),h=i?'
(+'+l.toFixed(this.options.lengthUnit.decimal)+")
":"";this._totalLength=i?this._totalLength:n,e.getTooltip()||e.bindTooltip("",i?{direction:"auto",sticky:!0,offset:new L.Point(0,-40),className:"moving-tooltip"}:{permanent:!0,className:"result-tooltip"}).openTooltip(),e.setLatLng(t).setTooltipContent(""+this.options.angleUnit.label+" "+o.toFixed(this.options.angleUnit.decimal)+" "+this.options.angleUnit.display+"
"+this.options.lengthUnit.label+" "+a+" "+this.options.lengthUnit.display+h)},_addPoint(t){let e=t.latlng||t,i=new L.CircleMarker(e,this.options.circleMarker).addTo(this._circles);this._polyline.addLatLng(e),this._latlngs.length&&!e.equals(this._latlngs[this._latlngs.length-1])&&this._drawTooltip(e,i,!1),this._latlngs.push(e)},_moving(t){if(this._latlngs.length){let e=this._latlngs[this._latlngs.length-1];this._tempLine||(this._tempLine=new L.Polyline([],this.options.lineStyle).addTo(this._map)),this._tempPoint||(this._tempPoint=new L.CircleMarker(t.latlng,this.options.circleMarker).addTo(this._map)),this._tempLine.setLatLngs([e,t.latlng]),this._drawTooltip(t.latlng,this._tempPoint,!0),L.DomEvent.off(this._container,"click",this._toggleMeasure,this)}},_escape(t){t.keyCode===27&&(this._latlngs.length?this._closePath():(this._enabled=!0,this._toggleMeasure()))},_calculateBearing(t,e){const i=Math.PI/180,s=this.options.angleUnit.factor/2/Math.PI;let o=Math.sin((e.lng-t.lng)*i)*Math.cos(e.lat*i),l=Math.cos(t.lat*i)*Math.sin(e.lat*i)-Math.sin(t.lat*i)*Math.cos(e.lat*i)*Math.cos((e.lng-t.lng)*i);return(Math.atan2(o,l)*s+this.options.angleUnit.factor)%this.options.angleUnit.factor},_closePath(){this._tempLine&&(this._tempLine.remove(),this._tempLine=null),this._tempPoint&&(this._tempPoint.remove(),this._tempLine=null),this._latlngs.length<=1&&this._circles.remove(),this._enabled=!1,L.DomEvent.on(this._container,"click",this._toggleMeasure,this),this._toggleMeasure()}}),L.control=L.control||{},L.control.ruler=function(t){return new L.Control.Ruler(t)}; -- cgit v1.3.1