@nextgis/leaflet-map-adapter 3.0.0-alpha.20 → 3.0.0-alpha.21
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/lib/leaflet-map-adapter.esm-browser.js +3 -12
- package/lib/leaflet-map-adapter.esm-browser.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-browser.prod.js +1 -1
- package/lib/leaflet-map-adapter.esm-browser.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.js +4 -13
- package/lib/leaflet-map-adapter.esm-bundler.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.prod.js +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.global.js +3 -12
- package/lib/leaflet-map-adapter.global.js.map +1 -1
- package/lib/leaflet-map-adapter.global.prod.js +1 -1
- package/lib/leaflet-map-adapter.global.prod.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{EventEmitter as t}from"events";import{Control as e,DomEvent as s,GeoJSON as o,DivIcon as i,Marker as r,CircleMarker as n,FeatureGroup as a,ImageOverlay as l,Layer as p,Util as c,CRS as h,GridLayer as u,DomUtil as d,TileLayer as m,Map as y,latLngBounds as f,latLng as v}from"leaflet";import{defined as _,debounce as b,isObject as g,updateUrlParams as O}from"@nextgis/utils";import{isPaintCallback as P,isPaint as w}from"@nextgis/paint";import L from"@nextgis/queue";function C(t,o={},i){return new(e.extend({onAdd(){const e=document.createElement("div"),r=t.onAdd(i);return e.classList.add("leaflet-control"),o.bar&&e.classList.add("leaflet-bar"),o.addClass&&e.classList.add(o.addClass),o.margin||o.bar||(e.style.marginBottom="0px",e.style.marginTop="0px",e.style.marginLeft="0px",e.style.marginRight="0px"),r&&e.appendChild(r),s.disableClickPropagation(e),e},onRemove(){t.onRemove()}}))}function x(t){const e=t.getNorthEast(),s=t.getSouthWest();return[s.lng,s.lat,e.lng,e.lat]}function j(t){const e={};for(let o=0;o<t.length;o++)e[t[o]]=1+(e[t[o]]||0);let s="";for(const o in e){e[o]>(s?e[s]:0)&&(s=o)}return s}const M={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon",GeometryCollection:"polygon"},k={stroke:!1,opacity:1},S={};for(const _e in M){const t=M[_e],e=S[t]||[];e.push(_e),S[t]=e}function E(t,e){return-1!==(S[e]||[]).indexOf(t)}function Z(t){const e=new o;return(Array.isArray(t)?t:[t]).forEach((t=>e.addData(t))),e.getBounds()}function T(t){return{getBounds:()=>function(t){return x(Z(t))}(t),getCenter:()=>function(t){const{lat:e,lng:s}=Z(t).getCenter();return[s,e]}(t)}}var B=Object.defineProperty,z=(t,e,s)=>((t,e,s)=>e in t?B(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);class I{constructor(t,e){if(this.map=t,this.options=e,z(this,"layer"),z(this,"pane","order-0"),void 0!==e.order){const s="order-"+e.order;let o=t.getPane(s);o||(o=t.createPane(s)),o.style.zIndex=String(Math.round(100*e.order)),this.pane=s}}addLayer(t){Object.assign(this.options,t)}}function A(t){const e=t.containerPoint,s=t.latlng,{lat:o,lng:i}=s;return{latLng:s,lngLat:[i,o],pixel:{left:e.x,top:e.y},source:t}}var F=Object.defineProperty,U=Object.getOwnPropertySymbols,D=Object.prototype.hasOwnProperty,W=Object.prototype.propertyIsEnumerable,R=(t,e,s)=>e in t?F(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;function N({layer:t,source:e}){const s=e.target.feature;return((t,e)=>{for(var s in e||(e={}))D.call(e,s)&&R(t,s,e[s]);if(U)for(var s of U(e))W.call(e,s)&&R(t,s,e[s]);return t})({layer:t,feature:s,event:A(e),source:e},T(s))}var V=Object.defineProperty,$=Object.getOwnPropertySymbols,G=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable,q=(t,e,s)=>e in t?V(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,J=(t,e)=>{for(var s in e||(e={}))G.call(e,s)&&q(t,s,e[s]);if($)for(var s of $(e))H.call(e,s)&&q(t,s,e[s]);return t},X=(t,e,s)=>q(t,"symbol"!=typeof e?e+"":e,s);class K{constructor(t){X(this,"layer"),X(this,"_onclick"),X(this,"_ondblclick"),X(this,"_mouseout"),X(this,"_mouseover"),this.layer=t}handleMouseEvents(t){const{onClick:e,onDoubleClick:o,onLayerClick:i,onMouseOut:r,onMouseOver:n}=this.layer.options,a=e||i;a&&(this._onclick=e=>{const s=!!this.layer._getSelected(t);a(J({selected:s},this._createMouseEvent(e)))},t.on("click",this._onclick,this)),o&&(this._ondblclick=e=>{s.stopPropagation(e);const i=!!this.layer._getSelected(t);o(J({selected:i},this._createMouseEvent(e)))},t.on("dblclick",this._ondblclick,this)),r&&(this._mouseout=t=>{r(this._createMouseEvent(t))},t.on("mouseout",this._mouseout,this)),n&&(this._mouseover=t=>{n(this._createMouseEvent(t))},t.on("mouseover",this._mouseover,this))}stopMouseEvents(t){this._mouseover&&t.off("mouseover",this._mouseover,this),this._mouseout&&t.off("mouseout",this._mouseout,this),this._onclick&&t.off("click",this._onclick,this)}_createMouseEvent(t){return N({layer:this.layer,source:t})}}var Q=Object.defineProperty,Y=Object.defineProperties,tt=Object.getOwnPropertyDescriptors,et=Object.getOwnPropertySymbols,st=Object.prototype.hasOwnProperty,ot=Object.prototype.propertyIsEnumerable,it=(t,e,s)=>e in t?Q(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,rt=(t,e)=>{for(var s in e||(e={}))st.call(e,s)&&it(t,s,e[s]);if(et)for(var s of et(e))ot.call(e,s)&&it(t,s,e[s]);return t};class nt{constructor(t){var e;it(this,"layer"+"",e),this.layer=t}setPaintEachLayer(t){this.layer._layers.forEach((e=>{this.setPaint(e,t)}))}setPaint(t,e){let s;const{layer:o,feature:i}=t;if(o&&i&&(P(e)?s=e(i):w(e)&&(s=e),s))if("point"===this.layer.type&&"icon"===s.type){const t=o,e=this._createDivIcon(s);setTimeout((()=>{t.setIcon(e)}),10)}else"setStyle"in o&&o.setStyle(this.preparePaint(s))}preparePaint(t){if("get-paint"!==t.type){const e="line"===this.layer.type?[["color","strokeColor"],["opacity","strokeOpacity"],["weight","weight"]]:[["color","strokeColor"],["opacity","strokeOpacity"],["stroke","stroke"],["fillColor","fillColor"],["fillOpacity","fillOpacity"],["fill","fill"],["weight","weight"]],s={};"radius"in t&&"number"==typeof t.radius&&(s.radius=t.radius);for(const[o,i]of e){const e=this.layer.options.opacity;let r=t[i];_(e)&&-1!==i.toLowerCase().indexOf("opacity")&&(r=Number(r)*e),void 0!==r&&Object.defineProperty(s,o,{enumerable:!0,value:r})}return s}return k}_createDivIcon(t){const e=t,{html:s,rotate:o,className:r}=e,n=((t,e)=>{var s={};for(var o in t)st.call(t,o)&&e.indexOf(o)<0&&(s[o]=t[o]);if(null!=t&&et)for(var o of et(t))e.indexOf(o)<0&&ot.call(t,o)&&(s[o]=t[o]);return s})(e,["html","rotate","className"]),a=document.createElement("div");r&&(a.className=r),o&&(a.style.transform=`rotateZ(${o}deg)`),s&&(a.innerHTML=s);var l;return new i((l=rt({className:""},n),Y(l,tt({html:a}))))}createPaintToLayer(t){if(t&&t.type)if("icon"===t.type){if(t.className||t.html)return(e,s)=>{const o=this._createDivIcon(t);return new r(s,{icon:o})}}else if("pin"===t.type)return(t,e)=>new r(e);return(e,s)=>new n(s,this.preparePaint(rt(rt({},k),t)))}createPaintOptions(t){const e={},s=this.preparePaint(t);return t&&(e.style=()=>s),"point"===this.layer.type?e.pointToLayer=this.createPaintToLayer(t):"line"===this.layer.type&&(s.stroke=!0),e}}var at=Object.defineProperty,lt=Object.defineProperties,pt=Object.getOwnPropertyDescriptors,ct=Object.getOwnPropertySymbols,ht=Object.prototype.hasOwnProperty,ut=Object.prototype.propertyIsEnumerable,dt=(t,e,s)=>e in t?at(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,mt=(t,e)=>{for(var s in e||(e={}))ht.call(e,s)&&dt(t,s,e[s]);if(ct)for(var s of ct(e))ut.call(e,s)&&dt(t,s,e[s]);return t},yt=(t,e)=>lt(t,pt(e)),ft=(t,e,s)=>dt(t,"symbol"!=typeof e?e+"":e,s);function vt({src:t,headers:e,withCredentials:s}){let o=()=>{};return[new Promise(((i,r)=>{const n=new XMLHttpRequest;n.open("GET",t),n.responseType="arraybuffer";for(const t in e)n.setRequestHeader(t,e[t]);s&&(n.withCredentials=s),n.onload=function(){const t=new Uint8Array(this.response),e=new Blob([t],{type:"image/png"}),s=(window.URL||window.webkitURL).createObjectURL(e);i(s)},n.onerror=r,n.send(),o=()=>{n.abort(),i("")}})),o]}const _t=new L({concurrency:6,delay:200});var bt=Object.defineProperty,gt=(t,e,s)=>((t,e,s)=>e in t?bt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);class Ot extends l{constructor(t,e,s){super(t,e,s),gt(this,"_aborter")}cancelLoad(){this._aborter&&(this._aborter(),this._aborter=void 0)}_initImage(){super._initImage();const{headers:t,withCredentials:e}=this.options,s=this._image,o=s.src;s.src="",_t.add((()=>{const[i,r]=vt({src:o,headers:t,withCredentials:e});return i.then((t=>{s.src=t})),this._aborter=r,i}))}}var Pt=Object.defineProperty,wt=(t,e,s)=>((t,e,s)=>e in t?Pt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);class Lt extends p{constructor(t,e){super(e),wt(this,"defaultWmsParams",{service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1}),wt(this,"options",{crs:null,uppercase:!1,attribution:"",opacity:1,isBack:!1,minZoom:0,maxZoom:void 0,pane:"tilePane",headers:null,withCredentials:!1,viewPortBuffer:0,setViewDelay:100}),wt(this,"wmsParams"),wt(this,"_url"),wt(this,"_currentUrl"),wt(this,"_currentOverlay"),wt(this,"_loadedOverlay"),this._url=t;const s={},o={};let i;for(i in e){i in this.options&&(o[i]=e[i])}if(e.params)for(const r in e.params){const t=e.params[r];g(t)||Array.isArray(t)||"function"==typeof t||(s[r]=t)}c.setOptions(this,o),this.wmsParams=c.extend({},this.defaultWmsParams,s)}setParams(t){c.extend(this.wmsParams,t),this.update()}getAttribution(){return this.options.attribution||""}onAdd(){return this.update(),this}onRemove(t){return this._currentOverlay&&(this._currentOverlay.cancelLoad(),t.removeLayer(this._currentOverlay),delete this._currentOverlay),this._currentUrl&&delete this._currentUrl,this}getEvents(){return{moveend:b(this.update,this.options.setViewDelay)}}update(){if(!this._map)return;this.updateWmsParams();const t=this.getImageUrl();if(this._currentUrl===t)return;this._currentUrl=t;const e=this.options.viewPortBuffer||0,s=this._map.getBounds().pad(e);this._loadedOverlay&&(this._loadedOverlay.cancelLoad(),this._loadedOverlay.off("load"),this._loadedOverlay=void 0);const o=new Ot(t,s,{opacity:0,pane:this.options.pane,headers:this.options.headers,withCredentials:this.options.withCredentials});o.addTo(this._map),this._loadedOverlay=o,o.once("load",(()=>{this._map&&(o._url===this._currentUrl?(this._currentOverlay&&this._map.removeLayer(this._currentOverlay),this._loadedOverlay=void 0,this._currentOverlay=o,o.setOpacity(void 0!==this.options.opacity?this.options.opacity:1),!0===this.options.isBack&&o.bringToBack(),!1===this.options.isBack&&o.bringToFront(),void 0!==this.options.zIndex&&o.setZIndex(this.options.zIndex)):this._map.removeLayer(o))}),this);const{minZoom:i,maxZoom:r}=this.options;(i&&this._map.getZoom()<i||r&&this._map.getZoom()>r)&&this._map.removeLayer(o)}setOpacity(t){this.options.opacity=t,this._currentOverlay&&this._currentOverlay.setOpacity(t)}bringToBack(){this.options.isBack=!0,this._currentOverlay&&this._currentOverlay.bringToBack()}bringToFront(){this.options.isBack=!1,this._currentOverlay&&this._currentOverlay.bringToFront()}setZIndex(t){this.options.zIndex=t,this._currentOverlay&&this._currentOverlay.setZIndex(t)}updateWmsParams(t){t||(t=this._map);const e=this.options.viewPortBuffer||0,s=t.getBounds().pad(e),o=t.getSize();if(0!==this.options.viewPortBuffer){const t=e+1;o.x=Math.ceil(o.x*t),o.y=Math.ceil(o.y*t)}const i=parseFloat(this.wmsParams.version),r=this.options.crs||t.options.crs,n=i>=1.3?"crs":"srs";if(r){const t=r.project(s.getNorthWest()),e=r.project(s.getSouthEast()),a={width:o.x,height:o.y};a[n]=r.code,a.bbox=(i>=1.3&&r===h.EPSG4326?[e.y,t.x,t.y,e.x]:[t.x,e.y,e.x,t.y]).join(","),c.extend(this.wmsParams,a)}}getImageUrl(){const t=c.getParamString(this.wmsParams,this._url,this.options.uppercase||!1);return this._url+t}}var Ct=Object.defineProperty,xt=Object.defineProperties,jt=Object.getOwnPropertyDescriptors,Mt=Object.getOwnPropertySymbols,kt=Object.prototype.hasOwnProperty,St=Object.prototype.propertyIsEnumerable,Et=(t,e,s)=>e in t?Ct(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Zt=(t,e)=>{for(var s in e||(e={}))kt.call(e,s)&&Et(t,s,e[s]);if(Mt)for(var s of Mt(e))St.call(e,s)&&Et(t,s,e[s]);return t},Tt=(t,e,s)=>Et(t,"symbol"!=typeof e?e+"":e,s);class Bt extends I{constructor(){super(...arguments),Tt(this,"layer")}addLayer(t){var e;const s=t&&t.url;if(s){const r=t.updateWmsParams;if(this.layer=new Lt(s,Zt(Zt(Zt({pane:this.pane,headers:t.headers,setViewDelay:t.setViewDelay},(o=Zt({transparent:!0},t),i={opacity:null!=(e=t.opacity)?e:void 0},xt(o,jt(i)))),t.params),t.nativeOptions)),r){const t=this.layer.updateWmsParams;this.layer.updateWmsParams=function(e){t.call(this,e),this.wmsParams=r(this.wmsParams)}}return this.layer}var o,i}updateLayer(t){if(this.layer){c.extend(this.layer.wmsParams,(null==t?void 0:t.params)||{}),this.layer.update()}}}function zt(t){return class extends t{constructor(...t){super(...t),this.options.setViewDelay&&(this._update=function(t,e=10){let s;function o(...i){o.clear(),s=setTimeout((()=>{s=null,t.apply(this,i)}),e)}return o.clear=function(){s&&(clearTimeout(s),s=null)},o}(((...t)=>{u.prototype._update.call(this,...t)}),this.options.setViewDelay))}createTile(t,e){const s=this.getTileUrl(t),o=document.createElement("img"),[i,r]=vt({src:s,withCredentials:this.options.withCredentials,headers:this.options.headers});return i.then((t=>{o.src=t,e(null,o)})),o.abort=r,(this.options.crossOrigin||""===this.options.crossOrigin)&&(o.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),o.alt="",o.setAttribute("role","presentation"),o}_abortLoading(){const t=this._tiles,e=this._tileZoom;for(const s in t)if(t[s].coords.z!==e){const e=t[s].el;e.onload=c.falseFn,e.onerror=c.falseFn,e.complete||(e.abort&&e.abort(),e.src=c.emptyImageUrl,d.remove(e),delete t[s])}}}}Tt(Bt,"queue",_t);const It=zt(class extends m{constructor(t,e){super(t,e),Object.assign(this.options,e)}});var At=Object.defineProperty,Ft=Object.defineProperties,Ut=Object.getOwnPropertyDescriptors,Dt=Object.getOwnPropertySymbols,Wt=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,Nt=(t,e,s)=>e in t?At(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Vt=(t,e)=>{for(var s in e||(e={}))Wt.call(e,s)&&Nt(t,s,e[s]);if(Dt)for(var s of Dt(e))Rt.call(e,s)&&Nt(t,s,e[s]);return t};class $t extends I{addLayer(t){if(this.options=Object.assign(this.options,t),t){const s=t,{url:o}=s,i=((t,e)=>{var s={};for(var o in t)Wt.call(t,o)&&e.indexOf(o)<0&&(s[o]=t[o]);if(null!=t&&Dt)for(var o of Dt(t))e.indexOf(o)<0&&Rt.call(t,o)&&(s[o]=t[o]);return s})(s,["url"]);if(o){const t=Vt({pane:this.pane,attribution:i.attribution,minZoom:i.minZoom,maxZoom:i.maxZoom},i.nativeOptions);let s;return i.subdomains&&(t.subdomains=i.subdomains),s=i.headers||i.withCredentials?new It(o,(e=Vt({},t),Ft(e,Ut({headers:i.headers,withCredentials:i.withCredentials,setViewDelay:i.setViewDelay})))):new m(o,t),s}}var e}updateLayer(t){if(this.layer){(null==t?void 0:t.params)&&this.layer.setUrl(O(this.layer._url,t.params)),this.layer.redraw()}}}var Gt=Object.defineProperty,Ht=Object.defineProperties,qt=Object.getOwnPropertyDescriptors,Jt=Object.getOwnPropertySymbols,Xt=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable,Qt=(t,e,s)=>e in t?Gt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;const Yt=zt(class extends m.WMS{constructor(t,e){super(t,e)}});var te=Object.defineProperty,ee=Object.defineProperties,se=Object.getOwnPropertyDescriptors,oe=Object.getOwnPropertySymbols,ie=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable,ne=(t,e,s)=>e in t?te(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ae=(t,e)=>{for(var s in e||(e={}))ie.call(e,s)&&ne(t,s,e[s]);if(oe)for(var s of oe(e))re.call(e,s)&&ne(t,s,e[s]);return t};function le(t){return[[t[3],t[0]],[t[1],t[2]]]}var pe=Object.defineProperty,ce=Object.getOwnPropertySymbols,he=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable,de=(t,e,s)=>e in t?pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,me=(t,e)=>{for(var s in e||(e={}))he.call(e,s)&&de(t,s,e[s]);if(ce)for(var s of ce(e))ue.call(e,s)&&de(t,s,e[s]);return t},ye=(t,e,s)=>de(t,"symbol"!=typeof e?e+"":e,s);const fe=class e{constructor(){ye(this,"options",{target:"map"}),ye(this,"layerAdapters",e.layerAdapters),ye(this,"controlAdapters",e.controlAdapters),ye(this,"emitter",new t),ye(this,"map"),ye(this,"_resizeObserver"),ye(this,"_unselectCb",[]),ye(this,"_universalEvents",["move","zoom","zoomend","zoomstart","moveend","movestart"]),ye(this,"_positionEvents",["mousemove","mouseout","mouseover"])}create(t){if(this.options=me({},t),this.options.target){const{zoom:t,center:e,maxZoom:s,minZoom:o,maxBounds:i,mapAdapterOptions:r}=this.options;this.map=this.options.map||new y(this.options.target,me({attributionControl:!1,zoomControl:!1,maxBounds:i?le(i):void 0,maxZoom:s,minZoom:o,center:e&&[e[1],e[0]],zoom:t},r)),this._updateMinZoomForBounds(o),this._watchSizeChangeToUpdateMinZoom();const n=this.map.createPane("order-0");this.map._addUnselectCb=t=>{this._addUnselectCb(t)},n.style.zIndex=String(0),this.emitter.emit("create",this),this._addMapListeners()}}destroy(){this.map&&this.map.remove(),this._stopWatchSizeChangeToUpdateMinZoom()}getContainer(){return this.map&&this.map.getContainer()}getControlContainer(){const t=this.map&&this.map._controlContainer;if(t)return t;throw new Error("Leaflet Map is not initialized yet")}setCursor(t){this.map&&(this.map.getContainer().style.cursor=t)}setView(t,e){const s=this.map;if(s)if(Array.isArray(t)){const s=t,[o,i]=s;this.map&&("number"==typeof e?this.map.setView([i,o],e,{animate:!1}):this.setCenter([o,i]))}else{const{zoom:e,center:o,maxBounds:i,bounds:r,minZoom:n,maxZoom:a}=t;if(o&&void 0!==e?this.setView(o,e):(void 0!==e&&this.setZoom(e),o&&this.setCenter(o)),r&&this.fitBounds(r),void 0!==i)if(i){const t=le(i);s.setMaxBounds(t),this._updateMinZoomForBounds()}else s.setMaxBounds(null),this._updateMinZoomForBounds();void 0!==a&&s.setMaxZoom(a),void 0!==n&&this._updateMinZoomForBounds(n)}}setCenter(t){const[e,s]=t;this.map&&this.map.panTo([s,e])}getCenter(){const t=this.map;if(t){const e=t.getBounds().getCenter();return[e.lng,e.lat]}}setZoom(t){this.map&&this.map.setZoom(t)}getZoom(){var t;return null!=(t=this.map&&this.map.getZoom())?t:void 0}getBounds(){if(!this.map)return;const t=this.map.getBounds(),e=t.getSouthWest(),s=t.getNorthEast();return[e.lng,e.lat,s.lng,s.lat]}fitBounds(t,e={}){if(this.map){const{maxZoom:s,offset:o,padding:i}=e,r={};s&&(r.maxZoom=s),i&&(r.padding=[i,i]),o&&(r.padding=o),this.map.fitBounds(le(t),r)}}getLayerAdapter(t){return e.layerAdapters[t]}createControl(t,e){return C(t,e,this)}createButtonControl(t){return function(t,e){const o=document.createElement("a"),i=t.title||"";o.href="#",o.title=i,o.setAttribute("role","button"),o.setAttribute("aria-label",i),t.addClass&&o.classList.add(t.addClass),s.disableClickPropagation(o),s.on(o,"click",s.stop),t.html instanceof HTMLElement?o.appendChild(t.html):"string"==typeof t.html&&(o.innerHTML=t.html);const r=e=>{e.stopPropagation(),t.onClick()};return C({onAdd:()=>(void 0!==t.onClick&&o.addEventListener("click",r),o),onRemove(){const e=o.parentNode;e&&e.removeChild(o),void 0!==t.onClick&&o.removeEventListener("click",r)}},{bar:!0},e)}(t,this)}addControl(t,e){if(t.options.position=e.replace("-",""),this.map)return this.map.addControl(t),t}removeControl(t){this.map&&this.map.removeControl(t)}removeLayer(t){t&&t.remove&&t.remove()}showLayer(t){this.map&&t.addTo(this.map)}hideLayer(t){t.remove()}setLayerOpacity(t,e){"setOpacity"in t&&t.setOpacity(e)}setLayerOrder(t,e,s){}onMapClick(t){const e=A(t);this.emitter.emit("preclick",e),this.emitter.emit("click",e)}locate(t,e){const s=this.map;if(s&&(s.locate(t),e)){const{locationfound:t,locationerror:o}=e,i=e=>{t({lngLat:[e.latlng.lng,e.latlng.lat]})};void 0!==t&&s.on("locationfound",i,this),o&&s.on("locationerror",o,this);return{stop:()=>{void 0!==t&&s.off("locationfound",i),o&&s.off("locationerror",o)}}}return{stop:()=>{}}}_addUnselectCb(t){for(const e of this._unselectCb)e();this._unselectCb.length=0,this._unselectCb.push(t)}_watchSizeChangeToUpdateMinZoom(){this._stopWatchSizeChangeToUpdateMinZoom();const t=this.getContainer();t&&this.map&&window.ResizeObserver&&(this._resizeObserver=new ResizeObserver((()=>{this._updateMinZoomForBounds()})),this._resizeObserver.observe(t))}_stopWatchSizeChangeToUpdateMinZoom(){this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0)}_addMapListeners(){const t=this.map;if(t){t.on("click",(t=>{this.onMapClick(t)}));for(const e of this._universalEvents)t.on(e,(()=>this.emitter.emit(e,this)),t);t.on("movestart",(()=>{Bt.queue.abort()})),t.on("zoomstart",(()=>{Bt.queue.abort()}));for(const e of this._positionEvents)t.on(e,(t=>this.emitter.emit(e,A(t))),t)}}_updateMinZoomForBounds(t){var e;const s=this.map;if(s){t=null!=t?t:s.getMinZoom();const o=f(v(-90,-18e3),v(90,18e3)),i=null!=(e=s.options.maxBounds)?e:o;if(void 0!==i){s.setMinZoom(0);const e=s.getBoundsZoom(i,!0),o=t<e?e:t;s.options.minZoom=o,s.setMinZoom(o),s.getZoom()<o&&s.setZoom(o)}}}};ye(fe,"layerAdapters",{GEOJSON:class extends I{constructor(t,e){super(t,e),ft(this,"layer"),ft(this,"selected",!1),ft(this,"type"),ft(this,"_layers",[]),ft(this,"_events"),ft(this,"paint"),ft(this,"selectedPaint"),ft(this,"_selectedLayers",[]),ft(this,"_filteredLayers",[]),ft(this,"_filterFun"),ft(this,"_openedPopup",[]),ft(this,"_paint"),ft(this,"$updateTooltip",b((()=>{this.updateTooltip()}),300)),ft(this,"$unselect",(()=>{this.unselect()})),this._events=new K(this),this._paint=new nt(this)}addLayer(t){return Object.assign(this.options,t),this.paint=t.paint,this.layer=new a([],yt(mt({},t.nativeOptions),{pane:this.pane})),this.selectedPaint=t.selectedPaint,t.paint=this.paint,t.data&&this.addData(t.data),this._addMapListener(),this.layer}beforeRemove(){this._removeMapListener()}select(t){if(this.unselect(),t){const e=this._layers.filter(t);for(const t of e)this._selectLayer(t,"api")}else this.selected||(this.selected=!0,this.selectedPaint&&this._paint.setPaintEachLayer(this.selectedPaint))}unselect(t){if(t){this._layers.filter(t).forEach((t=>{this._unSelectLayer(t)}))}else if(this.selected){for(const t of this._openedPopup)this._removePopup(t[0]);this.paint&&this._paint.setPaintEachLayer(this.paint),this._selectedLayers.length=0,this.selected=!1}}getSelected(){return this._selectedLayers.map((t=>mt({target:this,feature:t.feature,layer:t},T(t.feature))))}getFiltered(){return this._filteredLayers}filter(t){this._filterFun=t;const e=this.layer,s=e&&e._map;if(e&&s){e.remove();const o=[];this._layers.forEach((({feature:s,layer:i})=>{if(i){!t||t(mt({target:this,feature:s,layer:i},T(s)))?(e.addLayer(i),o.push(mt({target:this,feature:s,layer:i},T(s)))):e.removeLayer(i)}})),this._filteredLayers=o,e.addTo(s)}return this._filteredLayers}cleanFilter(){this.filter()}getLayers(){return this._layers.map((({layer:t,feature:e})=>mt({feature:e,layer:t,visible:t&&!!t._map,target:this},T(e))))}clearLayer(t){this.unselect();const e=this.layer;if(e)if(t)for(let s=this._layers.length;s--;){const o=this._layers[s];if(o){const{feature:i,layer:r}=o;if(i&&r){t(i)&&(e.removeLayer(r),this._layers.splice(s,1))}}}else e.clearLayers(),this._layers=[]}setData(t){this.clearLayer(),this.addData(t)}addData(t){const e=this.options;let s;if(e){if(t){let o;if(e.type)o=e.type;else{const e=function(t){let e;e="FeatureCollection"===t.type?j(t.features.map((t=>t.geometry.type))):"GeometryCollection"===t.type?j(t.geometries.map((t=>t.type))):"Feature"===t.type?t.geometry.type:t.type;return e}(t);o=M[e]}if(this.type&&this.type!==o)return void console.warn("no other data type than layer can be added");this.type=o,t=function(t,e){if("FeatureCollection"===t.type)t.features=t.features.filter((t=>E(t.geometry.type,e)));else if("Feature"===t.type){if(!E(t.geometry.type,e))return!1}else"GeometryCollection"===t.type&&(t.geometries=t.geometries.filter((t=>E(t.type,e))));return t}(t,o),t&&(s=this._getGeoJsonOptions(e,o))}new o(t||void 0,s)}}openPopup(t,e){if(t){this._layers.filter(t).forEach((t=>{this._openPopup(t,e,"api")}))}}closePopup(t){(t?this._openedPopup.filter((e=>t(e[2]))):this._openedPopup).forEach((t=>{this._removePopup(t[0])}))}updateTooltip(t){t?this._updateTooltip(t):this.getLayers().forEach((t=>this._updateTooltip({feature:t.feature,layer:t.layer})))}getExtent(){return this.getBounds()}getBounds(){if(this.layer){const t=this.layer.getBounds();if(t.isValid())return x(t)}}setOpacity(t){this.options.opacity=t,this.setPaint(this.paint),this.setSelectedPaint(this.selectedPaint)}setPaint(t){if(t){this.paint=t;for(const e of this._layers)this._paint.setPaint(e,t)}}setSelectedPaint(t){if(t){this.selectedPaint=t;for(const e of this._selectedLayers)this._paint.setPaint(e,t)}}updatePaint(t){this.paint=mt(mt({},this.paint),t);for(const e of this._layers)this._paint.setPaint(e,this.paint)}updateSelectedPaint(t){this.selectedPaint=mt(mt({},this.selectedPaint),t);for(const e of this._selectedLayers)this._paint.setPaint(e,this.selectedPaint)}_getSelected(t){return this._selectedLayers.find((e=>e.layer===t))}_updateTooltip(t){const{feature:e,layer:s}=t,{label:o,labelField:i,labelOnHover:r}=this.options;if(s){let n;if(s.unbindTooltip(),e.properties&&i?n=e.properties[i]:o&&(n=o(mt(mt({target:this},t),T(e)))),n){const t=!r;s.bindTooltip(String(n),{permanent:t,sticky:!1})}}}_openPopup(t){return e=this,s=arguments,o=function*(t,e={},s,o){var i,r;const{feature:n,layer:a}=t,{minWidth:l,autoPan:p,maxWidth:c,closeButton:h}=mt({minWidth:300},e),u=null!=h?h:!this.options.selectOnHover;let d;const m=[],y=t=>{m.push(t)},f=()=>{d&&this._removePopup(d)};let v;if(v=e.createPopupContent?yield e.createPopupContent(mt({layer:a,feature:n,target:this,type:s,close:f,onClose:y},T(n))):e.popupContent,v&&a){const e={minWidth:l,autoPan:p,closeButton:u,closeOnClick:!1,autoClose:!1};if(_(c)&&(e.maxWidth=c),d=a.bindPopup(v,e),null==(r=null==(i=this.options.popupOptions)?void 0:i.unselectOnClose)||r){const t=a.getPopup();t&&t.once("remove",(()=>{f()}),this)}this._openedPopup.push([d,m,t]),d.openPopup(o)}},new Promise(((t,i)=>{var r=t=>{try{a(o.next(t))}catch(e){i(e)}},n=t=>{try{a(o.throw(t))}catch(e){i(e)}},a=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,n);a((o=o.apply(e,s)).next())}));var e,s,o}_removePopup(t){var e,s;if(this.map){t.closePopup().unbindPopup();const o=this._openedPopup.findIndex((e=>e[0]===t));if(-1!==o){const t=null==(s=null==(e=this.options.popupOptions)?void 0:e.unselectOnClose)||s,[,i,r]=this._openedPopup[o];for(const e of i)e(r);i.length=0,t&&this._unSelectLayer(r),this._openedPopup.splice(o,1)}}}_getGeoJsonOptions(t,e){const s=t.paint;let o={};return"function"==typeof s?"point"===e?o.pointToLayer=(t,e)=>{const o=s(t);return this._paint.createPaintToLayer(o)(t,e)}:o={style:t=>this._paint.preparePaint(t?mt(mt({},k),s(t)):yt(mt({},k),{type:"path"}))}:o=this._paint.createPaintOptions(s),o.onEachFeature=(t,e)=>{this._onEachFeature(t,e)},o}_onEachFeature(t,e){const s=this.layer;if(s){const o=mt({target:this,feature:t,layer:e},T(t));e.options.pane=this.pane,this._layers.push(o);let i=!0;if(this._filterFun&&(i=this._filterFun(o)),i){const{popup:i,popupOptions:r,selectable:n,interactive:a,selectOnHover:l}=this.options;e.options.interactive=!_(a)||a,s.addLayer(e),n&&(l?(e.on("mouseover",(()=>{this._selectLayer(o,"hover")})),e.on("mouseout",(()=>{this._unSelectLayer(o)}))):e.on("click",(t=>this._selectOnLayerClick(t)),this)),this._events.handleMouseEvents(e),setTimeout((()=>{i&&this._openPopup(mt({target:this,layer:e,feature:t},T(t)),r,"api"),this._updateTooltip({layer:e,feature:t})}))}}}_selectOnLayerClick(t){s.stopPropagation(t);const e=t.target,o=e.feature,i=mt({target:this,layer:e,feature:o},T(o)),r=this._getSelected(e);r?this.options&&this.options.unselectOnSecondClick&&this._unSelectLayer(r):this._selectLayer(i,"click",t.latlng)}_selectLayer(t,e,s){const{multiselect:o}=this.options;o||(this.map._addUnselectCb((()=>{this._unSelectLayer(t)})),this._selectedLayers.forEach((t=>this._unSelectLayer(t)))),this._selectedLayers.push(t),this.selected=!0;const{selectedPaint:i,popupOnSelect:r,popupOptions:n}=this.options;if(i&&t.layer&&this._paint.setPaint(t,i),r&&this._openPopup(t,n,e,s),this.options.onSelect){const s=t.feature?[t.feature]:[];this.options.onSelect(mt({type:e,layer:this,features:s},T(s)))}}_unSelectLayer(t){const e=this._selectedLayers.indexOf(t);-1!==e&&(this._selectedLayers.splice(e,1),this.options&&(this.options.paint&&this._paint.setPaint(t,this.options.paint),this.options.popupOnSelect&&t.layer&&this._removePopup(t.layer))),this.selected=this._selectedLayers.length>0}_addMapClickListener(){const t=this.map;if(t){const{unselectOnClick:e}=this.options;(null==e||e)&&t.on("click",this.$unselect)}}_removeMapClickListener(){this.map.off("zoomend",this.$updateTooltip),this.map.off("moveend",this.$updateTooltip),this.map.off("click",this.$unselect)}_addMapListener(){const t=this.map;if(t){const{label:e,labelField:s,labelOnHover:o}=this.options;this._addMapClickListener(),!s&&!e||o||(t.on("zoomend",this.$updateTooltip),t.on("moveend",this.$updateTooltip))}}_removeMapListener(){this._removeMapClickListener(),this.map.off("zoomend",this.$updateTooltip),this.map.off("moveend",this.$updateTooltip)}},IMAGE:Bt,TILE:$t,WMS:class extends I{addLayer(t){Object.assign(this.options,t);const e=t,{url:s}=e,o=((t,e)=>{var s={};for(var o in t)ie.call(t,o)&&e.indexOf(o)<0&&(s[o]=t[o]);if(null!=t&&oe)for(var o of oe(t))e.indexOf(o)<0&&re.call(t,o)&&(s[o]=t[o]);return s})(e,["url"]);if(s){const e=ae({pane:this.pane,attribution:o.attribution,minZoom:o.minZoom,maxZoom:o.maxZoom,layers:t.layers,format:t.format,transparent:!0},t.nativeOptions);let r;return r=o.headers||o.withCredentials?new Yt(s,(i=ae({},e),ee(i,se({headers:o.headers,withCredentials:o.withCredentials})))):new m.WMS(s,e),r}var i}},OSM:class extends $t{addLayer(t){return super.addLayer((e=((t,e)=>{for(var s in e||(e={}))Xt.call(e,s)&&Qt(t,s,e[s]);if(Jt)for(var s of Jt(e))Kt.call(e,s)&&Qt(t,s,e[s]);return t})({name:"OpenStreetMap",attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'},t),Ht(e,qt({url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}))));var e}}}),ye(fe,"controlAdapters",{ZOOM:e.Zoom,ATTRIBUTION:class extends e.Attribution{constructor(t){super(t);const e=t&&t.customAttribution;if(e){let t=[];Array.isArray(e)?t=e:e&&(t=[e]),t.forEach((t=>this.addAttribution(t)))}}}}),ye(fe,"Map",y);let ve=fe;export{ve as default};
|
|
1
|
+
import{EventEmitter as t}from"events";import{Control as e,DomEvent as s,GeoJSON as o,DivIcon as i,Marker as r,CircleMarker as n,FeatureGroup as a,ImageOverlay as l,Layer as p,Util as c,GridLayer as h,DomUtil as u,TileLayer as d,Map as m,latLngBounds as y,latLng as f}from"leaflet";import{defined as v,debounce as _,isObject as b,updateUrlParams as g}from"@nextgis/utils";import{isPaintCallback as O,isPaint as P}from"@nextgis/paint";import w from"@nextgis/queue";function L(t,o={},i){return new(e.extend({onAdd(){const e=document.createElement("div"),r=t.onAdd(i);return e.classList.add("leaflet-control"),o.bar&&e.classList.add("leaflet-bar"),o.addClass&&e.classList.add(o.addClass),o.margin||o.bar||(e.style.marginBottom="0px",e.style.marginTop="0px",e.style.marginLeft="0px",e.style.marginRight="0px"),r&&e.appendChild(r),s.disableClickPropagation(e),e},onRemove(){t.onRemove()}}))}function C(t){const e=t.getNorthEast(),s=t.getSouthWest();return[s.lng,s.lat,e.lng,e.lat]}function x(t){const e={};for(let o=0;o<t.length;o++)e[t[o]]=1+(e[t[o]]||0);let s="";for(const o in e){e[o]>(s?e[s]:0)&&(s=o)}return s}const j={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon",GeometryCollection:"polygon"},M={stroke:!1,opacity:1},k={};for(const ve in j){const t=j[ve],e=k[t]||[];e.push(ve),k[t]=e}function E(t,e){return-1!==(k[e]||[]).indexOf(t)}function S(t){const e=new o;return(Array.isArray(t)?t:[t]).forEach((t=>e.addData(t))),e.getBounds()}function Z(t){return{getBounds:()=>function(t){return C(S(t))}(t),getCenter:()=>function(t){const{lat:e,lng:s}=S(t).getCenter();return[s,e]}(t)}}var T=Object.defineProperty,B=(t,e,s)=>((t,e,s)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);class z{constructor(t,e){if(this.map=t,this.options=e,B(this,"layer"),B(this,"pane","order-0"),void 0!==e.order){const s="order-"+e.order;let o=t.getPane(s);o||(o=t.createPane(s)),o.style.zIndex=String(Math.round(100*e.order)),this.pane=s}}addLayer(t){Object.assign(this.options,t)}}function I(t){const e=t.containerPoint,s=t.latlng,{lat:o,lng:i}=s;return{latLng:s,lngLat:[i,o],pixel:{left:e.x,top:e.y},source:t}}var A=Object.defineProperty,F=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable,W=(t,e,s)=>e in t?A(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;function R({layer:t,source:e}){const s=e.target.feature;return((t,e)=>{for(var s in e||(e={}))U.call(e,s)&&W(t,s,e[s]);if(F)for(var s of F(e))D.call(e,s)&&W(t,s,e[s]);return t})({layer:t,feature:s,event:I(e),source:e},Z(s))}var N=Object.defineProperty,V=Object.getOwnPropertySymbols,$=Object.prototype.hasOwnProperty,G=Object.prototype.propertyIsEnumerable,H=(t,e,s)=>e in t?N(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,q=(t,e)=>{for(var s in e||(e={}))$.call(e,s)&&H(t,s,e[s]);if(V)for(var s of V(e))G.call(e,s)&&H(t,s,e[s]);return t},J=(t,e,s)=>H(t,"symbol"!=typeof e?e+"":e,s);class X{constructor(t){J(this,"layer"),J(this,"_onclick"),J(this,"_ondblclick"),J(this,"_mouseout"),J(this,"_mouseover"),this.layer=t}handleMouseEvents(t){const{onClick:e,onDoubleClick:o,onLayerClick:i,onMouseOut:r,onMouseOver:n}=this.layer.options,a=e||i;a&&(this._onclick=e=>{const s=!!this.layer._getSelected(t);a(q({selected:s},this._createMouseEvent(e)))},t.on("click",this._onclick,this)),o&&(this._ondblclick=e=>{s.stopPropagation(e);const i=!!this.layer._getSelected(t);o(q({selected:i},this._createMouseEvent(e)))},t.on("dblclick",this._ondblclick,this)),r&&(this._mouseout=t=>{r(this._createMouseEvent(t))},t.on("mouseout",this._mouseout,this)),n&&(this._mouseover=t=>{n(this._createMouseEvent(t))},t.on("mouseover",this._mouseover,this))}stopMouseEvents(t){this._mouseover&&t.off("mouseover",this._mouseover,this),this._mouseout&&t.off("mouseout",this._mouseout,this),this._onclick&&t.off("click",this._onclick,this)}_createMouseEvent(t){return R({layer:this.layer,source:t})}}var K=Object.defineProperty,Q=Object.defineProperties,Y=Object.getOwnPropertyDescriptors,tt=Object.getOwnPropertySymbols,et=Object.prototype.hasOwnProperty,st=Object.prototype.propertyIsEnumerable,ot=(t,e,s)=>e in t?K(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,it=(t,e)=>{for(var s in e||(e={}))et.call(e,s)&&ot(t,s,e[s]);if(tt)for(var s of tt(e))st.call(e,s)&&ot(t,s,e[s]);return t};class rt{constructor(t){var e;ot(this,"layer"+"",e),this.layer=t}setPaintEachLayer(t){this.layer._layers.forEach((e=>{this.setPaint(e,t)}))}setPaint(t,e){let s;const{layer:o,feature:i}=t;if(o&&i&&(O(e)?s=e(i):P(e)&&(s=e),s))if("point"===this.layer.type&&"icon"===s.type){const t=o,e=this._createDivIcon(s);setTimeout((()=>{t.setIcon(e)}),10)}else"setStyle"in o&&o.setStyle(this.preparePaint(s))}preparePaint(t){if("get-paint"!==t.type){const e="line"===this.layer.type?[["color","strokeColor"],["opacity","strokeOpacity"],["weight","weight"]]:[["color","strokeColor"],["opacity","strokeOpacity"],["stroke","stroke"],["fillColor","fillColor"],["fillOpacity","fillOpacity"],["fill","fill"],["weight","weight"]],s={};"radius"in t&&"number"==typeof t.radius&&(s.radius=t.radius);for(const[o,i]of e){const e=this.layer.options.opacity;let r=t[i];v(e)&&-1!==i.toLowerCase().indexOf("opacity")&&(r=Number(r)*e),void 0!==r&&Object.defineProperty(s,o,{enumerable:!0,value:r})}return s}return M}_createDivIcon(t){const e=t,{html:s,rotate:o,className:r}=e,n=((t,e)=>{var s={};for(var o in t)et.call(t,o)&&e.indexOf(o)<0&&(s[o]=t[o]);if(null!=t&&tt)for(var o of tt(t))e.indexOf(o)<0&&st.call(t,o)&&(s[o]=t[o]);return s})(e,["html","rotate","className"]),a=document.createElement("div");r&&(a.className=r),o&&(a.style.transform=`rotateZ(${o}deg)`),s&&(a.innerHTML=s);var l;return new i((l=it({className:""},n),Q(l,Y({html:a}))))}createPaintToLayer(t){if(t&&t.type)if("icon"===t.type){if(t.className||t.html)return(e,s)=>{const o=this._createDivIcon(t);return new r(s,{icon:o})}}else if("pin"===t.type)return(t,e)=>new r(e);return(e,s)=>new n(s,this.preparePaint(it(it({},M),t)))}createPaintOptions(t){const e={},s=this.preparePaint(t);return t&&(e.style=()=>s),"point"===this.layer.type?e.pointToLayer=this.createPaintToLayer(t):"line"===this.layer.type&&(s.stroke=!0),e}}var nt=Object.defineProperty,at=Object.defineProperties,lt=Object.getOwnPropertyDescriptors,pt=Object.getOwnPropertySymbols,ct=Object.prototype.hasOwnProperty,ht=Object.prototype.propertyIsEnumerable,ut=(t,e,s)=>e in t?nt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,dt=(t,e)=>{for(var s in e||(e={}))ct.call(e,s)&&ut(t,s,e[s]);if(pt)for(var s of pt(e))ht.call(e,s)&&ut(t,s,e[s]);return t},mt=(t,e)=>at(t,lt(e)),yt=(t,e,s)=>ut(t,"symbol"!=typeof e?e+"":e,s);function ft({src:t,headers:e,withCredentials:s}){let o=()=>{};return[new Promise(((i,r)=>{const n=new XMLHttpRequest;n.open("GET",t),n.responseType="arraybuffer";for(const t in e)n.setRequestHeader(t,e[t]);s&&(n.withCredentials=s),n.onload=function(){const t=new Uint8Array(this.response),e=new Blob([t],{type:"image/png"}),s=(window.URL||window.webkitURL).createObjectURL(e);i(s)},n.onerror=r,n.send(),o=()=>{n.abort(),i("")}})),o]}const vt=new w({concurrency:6,delay:200});var _t=Object.defineProperty,bt=(t,e,s)=>((t,e,s)=>e in t?_t(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,e+"",s);class gt extends l{constructor(t,e,s){super(t,e,s),bt(this,"_aborter")}cancelLoad(){this._aborter&&(this._aborter(),this._aborter=void 0)}_initImage(){super._initImage();const{headers:t,withCredentials:e}=this.options,s=this._image,o=s.src;s.src="",vt.add((()=>{const[i,r]=ft({src:o,headers:t,withCredentials:e});return i.then((t=>{s.src=t})),this._aborter=r,i}))}}var Ot=Object.defineProperty,Pt=(t,e,s)=>((t,e,s)=>e in t?Ot(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s)(t,"symbol"!=typeof e?e+"":e,s);class wt extends p{constructor(t,e){super(e),Pt(this,"defaultWmsParams",{request:"GetMap"}),Pt(this,"options",{crs:null,uppercase:!1,attribution:"",opacity:1,isBack:!1,minZoom:0,maxZoom:void 0,pane:"tilePane",headers:null,withCredentials:!1,viewPortBuffer:0,setViewDelay:100}),Pt(this,"wmsParams"),Pt(this,"_url"),Pt(this,"_currentUrl"),Pt(this,"_currentOverlay"),Pt(this,"_loadedOverlay"),this._url=t;const s={},o={};let i;for(i in e){i in this.options&&(o[i]=e[i])}if(e.params)for(const r in e.params){const t=e.params[r];b(t)||Array.isArray(t)||"function"==typeof t||(s[r]=t)}c.setOptions(this,o),this.wmsParams=c.extend({},this.defaultWmsParams,s)}setParams(t){c.extend(this.wmsParams,t),this.update()}getAttribution(){return this.options.attribution||""}onAdd(){return this.update(),this}onRemove(t){return this._currentOverlay&&(this._currentOverlay.cancelLoad(),t.removeLayer(this._currentOverlay),delete this._currentOverlay),this._currentUrl&&delete this._currentUrl,this}getEvents(){return{moveend:_(this.update,this.options.setViewDelay)}}update(){if(!this._map)return;this.updateWmsParams();const t=this.getImageUrl();if(this._currentUrl===t)return;this._currentUrl=t;const e=this.options.viewPortBuffer||0,s=this._map.getBounds().pad(e);this._loadedOverlay&&(this._loadedOverlay.cancelLoad(),this._loadedOverlay.off("load"),this._loadedOverlay=void 0);const o=new gt(t,s,{opacity:0,pane:this.options.pane,headers:this.options.headers,withCredentials:this.options.withCredentials});o.addTo(this._map),this._loadedOverlay=o,o.once("load",(()=>{this._map&&(o._url===this._currentUrl?(this._currentOverlay&&this._map.removeLayer(this._currentOverlay),this._loadedOverlay=void 0,this._currentOverlay=o,o.setOpacity(void 0!==this.options.opacity?this.options.opacity:1),!0===this.options.isBack&&o.bringToBack(),!1===this.options.isBack&&o.bringToFront(),void 0!==this.options.zIndex&&o.setZIndex(this.options.zIndex)):this._map.removeLayer(o))}),this);const{minZoom:i,maxZoom:r}=this.options;(i&&this._map.getZoom()<i||r&&this._map.getZoom()>r)&&this._map.removeLayer(o)}setOpacity(t){this.options.opacity=t,this._currentOverlay&&this._currentOverlay.setOpacity(t)}bringToBack(){this.options.isBack=!0,this._currentOverlay&&this._currentOverlay.bringToBack()}bringToFront(){this.options.isBack=!1,this._currentOverlay&&this._currentOverlay.bringToFront()}setZIndex(t){this.options.zIndex=t,this._currentOverlay&&this._currentOverlay.setZIndex(t)}updateWmsParams(t){t||(t=this._map);const e=this.options.viewPortBuffer||0,s=t.getBounds().pad(e),o=t.getSize();if(0!==this.options.viewPortBuffer){const t=e+1;o.x=Math.ceil(o.x*t),o.y=Math.ceil(o.y*t)}const i=this.options.crs||t.options.crs;if(i){const t=i.project(s.getNorthWest()),e=i.project(s.getSouthEast()),r={width:o.x,height:o.y};r.bbox=[t.x,e.y,e.x,t.y],c.extend(this.wmsParams,r)}}getImageUrl(){const t=c.getParamString(this.wmsParams,this._url,this.options.uppercase||!1);return this._url+t}}var Lt=Object.defineProperty,Ct=Object.defineProperties,xt=Object.getOwnPropertyDescriptors,jt=Object.getOwnPropertySymbols,Mt=Object.prototype.hasOwnProperty,kt=Object.prototype.propertyIsEnumerable,Et=(t,e,s)=>e in t?Lt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,St=(t,e)=>{for(var s in e||(e={}))Mt.call(e,s)&&Et(t,s,e[s]);if(jt)for(var s of jt(e))kt.call(e,s)&&Et(t,s,e[s]);return t},Zt=(t,e,s)=>Et(t,"symbol"!=typeof e?e+"":e,s);class Tt extends z{constructor(){super(...arguments),Zt(this,"layer")}addLayer(t){var e;const s=t&&t.url;if(s){const r=t.updateWmsParams;if(this.layer=new wt(s,St(St(St({pane:this.pane,headers:t.headers,setViewDelay:t.setViewDelay},(o=St({transparent:!0},t),i={opacity:null!=(e=t.opacity)?e:void 0},Ct(o,xt(i)))),t.params),t.nativeOptions)),r){const t=this.layer.updateWmsParams;this.layer.updateWmsParams=function(e){t.call(this,e),this.wmsParams=r(this.wmsParams)}}return this.layer}var o,i}updateLayer(t){if(this.layer){c.extend(this.layer.wmsParams,(null==t?void 0:t.params)||{}),this.layer.update()}}}function Bt(t){return class extends t{constructor(...t){super(...t),this.options.setViewDelay&&(this._update=function(t,e=10){let s;function o(...i){o.clear(),s=setTimeout((()=>{s=null,t.apply(this,i)}),e)}return o.clear=function(){s&&(clearTimeout(s),s=null)},o}(((...t)=>{h.prototype._update.call(this,...t)}),this.options.setViewDelay))}createTile(t,e){const s=this.getTileUrl(t),o=document.createElement("img"),[i,r]=ft({src:s,withCredentials:this.options.withCredentials,headers:this.options.headers});return i.then((t=>{o.src=t,e(null,o)})),o.abort=r,(this.options.crossOrigin||""===this.options.crossOrigin)&&(o.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),o.alt="",o.setAttribute("role","presentation"),o}_abortLoading(){const t=this._tiles,e=this._tileZoom;for(const s in t)if(t[s].coords.z!==e){const e=t[s].el;e.onload=c.falseFn,e.onerror=c.falseFn,e.complete||(e.abort&&e.abort(),e.src=c.emptyImageUrl,u.remove(e),delete t[s])}}}}Zt(Tt,"queue",vt);const zt=Bt(class extends d{constructor(t,e){super(t,e),Object.assign(this.options,e)}});var It=Object.defineProperty,At=Object.defineProperties,Ft=Object.getOwnPropertyDescriptors,Ut=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,Wt=Object.prototype.propertyIsEnumerable,Rt=(t,e,s)=>e in t?It(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Nt=(t,e)=>{for(var s in e||(e={}))Dt.call(e,s)&&Rt(t,s,e[s]);if(Ut)for(var s of Ut(e))Wt.call(e,s)&&Rt(t,s,e[s]);return t};class Vt extends z{addLayer(t){if(this.options=Object.assign(this.options,t),t){const s=t,{url:o}=s,i=((t,e)=>{var s={};for(var o in t)Dt.call(t,o)&&e.indexOf(o)<0&&(s[o]=t[o]);if(null!=t&&Ut)for(var o of Ut(t))e.indexOf(o)<0&&Wt.call(t,o)&&(s[o]=t[o]);return s})(s,["url"]);if(o){const t=Nt({pane:this.pane,attribution:i.attribution,minZoom:i.minZoom,maxZoom:i.maxZoom},i.nativeOptions);let s;return i.subdomains&&(t.subdomains=i.subdomains),s=i.headers||i.withCredentials?new zt(o,(e=Nt({},t),At(e,Ft({headers:i.headers,withCredentials:i.withCredentials,setViewDelay:i.setViewDelay})))):new d(o,t),s}}var e}updateLayer(t){if(this.layer){(null==t?void 0:t.params)&&this.layer.setUrl(g(this.layer._url,t.params)),this.layer.redraw()}}}var $t=Object.defineProperty,Gt=Object.defineProperties,Ht=Object.getOwnPropertyDescriptors,qt=Object.getOwnPropertySymbols,Jt=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable,Kt=(t,e,s)=>e in t?$t(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;const Qt=Bt(class extends d.WMS{constructor(t,e){super(t,e)}});var Yt=Object.defineProperty,te=Object.defineProperties,ee=Object.getOwnPropertyDescriptors,se=Object.getOwnPropertySymbols,oe=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable,re=(t,e,s)=>e in t?Yt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ne=(t,e)=>{for(var s in e||(e={}))oe.call(e,s)&&re(t,s,e[s]);if(se)for(var s of se(e))ie.call(e,s)&&re(t,s,e[s]);return t};function ae(t){return[[t[3],t[0]],[t[1],t[2]]]}var le=Object.defineProperty,pe=Object.getOwnPropertySymbols,ce=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable,ue=(t,e,s)=>e in t?le(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,de=(t,e)=>{for(var s in e||(e={}))ce.call(e,s)&&ue(t,s,e[s]);if(pe)for(var s of pe(e))he.call(e,s)&&ue(t,s,e[s]);return t},me=(t,e,s)=>ue(t,"symbol"!=typeof e?e+"":e,s);const ye=class e{constructor(){me(this,"options",{target:"map"}),me(this,"layerAdapters",e.layerAdapters),me(this,"controlAdapters",e.controlAdapters),me(this,"emitter",new t),me(this,"map"),me(this,"_resizeObserver"),me(this,"_unselectCb",[]),me(this,"_universalEvents",["move","zoom","zoomend","zoomstart","moveend","movestart"]),me(this,"_positionEvents",["mousemove","mouseout","mouseover"])}create(t){if(this.options=de({},t),this.options.target){const{zoom:t,center:e,maxZoom:s,minZoom:o,maxBounds:i,mapAdapterOptions:r}=this.options;this.map=this.options.map||new m(this.options.target,de({attributionControl:!1,zoomControl:!1,maxBounds:i?ae(i):void 0,maxZoom:s,minZoom:o,center:e&&[e[1],e[0]],zoom:t},r)),this._updateMinZoomForBounds(o),this._watchSizeChangeToUpdateMinZoom();const n=this.map.createPane("order-0");this.map._addUnselectCb=t=>{this._addUnselectCb(t)},n.style.zIndex=String(0),this.emitter.emit("create",this),this._addMapListeners()}}destroy(){this.map&&this.map.remove(),this._stopWatchSizeChangeToUpdateMinZoom()}getContainer(){return this.map&&this.map.getContainer()}getControlContainer(){const t=this.map&&this.map._controlContainer;if(t)return t;throw new Error("Leaflet Map is not initialized yet")}setCursor(t){this.map&&(this.map.getContainer().style.cursor=t)}setView(t,e){const s=this.map;if(s)if(Array.isArray(t)){const s=t,[o,i]=s;this.map&&("number"==typeof e?this.map.setView([i,o],e,{animate:!1}):this.setCenter([o,i]))}else{const{zoom:e,center:o,maxBounds:i,bounds:r,minZoom:n,maxZoom:a}=t;if(o&&void 0!==e?this.setView(o,e):(void 0!==e&&this.setZoom(e),o&&this.setCenter(o)),r&&this.fitBounds(r),void 0!==i)if(i){const t=ae(i);s.setMaxBounds(t),this._updateMinZoomForBounds()}else s.setMaxBounds(null),this._updateMinZoomForBounds();void 0!==a&&s.setMaxZoom(a),void 0!==n&&this._updateMinZoomForBounds(n)}}setCenter(t){const[e,s]=t;this.map&&this.map.panTo([s,e])}getCenter(){const t=this.map;if(t){const e=t.getBounds().getCenter();return[e.lng,e.lat]}}setZoom(t){this.map&&this.map.setZoom(t)}getZoom(){var t;return null!=(t=this.map&&this.map.getZoom())?t:void 0}getBounds(){if(!this.map)return;const t=this.map.getBounds(),e=t.getSouthWest(),s=t.getNorthEast();return[e.lng,e.lat,s.lng,s.lat]}fitBounds(t,e={}){if(this.map){const{maxZoom:s,offset:o,padding:i}=e,r={};s&&(r.maxZoom=s),i&&(r.padding=[i,i]),o&&(r.padding=o),this.map.fitBounds(ae(t),r)}}getLayerAdapter(t){return e.layerAdapters[t]}createControl(t,e){return L(t,e,this)}createButtonControl(t){return function(t,e){const o=document.createElement("a"),i=t.title||"";o.href="#",o.title=i,o.setAttribute("role","button"),o.setAttribute("aria-label",i),t.addClass&&o.classList.add(t.addClass),s.disableClickPropagation(o),s.on(o,"click",s.stop),t.html instanceof HTMLElement?o.appendChild(t.html):"string"==typeof t.html&&(o.innerHTML=t.html);const r=e=>{e.stopPropagation(),t.onClick()};return L({onAdd:()=>(void 0!==t.onClick&&o.addEventListener("click",r),o),onRemove(){const e=o.parentNode;e&&e.removeChild(o),void 0!==t.onClick&&o.removeEventListener("click",r)}},{bar:!0},e)}(t,this)}addControl(t,e){if(t.options.position=e.replace("-",""),this.map)return this.map.addControl(t),t}removeControl(t){this.map&&this.map.removeControl(t)}removeLayer(t){t&&t.remove&&t.remove()}showLayer(t){this.map&&t.addTo(this.map)}hideLayer(t){t.remove()}setLayerOpacity(t,e){"setOpacity"in t&&t.setOpacity(e)}setLayerOrder(t,e,s){}onMapClick(t){const e=I(t);this.emitter.emit("preclick",e),this.emitter.emit("click",e)}locate(t,e){const s=this.map;if(s&&(s.locate(t),e)){const{locationfound:t,locationerror:o}=e,i=e=>{t({lngLat:[e.latlng.lng,e.latlng.lat]})};void 0!==t&&s.on("locationfound",i,this),o&&s.on("locationerror",o,this);return{stop:()=>{void 0!==t&&s.off("locationfound",i),o&&s.off("locationerror",o)}}}return{stop:()=>{}}}_addUnselectCb(t){for(const e of this._unselectCb)e();this._unselectCb.length=0,this._unselectCb.push(t)}_watchSizeChangeToUpdateMinZoom(){this._stopWatchSizeChangeToUpdateMinZoom();const t=this.getContainer();t&&this.map&&window.ResizeObserver&&(this._resizeObserver=new ResizeObserver((()=>{this._updateMinZoomForBounds()})),this._resizeObserver.observe(t))}_stopWatchSizeChangeToUpdateMinZoom(){this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0)}_addMapListeners(){const t=this.map;if(t){t.on("click",(t=>{this.onMapClick(t)}));for(const e of this._universalEvents)t.on(e,(()=>this.emitter.emit(e,this)),t);t.on("movestart",(()=>{Tt.queue.abort()})),t.on("zoomstart",(()=>{Tt.queue.abort()}));for(const e of this._positionEvents)t.on(e,(t=>this.emitter.emit(e,I(t))),t)}}_updateMinZoomForBounds(t){var e;const s=this.map;if(s){t=null!=t?t:s.getMinZoom();const o=y(f(-90,-18e3),f(90,18e3)),i=null!=(e=s.options.maxBounds)?e:o;if(void 0!==i){s.setMinZoom(0);const e=s.getBoundsZoom(i,!0),o=t<e?e:t;s.options.minZoom=o,s.setMinZoom(o),s.getZoom()<o&&s.setZoom(o)}}}};me(ye,"layerAdapters",{GEOJSON:class extends z{constructor(t,e){super(t,e),yt(this,"layer"),yt(this,"selected",!1),yt(this,"type"),yt(this,"_layers",[]),yt(this,"_events"),yt(this,"paint"),yt(this,"selectedPaint"),yt(this,"_selectedLayers",[]),yt(this,"_filteredLayers",[]),yt(this,"_filterFun"),yt(this,"_openedPopup",[]),yt(this,"_paint"),yt(this,"$updateTooltip",_((()=>{this.updateTooltip()}),300)),yt(this,"$unselect",(()=>{this.unselect()})),this._events=new X(this),this._paint=new rt(this)}addLayer(t){return Object.assign(this.options,t),this.paint=t.paint,this.layer=new a([],mt(dt({},t.nativeOptions),{pane:this.pane})),this.selectedPaint=t.selectedPaint,t.paint=this.paint,t.data&&this.addData(t.data),this._addMapListener(),this.layer}beforeRemove(){this._removeMapListener()}select(t){if(this.unselect(),t){const e=this._layers.filter(t);for(const t of e)this._selectLayer(t,"api")}else this.selected||(this.selected=!0,this.selectedPaint&&this._paint.setPaintEachLayer(this.selectedPaint))}unselect(t){if(t){this._layers.filter(t).forEach((t=>{this._unSelectLayer(t)}))}else if(this.selected){for(const t of this._openedPopup)this._removePopup(t[0]);this.paint&&this._paint.setPaintEachLayer(this.paint),this._selectedLayers.length=0,this.selected=!1}}getSelected(){return this._selectedLayers.map((t=>dt({target:this,feature:t.feature,layer:t},Z(t.feature))))}getFiltered(){return this._filteredLayers}filter(t){this._filterFun=t;const e=this.layer,s=e&&e._map;if(e&&s){e.remove();const o=[];this._layers.forEach((({feature:s,layer:i})=>{if(i){!t||t(dt({target:this,feature:s,layer:i},Z(s)))?(e.addLayer(i),o.push(dt({target:this,feature:s,layer:i},Z(s)))):e.removeLayer(i)}})),this._filteredLayers=o,e.addTo(s)}return this._filteredLayers}cleanFilter(){this.filter()}getLayers(){return this._layers.map((({layer:t,feature:e})=>dt({feature:e,layer:t,visible:t&&!!t._map,target:this},Z(e))))}clearLayer(t){this.unselect();const e=this.layer;if(e)if(t)for(let s=this._layers.length;s--;){const o=this._layers[s];if(o){const{feature:i,layer:r}=o;if(i&&r){t(i)&&(e.removeLayer(r),this._layers.splice(s,1))}}}else e.clearLayers(),this._layers=[]}setData(t){this.clearLayer(),this.addData(t)}addData(t){const e=this.options;let s;if(e){if(t){let o;if(e.type)o=e.type;else{const e=function(t){let e;e="FeatureCollection"===t.type?x(t.features.map((t=>t.geometry.type))):"GeometryCollection"===t.type?x(t.geometries.map((t=>t.type))):"Feature"===t.type?t.geometry.type:t.type;return e}(t);o=j[e]}if(this.type&&this.type!==o)return void console.warn("no other data type than layer can be added");this.type=o,t=function(t,e){if("FeatureCollection"===t.type)t.features=t.features.filter((t=>E(t.geometry.type,e)));else if("Feature"===t.type){if(!E(t.geometry.type,e))return!1}else"GeometryCollection"===t.type&&(t.geometries=t.geometries.filter((t=>E(t.type,e))));return t}(t,o),t&&(s=this._getGeoJsonOptions(e,o))}new o(t||void 0,s)}}openPopup(t,e){if(t){this._layers.filter(t).forEach((t=>{this._openPopup(t,e,"api")}))}}closePopup(t){(t?this._openedPopup.filter((e=>t(e[2]))):this._openedPopup).forEach((t=>{this._removePopup(t[0])}))}updateTooltip(t){t?this._updateTooltip(t):this.getLayers().forEach((t=>this._updateTooltip({feature:t.feature,layer:t.layer})))}getExtent(){return this.getBounds()}getBounds(){if(this.layer){const t=this.layer.getBounds();if(t.isValid())return C(t)}}setOpacity(t){this.options.opacity=t,this.setPaint(this.paint),this.setSelectedPaint(this.selectedPaint)}setPaint(t){if(t){this.paint=t;for(const e of this._layers)this._paint.setPaint(e,t)}}setSelectedPaint(t){if(t){this.selectedPaint=t;for(const e of this._selectedLayers)this._paint.setPaint(e,t)}}updatePaint(t){this.paint=dt(dt({},this.paint),t);for(const e of this._layers)this._paint.setPaint(e,this.paint)}updateSelectedPaint(t){this.selectedPaint=dt(dt({},this.selectedPaint),t);for(const e of this._selectedLayers)this._paint.setPaint(e,this.selectedPaint)}_getSelected(t){return this._selectedLayers.find((e=>e.layer===t))}_updateTooltip(t){const{feature:e,layer:s}=t,{label:o,labelField:i,labelOnHover:r}=this.options;if(s){let n;if(s.unbindTooltip(),e.properties&&i?n=e.properties[i]:o&&(n=o(dt(dt({target:this},t),Z(e)))),n){const t=!r;s.bindTooltip(String(n),{permanent:t,sticky:!1})}}}_openPopup(t){return e=this,s=arguments,o=function*(t,e={},s,o){var i,r;const{feature:n,layer:a}=t,{minWidth:l,autoPan:p,maxWidth:c,closeButton:h}=dt({minWidth:300},e),u=null!=h?h:!this.options.selectOnHover;let d;const m=[],y=t=>{m.push(t)},f=()=>{d&&this._removePopup(d)};let _;if(_=e.createPopupContent?yield e.createPopupContent(dt({layer:a,feature:n,target:this,type:s,close:f,onClose:y},Z(n))):e.popupContent,_&&a){const e={minWidth:l,autoPan:p,closeButton:u,closeOnClick:!1,autoClose:!1};if(v(c)&&(e.maxWidth=c),d=a.bindPopup(_,e),null==(r=null==(i=this.options.popupOptions)?void 0:i.unselectOnClose)||r){const t=a.getPopup();t&&t.once("remove",(()=>{f()}),this)}this._openedPopup.push([d,m,t]),d.openPopup(o)}},new Promise(((t,i)=>{var r=t=>{try{a(o.next(t))}catch(e){i(e)}},n=t=>{try{a(o.throw(t))}catch(e){i(e)}},a=e=>e.done?t(e.value):Promise.resolve(e.value).then(r,n);a((o=o.apply(e,s)).next())}));var e,s,o}_removePopup(t){var e,s;if(this.map){t.closePopup().unbindPopup();const o=this._openedPopup.findIndex((e=>e[0]===t));if(-1!==o){const t=null==(s=null==(e=this.options.popupOptions)?void 0:e.unselectOnClose)||s,[,i,r]=this._openedPopup[o];for(const e of i)e(r);i.length=0,t&&this._unSelectLayer(r),this._openedPopup.splice(o,1)}}}_getGeoJsonOptions(t,e){const s=t.paint;let o={};return"function"==typeof s?"point"===e?o.pointToLayer=(t,e)=>{const o=s(t);return this._paint.createPaintToLayer(o)(t,e)}:o={style:t=>this._paint.preparePaint(t?dt(dt({},M),s(t)):mt(dt({},M),{type:"path"}))}:o=this._paint.createPaintOptions(s),o.onEachFeature=(t,e)=>{this._onEachFeature(t,e)},o}_onEachFeature(t,e){const s=this.layer;if(s){const o=dt({target:this,feature:t,layer:e},Z(t));e.options.pane=this.pane,this._layers.push(o);let i=!0;if(this._filterFun&&(i=this._filterFun(o)),i){const{popup:i,popupOptions:r,selectable:n,interactive:a,selectOnHover:l}=this.options;e.options.interactive=!v(a)||a,s.addLayer(e),n&&(l?(e.on("mouseover",(()=>{this._selectLayer(o,"hover")})),e.on("mouseout",(()=>{this._unSelectLayer(o)}))):e.on("click",(t=>this._selectOnLayerClick(t)),this)),this._events.handleMouseEvents(e),setTimeout((()=>{i&&this._openPopup(dt({target:this,layer:e,feature:t},Z(t)),r,"api"),this._updateTooltip({layer:e,feature:t})}))}}}_selectOnLayerClick(t){s.stopPropagation(t);const e=t.target,o=e.feature,i=dt({target:this,layer:e,feature:o},Z(o)),r=this._getSelected(e);r?this.options&&this.options.unselectOnSecondClick&&this._unSelectLayer(r):this._selectLayer(i,"click",t.latlng)}_selectLayer(t,e,s){const{multiselect:o}=this.options;o||(this.map._addUnselectCb((()=>{this._unSelectLayer(t)})),this._selectedLayers.forEach((t=>this._unSelectLayer(t)))),this._selectedLayers.push(t),this.selected=!0;const{selectedPaint:i,popupOnSelect:r,popupOptions:n}=this.options;if(i&&t.layer&&this._paint.setPaint(t,i),r&&this._openPopup(t,n,e,s),this.options.onSelect){const s=t.feature?[t.feature]:[];this.options.onSelect(dt({type:e,layer:this,features:s},Z(s)))}}_unSelectLayer(t){const e=this._selectedLayers.indexOf(t);-1!==e&&(this._selectedLayers.splice(e,1),this.options&&(this.options.paint&&this._paint.setPaint(t,this.options.paint),this.options.popupOnSelect&&t.layer&&this._removePopup(t.layer))),this.selected=this._selectedLayers.length>0}_addMapClickListener(){const t=this.map;if(t){const{unselectOnClick:e}=this.options;(null==e||e)&&t.on("click",this.$unselect)}}_removeMapClickListener(){this.map.off("zoomend",this.$updateTooltip),this.map.off("moveend",this.$updateTooltip),this.map.off("click",this.$unselect)}_addMapListener(){const t=this.map;if(t){const{label:e,labelField:s,labelOnHover:o}=this.options;this._addMapClickListener(),!s&&!e||o||(t.on("zoomend",this.$updateTooltip),t.on("moveend",this.$updateTooltip))}}_removeMapListener(){this._removeMapClickListener(),this.map.off("zoomend",this.$updateTooltip),this.map.off("moveend",this.$updateTooltip)}},IMAGE:Tt,TILE:Vt,WMS:class extends z{addLayer(t){Object.assign(this.options,t);const e=t,{url:s}=e,o=((t,e)=>{var s={};for(var o in t)oe.call(t,o)&&e.indexOf(o)<0&&(s[o]=t[o]);if(null!=t&&se)for(var o of se(t))e.indexOf(o)<0&&ie.call(t,o)&&(s[o]=t[o]);return s})(e,["url"]);if(s){const e=ne({pane:this.pane,attribution:o.attribution,minZoom:o.minZoom,maxZoom:o.maxZoom,layers:t.layers,format:t.format,transparent:!0},t.nativeOptions);let r;return r=o.headers||o.withCredentials?new Qt(s,(i=ne({},e),te(i,ee({headers:o.headers,withCredentials:o.withCredentials})))):new d.WMS(s,e),r}var i}},OSM:class extends Vt{addLayer(t){return super.addLayer((e=((t,e)=>{for(var s in e||(e={}))Jt.call(e,s)&&Kt(t,s,e[s]);if(qt)for(var s of qt(e))Xt.call(e,s)&&Kt(t,s,e[s]);return t})({name:"OpenStreetMap",attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'},t),Gt(e,Ht({url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}))));var e}}}),me(ye,"controlAdapters",{ZOOM:e.Zoom,ATTRIBUTION:class extends e.Attribution{constructor(t){super(t);const e=t&&t.customAttribution;if(e){let t=[];Array.isArray(e)?t=e:e&&(t=[e]),t.forEach((t=>this.addAttribution(t)))}}}}),me(ye,"Map",m);let fe=ye;export{fe as default};
|
|
2
2
|
//# sourceMappingURL=leaflet-map-adapter.esm-bundler.prod.js.map
|