summaryrefslogtreecommitdiff
path: root/assets/static/vendor/leaflet-elevation/libs/leaflet-distance-marker.min.js
diff options
context:
space:
mode:
Diffstat (limited to 'assets/static/vendor/leaflet-elevation/libs/leaflet-distance-marker.min.js')
-rw-r--r--assets/static/vendor/leaflet-elevation/libs/leaflet-distance-marker.min.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/assets/static/vendor/leaflet-elevation/libs/leaflet-distance-marker.min.js b/assets/static/vendor/leaflet-elevation/libs/leaflet-distance-marker.min.js
index b8bc58b..1b669ed 100644
--- a/assets/static/vendor/leaflet-elevation/libs/leaflet-distance-marker.min.js
+++ b/assets/static/vendor/leaflet-elevation/libs/leaflet-distance-marker.min.js
@@ -1 +1 @@
-L.DistanceMarker=L.CircleMarker.extend({_updatePath:function(){let ctx=this._renderer._ctx,p=this._point;if(this.options.rotation=this.options.rotation||0,this.options.radius&&this._renderer._updateCircle&&this._renderer._updateCircle(this),this.options.icon&&this.options.icon.url)if(this.options.icon.element){const icon=this.options.icon;let cx=p.x+icon.offset.x,cy=p.y+icon.offset.y;ctx.save(),icon.rotate&&(ctx.translate(p.x,p.y),ctx.rotate(icon.rotate),cx=0,cy=0),ctx.drawImage(icon.element,cx-icon.size[0]/2,cy-icon.size[1]/2,icon.size[0],icon.size[1]),ctx.restore()}else{const icon=document.createElement("img");this.options.icon=L.extend({rotate:0,size:[40,40],offset:{x:0,y:0}},this.options.icon),this.options.icon.rotate+=this.options.rotation,this.options.icon.element=icon,icon.src=this.options.icon.url,icon.onload=()=>this.redraw(),icon.onerror=()=>this.options.icon=null}if(this.options.label){let cx=p.x,cy=p.y;ctx.save(),ctx.font=this.options.font||'normal 7pt "Helvetica Neue", Arial, Helvetica, sans-serif',ctx.textAlign="center",ctx.textBaseline="middle",ctx.fillStyle=this.options.fillStyle||"black",this.options.rotation&&(ctx.translate(p.x,p.y),ctx.rotate(this.options.rotation),cx=0,cy=0),this._map.getZoom()>17&&(ctx.fillStyle=this.options.strokeStyle||"black"),ctx.fillText(this.options.label,cx,cy),this.options.strokeStyle&&this._map.getZoom()<=17&&(ctx.strokeStyle=this.options.strokeStyle,ctx.strokeText(this.options.label,cx,cy)),ctx.restore()}}}),L.DistanceMarkers=L.LayerGroup.extend({options:{cssClass:"dist-marker",iconSize:[12,12],arrowSize:[10,10],arrowUrl:"data:image/svg+xml,%3Csvg transform='rotate(90)' xmlns='http://www.w3.org/2000/svg' width='560px' height='560px' viewBox='0 0 560 560'%3E%3Cpath stroke-width='35' fill='%23000' stroke='%23FFF' d='M280,40L522,525L280,420L38,525z'/%3E%3C/svg%3E",offset:1e3,showAll:12,textFunction:(distance,i,offset)=>i,distance:!0,direction:!0},initialize:function(line,map,options){this._layers={},this._zoomLayers={},options=L.setOptions(this,options);let preferCanvas=map.options.preferCanvas,showAll=Math.min(map.getMaxZoom(),options.showAll);preferCanvas||map.options.rotate||console.warn('Missing dependency: "leaflet-rotate"');let coords="function"==typeof line.getLatLngs?line.getLatLngs():line;coords=L.LineUtil.isFlat(coords)?[coords]:coords,coords.forEach(latlngs=>{let accumulated=L.GeometryUtil.accumulatedLengths(latlngs),length=accumulated.length>0?accumulated[accumulated.length-1]:0;for(let i=1,count=Math.floor(length/options.offset),j=0;i<=count;++i){let distance=options.offset*i;for(;j<accumulated.length-1&&accumulated[j]<distance;)++j;let p1=latlngs[j-1],p2=latlngs[j],m_line=L.polyline([p1,p2]),ratio=(distance-accumulated[j-1])/(accumulated[j]-accumulated[j-1]),position=L.GeometryUtil.interpolateOnLine(map,m_line,ratio),delta=map.project(p2).subtract(map.project(p1)),angle=Math.atan2(delta.y,delta.x),text=options.textFunction.call(this,distance,i,options.offset),zoom=this._minimumZoomLevelForItem(i,showAll),markers=this._zoomLayers[zoom]=this._zoomLayers[zoom]||L.layerGroup();options.direction&&(options.distance&&i%2==1||!options.distance)&&(preferCanvas?markers.addLayer(new L.DistanceMarker(p1,{radius:0,icon:{url:options.arrowUrl,size:options.arrowSize,rotate:0,offset:{x:0,y:0}},rotation:angle,interactive:!1})):markers.addLayer(L.marker(position.latLng,{icon:L.icon({iconUrl:options.arrowUrl,iconSize:options.arrowSize}),rotation:angle,interactive:!1}))),options.distance&&i%2==0&&(preferCanvas?markers.addLayer(new L.DistanceMarker(position.latLng,{label:text,radius:7,fillColor:"#fff",fillOpacity:1,fillStyle:"black",color:"#777",weight:1,interactive:!1})):markers.addLayer(L.marker(position.latLng,{title:text,icon:L.divIcon({className:options.cssClass,html:text,iconSize:options.iconSize}),interactive:!1})))}});const updateMarkerVisibility=()=>{let oldZoom=this._lastZoomLevel||0,newZoom=map.getZoom();if(newZoom>oldZoom)for(let i=oldZoom+1;i<=newZoom;++i)void 0!==this._zoomLayers[i]&&this.addLayer(this._zoomLayers[i]);else if(newZoom<oldZoom)for(let i=oldZoom;i>newZoom;--i)void 0!==this._zoomLayers[i]&&this.removeLayer(this._zoomLayers[i]);this._lastZoomLevel=newZoom};map.on("zoomend",updateMarkerVisibility),updateMarkerVisibility()},_minimumZoomLevelForItem:function(i,zoom){for(;i>0&&i%2==0;)--zoom,i=Math.floor(i/2);return zoom}}),L.Polyline.include({_originalOnAdd:L.Polyline.prototype.onAdd,_originalOnRemove:L.Polyline.prototype.onRemove,addDistanceMarkers:function(){this._map&&this._distanceMarkers&&this._map.addLayer(this._distanceMarkers)},removeDistanceMarkers:function(){this._map&&this._distanceMarkers&&this._map.removeLayer(this._distanceMarkers)},onAdd:function(map){this._originalOnAdd(map);let opts=this.options.distanceMarkers||{};this.options.distanceMarkers&&(this._distanceMarkers=this._distanceMarkers||new L.DistanceMarkers(this,map,opts)),void 0!==opts.lazy&&!1!==opts.lazy||this.addDistanceMarkers()},onRemove:function(map){this.removeDistanceMarkers(),this._originalOnRemove(map)}}); \ No newline at end of file
+L.DistanceMarker=L.CircleMarker.extend({_updatePath(){let t=this._renderer._ctx,i=this._point;if(this.options.rotation=this.options.rotation||0,this.options.radius&&this._renderer._updateCircle&&this._renderer._updateCircle(this),this.options.icon&&this.options.icon.url)if(this.options.icon.element){const e=this.options.icon;let s=i.x+e.offset.x,h=i.y+e.offset.y;t.save(),e.rotate&&(t.translate(i.x,i.y),t.rotate(e.rotate),s=0,h=0),t.drawImage(e.element,s-e.size[0]/2,h-e.size[1]/2,e.size[0],e.size[1]),t.restore()}else{const e=document.createElement("img");this.options.icon=Object.assign({rotate:0,size:[40,40],offset:{x:0,y:0}},this.options.icon),this.options.icon.rotate+=this.options.rotation,this.options.icon.element=e,e.src=this.options.icon.url,e.onload=()=>this.redraw(),e.onerror=()=>this.options.icon=null}if(this.options.label){let e=i.x,s=i.y;t.save(),t.font=this.options.font||'normal 7pt "Helvetica Neue", Arial, Helvetica, sans-serif',t.textAlign="center",t.textBaseline="middle",t.fillStyle=this.options.fillStyle||"black",this.options.rotation&&(t.translate(i.x,i.y),t.rotate(this.options.rotation),e=0,s=0),this._map.getZoom()>17&&(t.fillStyle=this.options.strokeStyle||"black"),t.fillText(this.options.label,e,s),this.options.strokeStyle&&this._map.getZoom()<=17&&(t.strokeStyle=this.options.strokeStyle,t.strokeText(this.options.label,e,s)),t.restore()}}}),L.DistanceMarkers=L.LayerGroup.extend({options:{cssClass:"dist-marker",iconSize:[12,12],arrowSize:[10,10],arrowUrl:"data:image/svg+xml,%3Csvg transform='rotate(90)' xmlns='http://www.w3.org/2000/svg' width='560px' height='560px' viewBox='0 0 560 560'%3E%3Cpath stroke-width='35' fill='%23000' stroke='%23FFF' d='M280,40L522,525L280,420L38,525z'/%3E%3C/svg%3E",offset:1e3,showAll:12,textFunction:(t,i,e)=>i,distance:!0,direction:!0},initialize(t,i,e){this._layers={},this._zoomLayers={},e=L.Util.setOptions(this,e);let s=i.options.preferCanvas,h=Math.min(i.getMaxZoom(),e.showAll);!s&&!i.options.rotate&&console.warn('Missing dependency: "leaflet-rotate"');let c=typeof t.getLatLngs=="function"?t.getLatLngs():t;c=L.LineUtil.isFlat(c)?[c]:c,c.forEach(r=>{let n=0,o=r.map((a,d)=>(d&&(n+=r[d-1].distanceTo(a)),n)),S=o.length>0?o[o.length-1]:0;for(let a=1,d=Math.floor(S/e.offset),l=0;a<=d;++a){let y=e.offset*a;for(;l<o.length-1&&o[l]<y;)++l;let p=r[l-1],g=r[l],w=(y-o[l-1])/(o[l]-o[l-1]),f=i.project(p),x=i.project(g),_={latLng:i.unproject(new L.Point(f.x+(x.x-f.x)*w,f.y+(x.y-f.y)*w))},v=i.project(g).subtract(i.project(p)),M=Math.atan2(v.y,v.x),k=e.textFunction.call(this,y,a,e.offset),z=this._minimumZoomLevelForItem(a,h),m=this._zoomLayers[z]=this._zoomLayers[z]||new L.LayerGroup;e.direction&&(e.distance&&a%2==1||!e.distance)&&(s?m.addLayer(new L.DistanceMarker(p,{radius:0,icon:{url:e.arrowUrl,size:e.arrowSize,rotate:0,offset:{x:0,y:0}},rotation:M,interactive:!1})):m.addLayer(new L.Marker(_.latLng,{icon:new L.Icon({iconUrl:e.arrowUrl,iconSize:e.arrowSize}),rotation:M,interactive:!1}))),e.distance&&a%2==0&&(s?m.addLayer(new L.DistanceMarker(_.latLng,{label:k,radius:7,fillColor:"#fff",fillOpacity:1,fillStyle:"black",color:"#777",weight:1,interactive:!1})):m.addLayer(new L.Marker(_.latLng,{title:k,icon:new L.DivIcon({className:e.cssClass,html:k,iconSize:e.iconSize}),interactive:!1})))}});const u=()=>{let r=this._lastZoomLevel||0,n=i.getZoom();if(n>r)for(let o=r+1;o<=n;++o)this._zoomLayers[o]!==void 0&&this.addLayer(this._zoomLayers[o]);else if(n<r)for(let o=r;o>n;--o)this._zoomLayers[o]!==void 0&&this.removeLayer(this._zoomLayers[o]);this._lastZoomLevel=n};i.on("zoomend",u),u()},_minimumZoomLevelForItem(t,i){for(;t>0&&t%2===0;)--i,t=Math.floor(t/2);return i}}),L.Polyline.include({_originalOnAdd:L.Polyline.prototype.onAdd,_originalOnRemove:L.Polyline.prototype.onRemove,addDistanceMarkers(){this._map&&this._distanceMarkers&&this._map.addLayer(this._distanceMarkers)},removeDistanceMarkers(){this._map&&this._distanceMarkers&&this._map.removeLayer(this._distanceMarkers)},onAdd(t){this._originalOnAdd(t);let i=this.options.distanceMarkers||{};this.options.distanceMarkers&&(this._distanceMarkers=this._distanceMarkers||new L.DistanceMarkers(this,t,i)),(i.lazy===void 0||i.lazy===!1)&&this.addDistanceMarkers()},onRemove(t){this.removeDistanceMarkers(),this._originalOnRemove(t)}});