PageSourceSearch

https://www.ekmd.de/assetm/vendor/leaflet.locatecontrol/dist/L.Con…ate.esm-1c2053b9090aa738b1f03709b006e0e5.js

js ekmd.de collected 2026-10-09 22:40:10 UTC 12,774 bytes, 13 lines download raw bytes

1/**
2 * Bundled by jsDelivr using Rollup v2.79.2 and Terser v5.39.0.
3 * Original file: /npm/[email protected]/dist/L.Control.Locate.esm.js
4 *
5 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
6 */
7import{Marker as t,setOptions as i,divIcon as s,Control as o,DomUtil as e,extend as n,LayerGroup as a,DomEvent as h,Util as l,circle as r}from"leaflet";
8/*!
9Copyright (c) 2016 Dominik Moritz
10
11This file is part of the leaflet locate control. It is licensed under the MIT license.
12You can find the project at: https://github.com/domoritz/leaflet-locatecontrol
13*/const c=(t,i)=>{i.split(" ").forEach((i=>{t.classList.add(i)}))},p=(t,i)=>{i.split(" ").forEach((i=>{t.classList.remove(i)}))},_=t.extend({initialize(t,s){i(this,s),this._latlng=t,this.createIcon()},createIcon(){const t=this.options,i=[["stroke",t.color],["stroke-width",t.weight],["fill",t.fillColor],["fill-opacity",t.fillOpacity],["opacity",t.opacity]].filter((([t,i])=>void 0!==i)).map((([t,i])=>`${t}="${i}"`)).join(" "),o=this._getIconSVG(t,i);this._locationIcon=s({className:o.className,html:o.svg,iconSize:[o.w,o.h]}),this.setIcon(this._locationIcon)},_getIconSVG(t,i){const s=t.radius,o=s+t.weight,e=2*o;return{className:"leaflet-control-locate-location",svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${e}" version="1.1" viewBox="-${o} -${o} ${e} ${e}"><circle r="${s}" ${i} /></svg>`,w:e,h:e}},setStyle(t){i(this,t),this.createIcon()}}),d=_.extend({initialize(t,s,o){i(this,o),this._latlng=t,this._heading=s,this.createIcon()},setHeading(t){this._heading=t},_getIconSVG(t,i){const s=t.radius,o=t.width+t.weight,e=2*(s+t.depth+t.weight),n=`M0,0 l${t.width/2},${t.depth} l-${o},0 z`;return{className:"leaflet-control-locate-heading",svg:`<svg xmlns="http://www.w3.org/2000/svg" width="${o}" height="${e}" version="1.1" viewBox="-${o/2} 0 ${o} ${e}" transform="rotate(${this._heading})"><path d="${n}" ${i} /></svg>`,w:o,h:e}}}),m=o.extend({options:{position:"topleft",layer:void 0,setView:"untilPanOrZoom",keepCurrentZoomLevel:!1,initialZoomLevel:!1,getLocationBounds:t=>t.bounds,flyTo:!1,clickBehavior:{inView:"stop",outOfView:"setView",inViewNotFollowing:"inView"},returnToPrevBounds:!1,cacheLocation:!0,drawCircle:!0,drawMarker:!0,showCompass:!0,markerClass:_,compassClass:d,circleStyle:{className:"leaflet-control-locate-circle",color:"#136AEC",fillColor:"#136AEC",fillOpacity:.15,weight:0},markerStyle:{className:"leaflet-control-locate-marker",color:"#fff",fillColor:"#2A93EE",fillOpacity:1,weight:3,opacity:1,radius:9},compassStyle:{fillColor:"#2A93EE",fillOpacity:1,weight:0,color:"#fff",opacity:1,radius:9,width:9,depth:6},followCircleStyle:{},followMarkerStyle:{},followCompassStyle:{},icon:"leaflet-control-locate-location-arrow",iconLoading:"leaflet-control-locate-spinner",iconElementTag:"span",textElementTag:"small",circlePadding:[0,0],metric:!0,createButtonCallback(t,i){const s=e.create("a","leaflet-bar-part leaflet-bar-part-single",t);s.title=i.strings.title,s.href="#",s.setAttribute("role","button");const o=e.create(i.iconElementTag,i.icon,s);if(void 0!==i.strings.text){e.create(i.textElementTag,"leaflet-locate-text",s).textContent=i.strings.text,s.classList.add("leaflet-locate-text-active"),s.parentNode.style.display="flex",i.icon.length>0&&o.classList.add("leaflet-locate-icon")}return{link:s,icon:o}},onLocationError(t,i){alert(t.message)},onLocationOutsideMapBounds(t){t.stop(),alert(t.options.strings.outsideMapBoundsMsg)},showPopup:!0,strings:{title:"Show me where I am",metersUnit:"meters",feetUnit:"feet",popup:"You are within {distance} {unit} from this point",outsideMapBoundsMsg:"You seem located outside the boundaries of the map"},locateOptions:{maxZoom:1/0,watch:!0,setView:!1}},initialize(t){for(const i in t)"object"==typeof this.options[i]?n(this.options[i],t[i]):this.options[i]=t[i];this.options.followMarkerStyle=n({},this.options.markerStyle,this.options.followMarkerStyle),this.options.followCircleStyle=n({},this.options.circleStyle,this.options.followCircleStyle),this.options.followCompassStyle=n({},this.options.compassStyle,this.options.followCompassStyle)},onAdd(t){const i=e.create("div","leaflet-control-locate leaflet-bar leaflet-control");this._container=i,this._map=t,this._layer=this.options.layer||new a,this._layer.addTo(t),this._event=void 0,this._compassHeading=null,this._prevBounds=null;const s=this.options.createButtonCallback(i,this.options);return this._link=s.link,this._icon=s.icon,h.on(this._link,"click",(function(t){h.stopPropagation(t),h.preventDefault(t),this._onClick()}),this).on(this._link,"dblclick",h.stopPropagation),this._resetVariables(),this._map.on("unload",this._unload,this),i},_onClick(){this._justClicked=!0;const t=this._isFollowing();if(this._userPanned=!1,this._userZoomed=!1,this._active&&!this._event)this.stop();else if(this._active){const i=this.options.clickBehavior;let s=i.outOfView;switch(this._map.getBounds().contains(this._event.latlng)&&(s=t?i.inView:i.inViewNotFollowing),i[s]&&(s=i[s]),s){case"setView":this.setView();break;case"stop":if(this.stop(),this.options.returnToPrevBounds){(this.options.flyTo?this._map.flyToBounds:this._map.fitBounds).bind(this._map)(this._prevBounds)}}}else this.options.returnToPrevBounds&&(this._prevBounds=this._map.getBounds()),this.start();this._updateContainerStyle()},start(){this._activate(),this._event&&(this._drawMarker(this._map),this.options.setView&&this.setView()),this._updateContainerStyle()}
13,stop(){this._deactivate(),this._cleanClasses(),this._resetVariables(),this._removeMarker()},stopFollowing(){this._userPanned=!0,this._updateContainerStyle(),this._drawMarker()},_activate(){if(!this._active&&this._map&&(this._map.locate(this.options.locateOptions),this._map.fire("locateactivate",this),this._active=!0,this._map.on("locationfound",this._onLocationFound,this),this._map.on("locationerror",this._onLocationError,this),this._map.on("dragstart",this._onDrag,this),this._map.on("zoomstart",this._onZoom,this),this._map.on("zoomend",this._onZoomEnd,this),this.options.showCompass)){const t="ondeviceorientationabsolute"in window;if(t||"ondeviceorientation"in window){const i=this,s=function(){h.on(window,t?"deviceorientationabsolute":"deviceorientation",i._onDeviceOrientation,i)};DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(t){"granted"===t&&s()})):s()}}},_deactivate(){this._active&&this._map&&(this._map.stopLocate(),this._map.fire("locatedeactivate",this),this._active=!1,this.options.cacheLocation||(this._event=void 0),this._map.off("locationfound",this._onLocationFound,this),this._map.off("locationerror",this._onLocationError,this),this._map.off("dragstart",this._onDrag,this),this._map.off("zoomstart",this._onZoom,this),this._map.off("zoomend",this._onZoomEnd,this),this.options.showCompass&&(this._compassHeading=null,"ondeviceorientationabsolute"in window?h.off(window,"deviceorientationabsolute",this._onDeviceOrientation,this):"ondeviceorientation"in window&&h.off(window,"deviceorientation",this._onDeviceOrientation,this)))},setView(){if(this._drawMarker(),this._isOutsideMapBounds())this._event=void 0,this.options.onLocationOutsideMapBounds(this);else if(this._justClicked&&!1!==this.options.initialZoomLevel){(this.options.flyTo?this._map.flyTo:this._map.setVie
13w).bind(this._map)([this._event.latitude,this._event.longitude],this.options.initialZoomLevel)}else if(this.options.keepCurrentZoomLevel){(this.options.flyTo?this._map.flyTo:this._map.panTo).bind(this._map)([this._event.latitude,this._event.longitude])}else{let t=this.options.flyTo?this._map.flyToBounds:this._map.fitBounds;this._ignoreEvent=!0,t.bind(this._map)(this.options.getLocationBounds(this._event),{padding:this.options.circlePadding,maxZoom:this.options.initialZoomLevel||this.options.locateOptions.maxZoom}),l.requestAnimFrame((function(){this._ignoreEvent=!1}),this)}},_drawCompass(){if(!this._event)return;const t=this._event.latlng;if(this.options.showCompass&&t&&null!==this._compassHeading){const i=this._isFollowing()?this.options.followCompassStyle:this.options.compassStyle;this._compass?(this._compass.setLatLng(t),this._compass.setHeading(this._compassHeading),this._compass.setStyle&&this._compass.setStyle(i)):this._compass=new this.options.compassClass(t,this._compassHeading,i).addTo(this._layer)}!this._compass||this.options.showCompass&&null!==this._compassHeading||(this._compass.removeFrom(this._layer),this._compass=null)},_drawMarker(){void 0===this._event.accuracy&&(this._event.accuracy=0);const t=this._event.accuracy,i=this._event.latlng;if(this.options.drawCircle){const s=this._isFollowing()?this.options.followCircleStyle:this.options.circleStyle;this._circle?this._circle.setLatLng(i).setRadius(t).setStyle(s):this._circle=r(i,t,s).addTo(this._layer)}let s,o;if(this.options.metric?(s=t.toFixed(0),o=this.options.strings.metersUnit):(s=(3.2808399*t).toFixed(0),o=this.options.strings.feetUnit),this.options.drawMarker){const t=this._isFollowing()?this.options.followMarkerStyle:this.options.markerStyle;this._marker?(this._marker.setLatLng(i),this._marker.setStyle&&this._marker.setStyle(t)):this._marker=new this.options.markerClass(i,t).addTo(this._layer)}this._drawCompass();const e=this.options.strings.popup;function n(){return"string"==typeof e?l.template(e,{distance:s,unit:o}):"function"==typeof e?e({distance:s,unit:o}):e}this.options.showPopup&&e&&this._marker&&this._marker.bindPopup(n())._popup.setLatLng(i),this.options.showPopup&&e&&this._compass&&this._compass.bindPopup(n())._popup.setLatLng(i)},_removeMarker(){this._layer.clearLayers(),this._marker=void 0,this._circle=void 0},_unload(){this.stop(),this._map&&this._map.off("unload",this._unload,this)},_setCompassHeading(t){!isNaN(parseFloat(t))&&isFinite(t)?(t=Math.round(t),this._compassHeading=t,l.requestAnimFrame(this._drawCompass,this)):this._compassHeading=null},_onCompassNeedsCalibration(){this._setCompassHeading()},_onDeviceOrientation(t){this._active&&(t.webkitCompassHeading?this._setCompassHeading(t.webkitCompassHeading):t.absolute&&t.alpha&&this._setCompassHeading(360-t.alpha))},_onLocationError(t){3==t.code&&this.options.locateOptions.watch||(this.stop(),this.options.onLocationError(t,this))},_onLocationFound(t){if((!this._event||this._event.latlng.lat!==t.latlng.lat||this._event.latlng.lng!==t.latlng.lng||this._event.accuracy!==t.accuracy)&&this._active){switch(this._event=t,this._drawMarker(),this._updateContainerStyle(),this.options.setView){case"once":this._justClicked&&this.setView();break;case"untilPan":this._userPanned||this.setView();break;case"untilPanOrZoom":this._userPanned||this._userZoomed||this.setView();break;case"always":this.setView()}this._justClicked=!1}},_onDrag(){this._event&&!this._ignoreEvent&&(this._userPanned=!0,this._updateContainerStyle(),this._drawMarker())},_onZoom(){this._event&&!this._ignoreEvent&&(this._userZoomed=!0,this._updateContainerStyle(),this._drawMarker())},_onZoomEnd(){this._event&&this._drawCompass(),this._event&&!this._ignoreEvent&&this._marker&&!this._map.getBounds().pad(-.3).contains(this._marker.getLatLng())&&(this._userPanned=!0,this._updateContainerStyle(),this._drawMarker())},_isFollowing(){return!!this._active&&("always"===this.options.setView||("untilPan"===this.options.setView?!this._userPanned:"untilPanOrZoom"===this.options.setView?!this._userPanned&&!this._userZoomed:void 0))},_isOutsideMapBounds(){return void 0!==this._event&&(this._map.options.maxBounds&&!this._map.options.maxBounds.contains(this._event.latlng))},_updateContainerStyle(){this._container&&(this._active&&!this._event?this._setClasses("requesting"):this._isFollowing()?this._setClasses("following"):this._active?this._setClasses("active"):this._cleanClasse
13s())},_setClasses(t){"requesting"==t?(p(this._container,"active following"),c(this._container,"requesting"),p(this._icon,this.options.icon),c(this._icon,this.options.iconLoading)):"active"==t?(p(this._container,"requesting following"),c(this._container,"active"),p(this._icon,this.options.iconLoading),c(this._icon,this.options.icon)):"following"==t&&(p(this._container,"requesting"),c(this._container,"active following"),p(this._icon,this.options.iconLoading),c(this._icon,this.options.icon))},_cleanClasses(){e.removeClass(this._container,"requesting"),e.removeClass(this._container,"active"),e.removeClass(this._container,"following"),p(this._icon,this.options.iconLoading),c(this._icon,this.options.icon)},_resetVariables(){this._active=!1,this._justClicked=!1,this._userPanned=!1,this._userZoomed=!1}});function u(t){return new m(t)}export{d as CompassMarker,m as LocateControl,_ as LocationMarker,u as locate};export default null;

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.