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