@nextgis/leaflet-map-adapter 1.18.21 → 1.19.1
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/index.d.ts +2 -2
- package/lib/leaflet-map-adapter.esm-browser.js +74 -74
- package/lib/leaflet-map-adapter.esm-browser.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-browser.prod.js +2 -2
- package/lib/leaflet-map-adapter.esm-browser.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.js +74 -74
- package/lib/leaflet-map-adapter.esm-bundler.js.map +1 -1
- package/lib/leaflet-map-adapter.esm-bundler.prod.js +2 -2
- package/lib/leaflet-map-adapter.esm-bundler.prod.js.map +1 -1
- package/lib/leaflet-map-adapter.global.js +78 -78
- package/lib/leaflet-map-adapter.global.js.map +1 -1
- package/lib/leaflet-map-adapter.global.prod.js +2 -2
- package/lib/leaflet-map-adapter.global.prod.js.map +1 -1
- package/package.json +6 -6
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{EventEmitter as t}from"events";import{Control as e,DomEvent as s,GeoJSON as i,DivIcon as o,Marker as n,CircleMarker as r,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}from"leaflet";import{defined as f,debounce as _}from"@nextgis/utils";import{isPaintCallback as g,isPaint as v}from"@nextgis/paint";function L(t
|
|
1
|
+
import{EventEmitter as t}from"events";import{Control as e,DomEvent as s,GeoJSON as i,DivIcon as o,Marker as n,CircleMarker as r,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}from"leaflet";import{defined as f,debounce as _}from"@nextgis/utils";import{isPaintCallback as g,isPaint as v}from"@nextgis/paint";function L(t,i={},o){return new(e.extend({onAdd(){const e=document.createElement("div"),n=t.onAdd(o);return e.classList.add("leaflet-control"),i.bar&&e.classList.add("leaflet-bar"),i.addClass&&e.classList.add(i.addClass),i.margin||i.bar||(e.style.marginBottom="0px",e.style.marginTop="0px",e.style.marginLeft="0px",e.style.marginRight="0px"),n&&e.appendChild(n),s.disableClickPropagation(e),e},onRemove(){t.onRemove()}}))}function P(t){const e=t.getNorthEast(),s=t.getSouthWest();return[s.lng,s.lat,e.lng,e.lat]}function b(t){const e={};for(let i=0;i<t.length;i++)e[t[i]]=1+(e[t[i]]||0);let s="";for(const i in e){e[i]>(s?e[s]:0)&&(s=i)}return s}const O={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon",GeometryCollection:"polygon"},C={stroke:!1,opacity:1},w={};for(const j in O){const t=O[j],e=w[t]||[];e.push(j),w[t]=e}function x(t,e){return-1!==(w[e]||[]).indexOf(t)}function M(t){const e=new i;return(Array.isArray(t)?t:[t]).forEach((t=>e.addData(t))),e.getBounds()}function T(t){return{getBounds:()=>function(t){return P(M(t))}(t),getCenter:()=>function(t){const{lat:e,lng:s}=M(t).getCenter();return[s,e]}(t)}}class k{constructor(t,e){if(this.map=t,this.options=e,this.pane="order-0",void 0!==e.order){const s="order-"+e.order;let i=t.getPane(s);i||(i=t.createPane(s)),i.style.zIndex=String(Math.round(100*e.order)),this.pane=s}}addLayer(t){Object.assign(this.options,t)}}function S(t){const e=t.containerPoint,s=t.latlng,{lat:i,lng:o}=s;return{latLng:s,lngLat:[o,i],pixel:{left:e.x,top:e.y},source:t}}class Z{constructor(t){this.layer=t}handleMouseEvents(t){const{onClick:e,onLayerClick:s,onMouseOut:i,onMouseOver:o}=this.layer.options,n=e||s;n&&(this._onclick=e=>{const s=!!this.layer._getSelected(t);n({selected:s,...this._createMouseEvent(e)})},t.on("click",this._onclick,this)),i&&(this._mouseout=t=>{i(this._createMouseEvent(t))},t.on("mouseout",this._mouseout,this)),o&&(this._mouseover=t=>{o(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 function({layer:t,source:e}){const s=e.target.feature;return{layer:t,feature:s,event:S(e),source:e,...T(s)}}({layer:this.layer,source:t})}}class E{constructor(t){this.layer=t}setPaintEachLayer(t){this.layer._layers.forEach((e=>{this.setPaint(e,t)}))}setPaint(t,e){let s;const{layer:i,feature:o}=t;if(i&&o&&(g(e)?s=e(o):v(e)&&(s=e),s))if("point"===this.layer.type&&"icon"===s.type){const t=i,e=this._createDivIcon(s);setTimeout((()=>{t.setIcon(e)}),10)}else"setStyle"in i&&i.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[i,o]of e){const e=this.layer.options.opacity;let n=t[o];f(e)&&-1!==o.toLowerCase().indexOf("opacity")&&(n=Number(n)*e),void 0!==n&&Object.defineProperty(s,i,{enumerable:!0,value:n})}return s}return C}_createDivIcon(t){const{html:e,rotate:s,className:i,...n}=t,r=document.createElement("div");i&&(r.className=i),s&&(r.style.transform=`rotateZ(${s}deg)`),e&&(r.innerHTML=e);return new o({className:"",...n,html:r})}createPaintToLayer(t){if(t&&t.type)if("icon"===t.type){if(t.className||t.html)return(e,s)=>{const i=this._createDivIcon(t);return new n(s,{icon:i})}}else if("pin"===t.type)return(t,e)=>new n(e);return(e,s)=>new r(s,this.preparePaint({...C,...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}}function B(t,e,s){const i=new XMLHttpRequest;i.open("GET",t),i.responseType="arraybuffer";for(const o in s)i.setRequestHeader(o,s[o]);return i.onload=function(){const t=new Uint8Array(this.response),s=new Blob([t],{type:"image/png"}),i=(window.URL||window.webkitURL).createObjectURL(s);e(i)},i.send(),()=>{i.abort()}}class z extends l{constructor(t,e,s){super(t,e,s),this._abort=[]}cancelLoad(){this._abort&&(this._abort.forEach((t=>t())),this._abort=[])}_initImage(){super._initImage();const t=this.options.headers;if(t){const e=this._image,s=e.src;e.src="",this._abort.push(B(s,(t=>{e.src=t}),t))}}}
|
|
2
2
|
/*!
|
|
3
3
|
* leaflet.wms.js
|
|
4
4
|
* A collection of Leaflet utilities for working with Web Mapping services.
|
|
5
5
|
* (c) 2014-2016, Houston Engineering, Inc.
|
|
6
6
|
* MIT License
|
|
7
|
-
*/class A extends p{constructor(t,e){super(e),this.defaultWmsParams={service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},this.options={crs:null,uppercase:!1,attribution:"",opacity:1,isBack:!1,minZoom:0,pane:"tilePane",headers:null,viewPortBuffer:0,setViewDelay:100},this._url=t;const s={},i={};let o;for(o in e)o in this.options?i[o]=e[o]:s[o]=e[o];c.setOptions(this,i),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),i=new z(t,s,{opacity:0,pane:this.options.pane,headers:this.options.headers});i.addTo(this._map),this._currentOverlay&&this._currentOverlay.cancelLoad(),i.once("load",(()=>{this._map&&(i._url===this._currentUrl?(this._currentOverlay&&this._map.removeLayer(this._currentOverlay),this._currentOverlay=i,i.setOpacity(void 0!==this.options.opacity?this.options.opacity:1),!0===this.options.isBack&&i.bringToBack(),!1===this.options.isBack&&i.bringToFront(),void 0!==this.options.zIndex&&i.setZIndex(this.options.zIndex)):this._map.removeLayer(i))}),this);const{minZoom:o,maxZoom:n}=this.options;(o&&this._map.getZoom()<o||n&&this._map.getZoom()>n)&&this._map.removeLayer(i)}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),i=t.getSize();if(0!==this.options.viewPortBuffer){const t=e+1;i.x=Math.ceil(i.x*t),i.y=Math.ceil(i.y*t)}const o=parseFloat(this.wmsParams.version),n=this.options.crs||t.options.crs,r=o>=1.3?"crs":"srs";if(n){const t=n.project(s.getNorthWest()),e=n.project(s.getSouthEast()),a={width:i.x,height:i.y};a[r]=n.code,a.bbox=(o>=1.3&&n===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}}function U(t){return class extends t{constructor(...t){super(...t),this.options.setViewDelay&&(this._update=function(t,e=10){let s;function i(...o){i.clear(),s=setTimeout((()=>{s=null,t.apply(this,o)}),e)}return i.clear=function(){s&&(clearTimeout(s),s=null)},i}(((...t)=>{u.prototype._update.call(this,...t)}),this.options.setViewDelay))}createTile(t,e){const s=this.getTileUrl(t),i=document.createElement("img");return i.abort=B(s,(t=>{i.src=t,e(null,i)}),this.options.headers),(this.options.crossOrigin||""===this.options.crossOrigin)&&(i.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),i.alt="",i.setAttribute("role","presentation"),i}_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])}}}}const W=U(class extends m{constructor(t,e){super(t,e),Object.assign(this.options,e)}});class I extends S{addLayer(t){if(this.options=Object.assign(this.options,t),t){const{url:e,...s}=t;if(e){const t={pane:this.pane,attribution:s.attribution,minZoom:s.minZoom,maxZoom:s.maxZoom,...s.nativeOptions};let i;return s.subdomains&&(t.subdomains=s.subdomains),i=s.headers?new W(e,{...t,headers:s.headers,setViewDelay:s.setViewDelay}):new m(e,t),i}}}}const F=U(class extends m.WMS{constructor(t,e){super(t,e)}});function D(t){return[[t[3],t[0]],[t[1],t[2]]]}class R{constructor(){this.options={target:"map"},this.layerAdapters=R.layerAdapters,this.controlAdapters=R.controlAdapters,this.emitter=new t,this._unselectCb=[],this._universalEvents=["move","zoom","zoomend","zoomstart","moveend","movestart"],this._positionEvents=["mousemove","mouseout","mouseover"]}create(t){if(this.options={...t},this.options.target){const{zoom:t,center:e,maxZoom:s,minZoom:i,maxBounds:o,mapAdapterOptions:n}=this.options;this.map=this.options.map||new y(this.options.target,{attributionControl:!1,zoomControl:!1,maxBounds:o?D(o):void 0,maxZoom:s,minZoom:i,center:e&&[e[1],e[0]],zoom:t,...n});const r=this.map.createPane("order-0");this.map._addUnselectCb=t=>{this._addUnselectCb(t)},r.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,[i,o]=s;this.map&&("number"==typeof e?this.map.setView([o,i],e,{animate:!1}):this.setCenter([i,o]))}else{const{zoom:e,center:i,maxBounds:o,bounds:n,minZoom:r,maxZoom:a}=t;if(i&&void 0!==e?this.setView(i,e):(void 0!==e&&this.setZoom(e),i&&this.setCenter(i)),n&&this.fitBounds(n),void 0!==o)if(o){const t=D(o);s.setMaxBounds(t),s.setMinZoom(s.getBoundsZoom(t)),this._watchSizeChangeToUpdateMinZoom(t)}else s.setMaxBounds(null),this._stopWatchSizeChangeToUpdateMinZoom();void 0!==a&&s.setMaxZoom(a),void 0!==r&&(this._stopWatchSizeChangeToUpdateMinZoom(),s.setMinZoom(r))}}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())&&void 0!==t?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:i,padding:o}=e,n={};s&&(n.maxZoom=s),o&&(n.padding=[o,o]),i&&(n.padding=i),this.map.fitBounds(D(t),n)}}getLayerAdapter(t){return R.layerAdapters[t]}createControl(t,e){return P(t,e,this)}createButtonControl(t){return function(t,e){const i=document.createElement("a"),o=t.title||"";i.href="#",i.title=o,i.setAttribute("role","button"),i.setAttribute("aria-label",o),t.addClass&&i.classList.add(t.addClass),s.disableClickPropagation(i),s.on(i,"click",s.stop),t.html instanceof HTMLElement?i.appendChild(t.html):"string"==typeof t.html&&(i.innerHTML=t.html);const n=e=>{e.stopPropagation(),t.onClick()};return P({onAdd:()=>(void 0!==t.onClick&&i.addEventListener("click",n),i),onRemove(){const e=i.parentNode;e&&e.removeChild(i),void 0!==t.onClick&&i.removeEventListener("click",n)}},{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=L(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:i}=e,o=e=>{t({lngLat:[e.latlng.lng,e.latlng.lat]})};void 0!==t&&s.on("locationfound",o,this),i&&s.on("locationerror",i,this);return{stop:()=>{void 0!==t&&s.off("locationfound",o),i&&s.off("locationerror",i)}}}return{stop:()=>{}}}_addUnselectCb(t){for(const e of this._unselectCb)e();this._unselectCb.length=0,this._unselectCb.push(t)}_watchSizeChangeToUpdateMinZoom(t){this._stopWatchSizeChangeToUpdateMinZoom();const e=this.getContainer(),s=this.map;e&&s&&window.ResizeObserver&&(this._resizeObserver=new ResizeObserver((()=>{s.setMinZoom(s.getBoundsZoom(t))})),this._resizeObserver.observe(e))}_stopWatchSizeChangeToUpdateMinZoom(){const t=this.map;t&&t.setMinZoom(0),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);for(const e of this._positionEvents)t.on(e,(t=>this.emitter.emit(e,L(t))),t)}}}R.layerAdapters={GEOJSON:class extends S{constructor(t,e){super(t,e),this.selected=!1,this._layers=[],this._selectedLayers=[],this._filteredLayers=[],this._openedPopup=[],this.$updateTooltip=_((()=>{this.updateTooltip()}),300),this.$unselect=()=>{this.unselect()},this._events=new Z(this),this._paint=new E(this)}addLayer(t){return Object.assign(this.options,t),this.paint=t.paint,this.layer=new a([],{...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=>({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 i=[];this._layers.forEach((({feature:s,layer:o})=>{if(o){!t||t({target:this,feature:s,layer:o,...T(s)})?(e.addLayer(o),i.push({target:this,feature:s,layer:o,...T(s)})):e.removeLayer(o)}})),this._filteredLayers=i,e.addTo(s)}return this._filteredLayers}cleanFilter(){this.filter()}getLayers(){return this._layers.map((({layer:t,feature:e})=>({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 i=this._layers[s];if(i){const{feature:o,layer:n}=i;if(o&&n){t(o)&&(e.removeLayer(n),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 i;if(e.type)i=e.type;else{const e=function(t){let e;e="FeatureCollection"===t.type?k(t.features.map((t=>t.geometry.type))):"GeometryCollection"===t.type?k(t.geometries.map((t=>t.type))):"Feature"===t.type?t.geometry.type:t.type;return e}(t);i=O[e]}if(this.type&&this.type!==i)return void console.warn("no other data type than layer can be added");this.type=i,t=function(t,e){if("FeatureCollection"===t.type)t.features=t.features.filter((t=>x(t.geometry.type,e)));else if("Feature"===t.type){if(!x(t.geometry.type,e))return!1}else"GeometryCollection"===t.type&&(t.geometries=t.geometries.filter((t=>x(t.type,e))));return t}(t,i),t&&(s=this._getGeoJsonOptions(e,i))}new i(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 b(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={...this.paint,...t};for(const e of this._layers)this._paint.setPaint(e,this.paint)}updateSelectedPaint(t){this.selectedPaint={...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;if(e&&s&&e.properties&&this.options.labelField){s.unbindTooltip();const t=e.properties[this.options.labelField];if(void 0!==t){const e=!this.options.labelOnHover;s.bindTooltip(String(t),{permanent:e,sticky:!1})}}}async _openPopup(t,e={},s,i){var o,n;const{feature:r,layer:a}=t,{minWidth:l,autoPan:p,maxWidth:c,closeButton:h}={minWidth:300,...e},u=null!=h?h:!this.options.selectOnHover;let d;const m=[],y=t=>{m.push(t)},_=()=>{d&&this._removePopup(d)};let g;if(g=e.createPopupContent?await e.createPopupContent({layer:a,feature:r,target:this,type:s,close:_,onClose:y,...T(r)}):e.popupContent,g&&a){const e={minWidth:l,autoPan:p,closeButton:u,closeOnClick:!1,autoClose:!1};f(c)&&(e.maxWidth=c),d=a.bindPopup(g,e);if(null===(n=null===(o=this.options.popupOptions)||void 0===o?void 0:o.unselectOnClose)||void 0===n||n){const t=a.getPopup();t&&t.once("remove",(()=>{_()}),this)}this._openedPopup.push([d,m,t]),d.openPopup(i)}}_removePopup(t){var e,s;if(this.map){t.closePopup().unbindPopup();const i=this._openedPopup.findIndex((e=>e[0]===t));if(-1!==i){const t=null===(s=null===(e=this.options.popupOptions)||void 0===e?void 0:e.unselectOnClose)||void 0===s||s,[,o,n]=this._openedPopup[i];for(const e of o)e(n);o.length=0,t&&this._unSelectLayer(n),this._openedPopup.splice(i,1)}}}_getGeoJsonOptions(t,e){const s=t.paint;let i={};return"function"==typeof s?"point"===e?i.pointToLayer=(t,e)=>{const i=s(t);return this._paint.createPaintToLayer(i)(t,e)}:i={style:t=>this._paint.preparePaint(t?{...C,...s(t)}:{...C,type:"path"})}:i=this._paint.createPaintOptions(s),i.onEachFeature=(t,e)=>{this._onEachFeature(t,e)},i}_onEachFeature(t,e){const s=this.layer;if(s){const i={target:this,feature:t,layer:e,...T(t)};e.options.pane=this.pane,this._layers.push(i);let o=!0;if(this._filterFun&&(o=this._filterFun(i)),o){const{popup:o,popupOptions:n,selectable:r,interactive:a,selectOnHover:l}=this.options;e.options.interactive=!f(a)||a,s.addLayer(e),r&&(l?(e.on("mouseover",(()=>{this._selectLayer(i,"hover")})),e.on("mouseout",(()=>{this._unSelectLayer(i)}))):e.on("click",(t=>this._selectOnLayerClick(t)),this)),this._events.handleMouseEvents(e),setTimeout((()=>{o&&this._openPopup({target:this,layer:e,feature:t,...T(t)},n,"api"),this._updateTooltip({layer:e,feature:t})}))}}}_selectOnLayerClick(t){s.stopPropagation(t);const e=t.target,i=e.feature,o={target:this,layer:e,feature:i,...T(i)},n=this._getSelected(e);n?this.options&&this.options.unselectOnSecondClick&&this._unSelectLayer(n):this._selectLayer(o,"click",t.latlng)}_selectLayer(t,e,s){const{multiselect:i}=this.options;i||(this.map._addUnselectCb((()=>{this._unSelectLayer(t)})),this._selectedLayers.forEach((t=>this._unSelectLayer(t)))),this._selectedLayers.push(t),this.selected=!0;const{selectedPaint:o,popupOnSelect:n,popupOptions:r}=this.options;if(o&&t.layer&&this._paint.setPaint(t,o),n&&this._openPopup(t,r,e,s),this.options.onSelect){const s=t.feature?[t.feature]:[];this.options.onSelect({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{labelField:e,labelOnHover:s}=this.options;this._addMapClickListener(),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:class extends S{addLayer(t){const e=t&&t.url;if(e){const s=(t={transparent:!0,...t}).updateWmsParams;if(this.layer=new A(e,{pane:this.pane,headers:t.headers,setViewDelay:t.setViewDelay,...t,...t.params,...t.nativeOptions}),s){const t=this.layer.updateWmsParams;this.layer.updateWmsParams=function(e){t.call(this,e),this.wmsParams=s(this.wmsParams)}}return this.layer}}},TILE:I,WMS:class extends S{addLayer(t){Object.assign(this.options,t);const{url:e,...s}=t;if(e){const i={pane:this.pane,attribution:s.attribution,minZoom:s.minZoom,maxZoom:s.maxZoom,layers:t.layers,format:t.format,...t.nativeOptions};let o;return o=s.headers?new F(e,{...i,headers:s.headers}):new m.WMS(e,i),o}}},OSM:class extends I{addLayer(t){return super.addLayer({name:"OpenStreetMap",attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',...t,url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"})}}},R.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)))}}}},R.Map=y;var V=R;export{V as default};
|
|
7
|
+
*/class A extends p{constructor(t,e){super(e),this.defaultWmsParams={service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},this.options={crs:null,uppercase:!1,attribution:"",opacity:1,isBack:!1,minZoom:0,pane:"tilePane",headers:null,viewPortBuffer:0,setViewDelay:100},this._url=t;const s={},i={};let o;for(o in e)o in this.options?i[o]=e[o]:s[o]=e[o];c.setOptions(this,i),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),i=new z(t,s,{opacity:0,pane:this.options.pane,headers:this.options.headers});i.addTo(this._map),this._currentOverlay&&this._currentOverlay.cancelLoad(),i.once("load",(()=>{this._map&&(i._url===this._currentUrl?(this._currentOverlay&&this._map.removeLayer(this._currentOverlay),this._currentOverlay=i,i.setOpacity(void 0!==this.options.opacity?this.options.opacity:1),!0===this.options.isBack&&i.bringToBack(),!1===this.options.isBack&&i.bringToFront(),void 0!==this.options.zIndex&&i.setZIndex(this.options.zIndex)):this._map.removeLayer(i))}),this);const{minZoom:o,maxZoom:n}=this.options;(o&&this._map.getZoom()<o||n&&this._map.getZoom()>n)&&this._map.removeLayer(i)}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),i=t.getSize();if(0!==this.options.viewPortBuffer){const t=e+1;i.x=Math.ceil(i.x*t),i.y=Math.ceil(i.y*t)}const o=parseFloat(this.wmsParams.version),n=this.options.crs||t.options.crs,r=o>=1.3?"crs":"srs";if(n){const t=n.project(s.getNorthWest()),e=n.project(s.getSouthEast()),a={width:i.x,height:i.y};a[r]=n.code,a.bbox=(o>=1.3&&n===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}}function U(t){return class extends t{constructor(...t){super(...t),this.options.setViewDelay&&(this._update=function(t,e=10){let s;function i(...o){i.clear(),s=setTimeout((()=>{s=null,t.apply(this,o)}),e)}return i.clear=function(){s&&(clearTimeout(s),s=null)},i}(((...t)=>{u.prototype._update.call(this,...t)}),this.options.setViewDelay))}createTile(t,e){const s=this.getTileUrl(t),i=document.createElement("img");return i.abort=B(s,(t=>{i.src=t,e(null,i)}),this.options.headers),(this.options.crossOrigin||""===this.options.crossOrigin)&&(i.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),i.alt="",i.setAttribute("role","presentation"),i}_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])}}}}const W=U(class extends m{constructor(t,e){super(t,e),Object.assign(this.options,e)}});class I extends k{addLayer(t){if(this.options=Object.assign(this.options,t),t){const{url:e,...s}=t;if(e){const t={pane:this.pane,attribution:s.attribution,minZoom:s.minZoom,maxZoom:s.maxZoom,...s.nativeOptions};let i;return s.subdomains&&(t.subdomains=s.subdomains),i=s.headers?new W(e,{...t,headers:s.headers,setViewDelay:s.setViewDelay}):new m(e,t),i}}}}const F=U(class extends m.WMS{constructor(t,e){super(t,e)}});function D(t){return[[t[3],t[0]],[t[1],t[2]]]}class R{constructor(){this.options={target:"map"},this.layerAdapters=R.layerAdapters,this.controlAdapters=R.controlAdapters,this.emitter=new t,this._unselectCb=[],this._universalEvents=["move","zoom","zoomend","zoomstart","moveend","movestart"],this._positionEvents=["mousemove","mouseout","mouseover"]}create(t){if(this.options={...t},this.options.target){const{zoom:t,center:e,maxZoom:s,minZoom:i,maxBounds:o,mapAdapterOptions:n}=this.options;this.map=this.options.map||new y(this.options.target,{attributionControl:!1,zoomControl:!1,maxBounds:o?D(o):void 0,maxZoom:s,minZoom:i,center:e&&[e[1],e[0]],zoom:t,...n});const r=this.map.createPane("order-0");this.map._addUnselectCb=t=>{this._addUnselectCb(t)},r.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,[i,o]=s;this.map&&("number"==typeof e?this.map.setView([o,i],e,{animate:!1}):this.setCenter([i,o]))}else{const{zoom:e,center:i,maxBounds:o,bounds:n,minZoom:r,maxZoom:a}=t;if(i&&void 0!==e?this.setView(i,e):(void 0!==e&&this.setZoom(e),i&&this.setCenter(i)),n&&this.fitBounds(n),void 0!==o)if(o){const t=D(o);s.setMaxBounds(t),s.setMinZoom(s.getBoundsZoom(t)),this._watchSizeChangeToUpdateMinZoom(t)}else s.setMaxBounds(null),this._stopWatchSizeChangeToUpdateMinZoom();void 0!==a&&s.setMaxZoom(a),void 0!==r&&(this._stopWatchSizeChangeToUpdateMinZoom(),s.setMinZoom(r))}}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())&&void 0!==t?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:i,padding:o}=e,n={};s&&(n.maxZoom=s),o&&(n.padding=[o,o]),i&&(n.padding=i),this.map.fitBounds(D(t),n)}}getLayerAdapter(t){return R.layerAdapters[t]}createControl(t,e){return L(t,e,this)}createButtonControl(t){return function(t,e){const i=document.createElement("a"),o=t.title||"";i.href="#",i.title=o,i.setAttribute("role","button"),i.setAttribute("aria-label",o),t.addClass&&i.classList.add(t.addClass),s.disableClickPropagation(i),s.on(i,"click",s.stop),t.html instanceof HTMLElement?i.appendChild(t.html):"string"==typeof t.html&&(i.innerHTML=t.html);const n=e=>{e.stopPropagation(),t.onClick()};return L({onAdd:()=>(void 0!==t.onClick&&i.addEventListener("click",n),i),onRemove(){const e=i.parentNode;e&&e.removeChild(i),void 0!==t.onClick&&i.removeEventListener("click",n)}},{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=S(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:i}=e,o=e=>{t({lngLat:[e.latlng.lng,e.latlng.lat]})};void 0!==t&&s.on("locationfound",o,this),i&&s.on("locationerror",i,this);return{stop:()=>{void 0!==t&&s.off("locationfound",o),i&&s.off("locationerror",i)}}}return{stop:()=>{}}}_addUnselectCb(t){for(const e of this._unselectCb)e();this._unselectCb.length=0,this._unselectCb.push(t)}_watchSizeChangeToUpdateMinZoom(t){this._stopWatchSizeChangeToUpdateMinZoom();const e=this.getContainer(),s=this.map;e&&s&&window.ResizeObserver&&(this._resizeObserver=new ResizeObserver((()=>{s.setMinZoom(s.getBoundsZoom(t))})),this._resizeObserver.observe(e))}_stopWatchSizeChangeToUpdateMinZoom(){const t=this.map;t&&t.setMinZoom(0),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);for(const e of this._positionEvents)t.on(e,(t=>this.emitter.emit(e,S(t))),t)}}}R.layerAdapters={GEOJSON:class extends k{constructor(t,e){super(t,e),this.selected=!1,this._layers=[],this._selectedLayers=[],this._filteredLayers=[],this._openedPopup=[],this.$updateTooltip=_((()=>{this.updateTooltip()}),300),this.$unselect=()=>{this.unselect()},this._events=new Z(this),this._paint=new E(this)}addLayer(t){return Object.assign(this.options,t),this.paint=t.paint,this.layer=new a([],{...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=>({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 i=[];this._layers.forEach((({feature:s,layer:o})=>{if(o){!t||t({target:this,feature:s,layer:o,...T(s)})?(e.addLayer(o),i.push({target:this,feature:s,layer:o,...T(s)})):e.removeLayer(o)}})),this._filteredLayers=i,e.addTo(s)}return this._filteredLayers}cleanFilter(){this.filter()}getLayers(){return this._layers.map((({layer:t,feature:e})=>({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 i=this._layers[s];if(i){const{feature:o,layer:n}=i;if(o&&n){t(o)&&(e.removeLayer(n),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 i;if(e.type)i=e.type;else{const e=function(t){let e;e="FeatureCollection"===t.type?b(t.features.map((t=>t.geometry.type))):"GeometryCollection"===t.type?b(t.geometries.map((t=>t.type))):"Feature"===t.type?t.geometry.type:t.type;return e}(t);i=O[e]}if(this.type&&this.type!==i)return void console.warn("no other data type than layer can be added");this.type=i,t=function(t,e){if("FeatureCollection"===t.type)t.features=t.features.filter((t=>x(t.geometry.type,e)));else if("Feature"===t.type){if(!x(t.geometry.type,e))return!1}else"GeometryCollection"===t.type&&(t.geometries=t.geometries.filter((t=>x(t.type,e))));return t}(t,i),t&&(s=this._getGeoJsonOptions(e,i))}new i(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 P(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={...this.paint,...t};for(const e of this._layers)this._paint.setPaint(e,this.paint)}updateSelectedPaint(t){this.selectedPaint={...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;if(e&&s&&e.properties&&this.options.labelField){s.unbindTooltip();const t=e.properties[this.options.labelField];if(void 0!==t){const e=!this.options.labelOnHover;s.bindTooltip(String(t),{permanent:e,sticky:!1})}}}async _openPopup(t,e={},s,i){var o,n;const{feature:r,layer:a}=t,{minWidth:l,autoPan:p,maxWidth:c,closeButton:h}={minWidth:300,...e},u=null!=h?h:!this.options.selectOnHover;let d;const m=[],y=t=>{m.push(t)},_=()=>{d&&this._removePopup(d)};let g;if(g=e.createPopupContent?await e.createPopupContent({layer:a,feature:r,target:this,type:s,close:_,onClose:y,...T(r)}):e.popupContent,g&&a){const e={minWidth:l,autoPan:p,closeButton:u,closeOnClick:!1,autoClose:!1};f(c)&&(e.maxWidth=c),d=a.bindPopup(g,e);if(null===(n=null===(o=this.options.popupOptions)||void 0===o?void 0:o.unselectOnClose)||void 0===n||n){const t=a.getPopup();t&&t.once("remove",(()=>{_()}),this)}this._openedPopup.push([d,m,t]),d.openPopup(i)}}_removePopup(t){var e,s;if(this.map){t.closePopup().unbindPopup();const i=this._openedPopup.findIndex((e=>e[0]===t));if(-1!==i){const t=null===(s=null===(e=this.options.popupOptions)||void 0===e?void 0:e.unselectOnClose)||void 0===s||s,[,o,n]=this._openedPopup[i];for(const e of o)e(n);o.length=0,t&&this._unSelectLayer(n),this._openedPopup.splice(i,1)}}}_getGeoJsonOptions(t,e){const s=t.paint;let i={};return"function"==typeof s?"point"===e?i.pointToLayer=(t,e)=>{const i=s(t);return this._paint.createPaintToLayer(i)(t,e)}:i={style:t=>this._paint.preparePaint(t?{...C,...s(t)}:{...C,type:"path"})}:i=this._paint.createPaintOptions(s),i.onEachFeature=(t,e)=>{this._onEachFeature(t,e)},i}_onEachFeature(t,e){const s=this.layer;if(s){const i={target:this,feature:t,layer:e,...T(t)};e.options.pane=this.pane,this._layers.push(i);let o=!0;if(this._filterFun&&(o=this._filterFun(i)),o){const{popup:o,popupOptions:n,selectable:r,interactive:a,selectOnHover:l}=this.options;e.options.interactive=!f(a)||a,s.addLayer(e),r&&(l?(e.on("mouseover",(()=>{this._selectLayer(i,"hover")})),e.on("mouseout",(()=>{this._unSelectLayer(i)}))):e.on("click",(t=>this._selectOnLayerClick(t)),this)),this._events.handleMouseEvents(e),setTimeout((()=>{o&&this._openPopup({target:this,layer:e,feature:t,...T(t)},n,"api"),this._updateTooltip({layer:e,feature:t})}))}}}_selectOnLayerClick(t){s.stopPropagation(t);const e=t.target,i=e.feature,o={target:this,layer:e,feature:i,...T(i)},n=this._getSelected(e);n?this.options&&this.options.unselectOnSecondClick&&this._unSelectLayer(n):this._selectLayer(o,"click",t.latlng)}_selectLayer(t,e,s){const{multiselect:i}=this.options;i||(this.map._addUnselectCb((()=>{this._unSelectLayer(t)})),this._selectedLayers.forEach((t=>this._unSelectLayer(t)))),this._selectedLayers.push(t),this.selected=!0;const{selectedPaint:o,popupOnSelect:n,popupOptions:r}=this.options;if(o&&t.layer&&this._paint.setPaint(t,o),n&&this._openPopup(t,r,e,s),this.options.onSelect){const s=t.feature?[t.feature]:[];this.options.onSelect({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{labelField:e,labelOnHover:s}=this.options;this._addMapClickListener(),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:class extends k{addLayer(t){const e=t&&t.url;if(e){const s=(t={transparent:!0,...t}).updateWmsParams;if(this.layer=new A(e,{pane:this.pane,headers:t.headers,setViewDelay:t.setViewDelay,...t,...t.params,...t.nativeOptions}),s){const t=this.layer.updateWmsParams;this.layer.updateWmsParams=function(e){t.call(this,e),this.wmsParams=s(this.wmsParams)}}return this.layer}}},TILE:I,WMS:class extends k{addLayer(t){Object.assign(this.options,t);const{url:e,...s}=t;if(e){const i={pane:this.pane,attribution:s.attribution,minZoom:s.minZoom,maxZoom:s.maxZoom,layers:t.layers,format:t.format,...t.nativeOptions};let o;return o=s.headers?new F(e,{...i,headers:s.headers}):new m.WMS(e,i),o}}},OSM:class extends I{addLayer(t){return super.addLayer({name:"OpenStreetMap",attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors',...t,url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"})}}},R.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)))}}}},R.Map=y;var V=R;export{V as default};
|
|
8
8
|
//# sourceMappingURL=leaflet-map-adapter.esm-bundler.prod.js.map
|