@nextgis/leaflet-map-adapter 1.12.0 → 1.13.2
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 +6 -5
- package/lib/leaflet-map-adapter.esm-browser.js +25 -5
- 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 +25 -5
- 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 +25 -5
- 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 +5 -5
|
@@ -12,11 +12,11 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
|
12
12
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
|
-
***************************************************************************** */var b=function(t,e){return(b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(t,e)};function P(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}b(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var O=function(){return(O=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function L(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(t);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(o[n[r]]=t[n[r]])}return o}function w(t,e,o,n){return new(o||(o=Promise))((function(r,i){function a(t){try{p(n.next(t))}catch(e){i(e)}}function s(t){try{p(n.throw(t))}catch(e){i(e)}}function p(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(a,s)}p((n=n.apply(t,e||[])).next())}))}function C(t,e){var o,n,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(s){i=[6,s],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function x(t,e,o){if(o||2===arguments.length)for(var n,r=0,i=e.length;r<i;r++)!n&&r in e||(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return t.concat(n||Array.prototype.slice.call(e))}function S(t){var e=t.containerPoint,o=t.latlng;return{latLng:o,lngLat:[o.lng,o.lat],pixel:{left:e.x,top:e.y},source:t}}function T(t,n,r){return void 0===n&&(n={}),new(e.extend({onAdd:function(){var e=document.createElement("div"),i=t.onAdd(r);return e.classList.add("leaflet-control"),n.bar&&e.classList.add("leaflet-bar"),n.addClass&&e.classList.add(n.addClass),n.margin||n.bar||(e.style.marginBottom="0px",e.style.marginTop="0px",e.style.marginLeft="0px",e.style.marginRight="0px"),i&&e.appendChild(i),o.disableClickPropagation(e),e},onRemove:function(){t.onRemove()}}))}var M=function(t){function e(e){var o=t.call(this,e)||this,n=e&&e.customAttribution;if(n){var r=[];Array.isArray(n)?r=n:n&&(r=[n]),r.forEach((function(t){return o.addAttribution(t)}))}return o}return P(e,t),e}(e.Attribution);function k(t){var e=t.getNorthEast(),o=t.getSouthWest();return[o.lng,o.lat,e.lng,e.lat]}var Z={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon",GeometryCollection:"polygon"},E={stroke:!1,opacity:1},B={};for(var z in Z){var A=Z[z],U=B[A]||[];U.push(z),B[A]=U}function I(t,e){return-1!==(B[e]||[]).indexOf(t)}function W(t){var e=new n;return(Array.isArray(t)?t:[t]).forEach((function(t){return e.addData(t)})),e.getBounds()}function F(t){return{getBounds:function(){return function(t){return k(W(t))}(t)},getCenter:function(){return function(t){var e=W(t).getCenter();return[e.lng,e.lat]}(t)}}}function j(t){for(var e={},o=0;o<t.length;o++)e[t[o]]=1+(e[t[o]]||0);var n="";for(var r in e){e[r]>(n?e[n]:0)&&(n=r)}return n}var D=function(){function t(t,e){if(this.map=t,this.options=e,this.pane="order-0",void 0!==e.order){var o="order-"+e.order,n=t.getPane(o);n||(n=t.createPane(o)),n.style.zIndex=String(Math.round(100*e.order)),this.pane=o}}return t.prototype.addLayer=function(t){Object.assign(this.options,t)},t}(),R=function(t){function e(e,o){var n=t.call(this,e,o)||this;return n.selected=!1,n._layers=[],n._selectedLayers=[],n._filteredLayers=[],n._openedPopup=[],n.$updateTooltip=v((function(){n.updateTooltip()}),300),n.$unselect=function(){n.unselect()},n}return P(e,t),e.prototype.addLayer=function(t){return Object.assign(this.options,t),this.paint=t.paint,this.layer=new r([],O(O({},t.nativeOptions),{pane:this.pane})),this.selectedPaint=t.selectedPaint,t.paint=this.paint,t.data&&this.addData(t.data),this._addMapListener(),this.layer},e.prototype.beforeRemove=function(){this._removeMapListener()},e.prototype.select=function(t){var e=this;t?this._layers.filter(t).forEach((function(t){e._selectLayer(t,"api")})):this.selected||(this.selected=!0,this.selectedPaint&&this._setPaintEachLayer(this.selectedPaint))},e.prototype.unselect=function(t){var e=this;if(t)this._layers.filter(t).forEach((function(t){e._unSelectLayer(t)}));else if(this.selected){for(var o=0,n=this._openedPopup;o<n.length;o++){this._removePopup(n[o][0])}this.paint&&this._setPaintEachLayer(this.paint),this._selectedLayers.length=0,this.selected=!1}},e.prototype.getSelected=function(){var t=this;return this._selectedLayers.map((function(e){return O({target:t,feature:e.feature,layer:e},F(e.feature))}))},e.prototype.getFiltered=function(){return this._filteredLayers},e.prototype.filter=function(t){var e=this;this._filterFun=t;var o=this.layer,n=o&&o._map;if(o&&n){o.remove();var r=[];this._layers.forEach((function(n){var i=n.feature,a=n.layer;a&&(!t||t(O({target:e,feature:i,layer:a},F(i)))?(o.addLayer(a),r.push(O({target:e,feature:i,layer:a},F(i)))):o.removeLayer(a))})),this._filteredLayers=r,o.addTo(n)}return this._filteredLayers},e.prototype.cleanFilter=function(){this.filter()},e.prototype.getLayers=function(){var t=this;return this._layers.map((function(e){var o=e.layer,n=e.feature;return O({feature:n,layer:o,visible:o&&!!o._map,target:t},F(n))}))},e.prototype.clearLayer=function(t){this.unselect();var e=this.layer;if(e)if(t)for(var o=this._layers.length;o--;){var n=this._layers[o];if(n){var r=n.feature,i=n.layer;if(r&&i)t(r)&&(e.removeLayer(i),this._layers.splice(o,1))}}else e.clearLayers(),this._layers=[]},e.prototype.setData=function(t){this.clearLayer(),this.addData(t)},e.prototype.addData=function(t){var e,o=this.options;if(o){if(t){var r=void 0;if(o.type)r=o.type;else{var i=function(t){var e;e="FeatureCollection"===t.type?j(t.features.map((function(t){return t.geometry.type}))):"GeometryCollection"===t.type?j(t.geometries.map((function(t){return t.type}))):"Feature"===t.type?t.geometry.type:t.type;return e}(t);r=Z[i]}if(this.type&&this.type!==r)return void console.warn("no other data type than layer can be added");this.type=r,(t=function(t,e){if("FeatureCollection"===t.type)(o=t).features=o.features.filter((function(t){return I(t.geometry.type,e)}));else if("Feature"===t.type){if(!I(t.geometry.type,e))return!1}else if("GeometryCollection"===t.type){var o;(o=t).geometries=o.geometries.filter((function(t){return I(t.type,e)}))}return t}(t,r))&&(e=this._getGeoJsonOptions(o,r))}new n(t||void 0,e)}},e.prototype.openPopup=function(t,e){var o=this;t&&this._layers.filter(t).forEach((function(t){o._openPopup(t,e,"api")}))},e.prototype.closePopup=function(t){var e=this;(t?this._openedPopup.filter((function(e){return t(e[2])})):this._openedPopup).forEach((function(t){e._removePopup(t[0])}))},e.prototype.updateTooltip=function(t){var e=this;t?this._updateTooltip(t):this.getLayers().forEach((function(t){return e._updateTooltip({feature:t.feature,layer:t.layer})}))},e.prototype.getExtent=function(){return this.getBounds()},e.prototype.getBounds=function(){if(this.layer){var t=this.layer.getBounds();if(t.isValid())return k(t)}},e.prototype.setOpacity=function(t){this.options.opacity=t,this.setPaint(this.paint),this.setSelectedPaint(this.selectedPaint)},e.prototype.setPaint=function(t){if(t){this.paint=t;for(var e=0,o=this._layers;e<o.length;e++){this._setPaint(o[e],t)}}},e.prototype.setSelectedPaint=function(t){if(t){this.selectedPaint=t;for(var e=0,o=this._selectedLayers;e<o.length;e++){this._setPaint(o[e],t)}}},e.prototype.updatePaint=function(t){this.paint=O(O({},this.paint),t);for(var e=0,o=this._layers;e<o.length;e++){this._setPaint(o[e],this.paint)}},e.prototype.updateSelectedPaint=function(t){this.selectedPaint=O(O({},this.selectedPaint),t);for(var e=0,o=this._selectedLayers;e<o.length;e++){this._setPaint(o[e],this.selectedPaint)}},e.prototype._updateTooltip=function(t){var e=t.feature,o=t.layer;if(e&&o&&e.properties&&this.options.labelField){o.unbindTooltip();var n=e.properties[this.options.labelField];if(void 0!==n){var r=!this.options.labelOnHover;o.bindTooltip(String(n),{permanent:r,sticky:!1})}}},e.prototype._openPopup=function(t,e,o,n){var r,i;return void 0===e&&(e={}),w(this,void 0,void 0,(function(){var a,s,p,u,c,l,h,f,y,d,v,_,g,b,P,L=this;return C(this,(function(w){switch(w.label){case 0:return a=t.feature,s=t.layer,p=O({minWidth:300},e),u=p.minWidth,c=p.autoPan,l=p.maxWidth,f=null!=(h=p.closeButton)?h:!this.options.selectOnHover,d=[],v=function(t){d.push(t)},_=function(){y&&L._removePopup(y)},e.createPopupContent?[4,e.createPopupContent(O({layer:s,feature:a,target:this,type:o,close:_,onClose:v},F(a)))]:[3,2];case 1:return g=w.sent(),[3,3];case 2:g=e.popupContent,w.label=3;case 3:return g&&s&&(b={minWidth:u,autoPan:c,closeButton:f,closeOnClick:!1,autoClose:!1},m(l)&&(b.maxWidth=l),y=s.bindPopup(g,b),(null===(i=null===(r=this.options.popupOptions)||void 0===r?void 0:r.unselectOnClose)||void 0===i||i)&&(P=s.getPopup())&&P.once("remove",(function(){_()}),this),this._openedPopup.push([y,d,t]),y.openPopup(n)),[2]}}))}))},e.prototype._removePopup=function(t){var e,o;if(this.map){t.closePopup().unbindPopup();var n=this._openedPopup.findIndex((function(e){return e[0]===t}));if(-1!==n){for(var r=null===(o=null===(e=this.options.popupOptions)||void 0===e?void 0:e.unselectOnClose)||void 0===o||o,i=this._openedPopup[n],a=i[1],s=i[2],p=0,u=a;p<u.length;p++){(0,u[p])(s)}a.length=0,r&&this._unSelectLayer(s),this._openedPopup.splice(n,1)}}},e.prototype._setPaintEachLayer=function(t){var e=this;this._layers.forEach((function(o){e._setPaint(o,t)}))},e.prototype._setPaint=function(t,e){var o=void 0,n=t.layer,r=t.feature;if(n&&r&&(_(e)?o=e(r):g(e)&&(o=e),o))if("point"===this.type&&"icon"===o.type){var i=n,a=this._createDivIcon(o);i.setIcon(a)}else"setStyle"in n&&n.setStyle(this._preparePaint(o))},e.prototype._preparePaint=function(t){if("get-paint"!==t.type){var e="line"===this.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(var n=0,r=e;n<r.length;n++){var i=r[n],a=i[0],s=i[1],p=t[s];m(this.options.opacity)&&-1!==s.toLowerCase().indexOf("opacity")&&(p=Number(p)*this.options.opacity),void 0!==p&&Object.defineProperty(o,a,{enumerable:!0,value:p})}return o}return E},e.prototype._getGeoJsonOptions=function(t,e){var o=this,n=t.paint,r={};return"function"==typeof n?"point"===e?r.pointToLayer=function(t,e){var r=n(t);return o._createPaintToLayer(r)(t,e)}:r={style:function(t){return o._preparePaint(O(O({},E),t?n(t):{type:"path"}))}}:r=this._createPaintOptions(n,e),r.onEachFeature=function(t,e){o._onEachFeature(t,e)},r},e.prototype._onEachFeature=function(t,e){var o=this,n=this.layer;if(n){var r=O({target:this,feature:t,layer:e},F(t));e.options.pane=this.pane,this._layers.push(r);var i=!0;if(this._filterFun&&(i=this._filterFun(r)),i){var a=this.options,s=a.popup,p=a.popupOptions,u=a.selectable,c=a.interactive,l=a.selectOnHover;e.options.interactive=!m(c)||c,n.addLayer(e),u&&(l?(e.on("mouseover",(function(){o._selectLayer(r,"hover")})),e.on("mouseout",(function(){o._unSelectLayer(r)}))):e.on("click",(function(t){return o._selectOnLayerClick(t)}),this)),this._handleMouseEvents(e),setTimeout((function(){s&&o._openPopup(O({target:o,layer:e,feature:t},F(t)),p,"api"),o._updateTooltip({layer:e,feature:t})}))}}},e.prototype._handleMouseEvents=function(t){var e=this,o=this.options,n=o.onMouseOut,r=o.onMouseOver,i=o.onClick||o.onLayerClick;i&&t.on("click",(function(o){var n=!!e._getSelected(t);i(O({selected:n},e._createMouseEvent(o)))}),this),n&&t.on("mouseout",(function(t){n(e._createMouseEvent(t))}),this),r&&t.on("mouseover",(function(t){r(e._createMouseEvent(t))}),this)},e.prototype._createMouseEvent=function(t){return function(t){var e=t.source,o=e.target.feature;return O({layer:t.layer,feature:o,event:S(e),source:e},F(o))}({layer:this,source:t})},e.prototype._getSelected=function(t){return this._selectedLayers.find((function(e){return e.layer===t}))},e.prototype._selectOnLayerClick=function(t){o.stopPropagation(t);var e=t.target,n=e.feature,r=O({target:this,layer:e,feature:n},F(n)),i=this._getSelected(e);i?this.options&&this.options.unselectOnSecondClick&&this._unSelectLayer(i):this._selectLayer(r,"click",t.latlng)},e.prototype._selectLayer=function(t,e,o){var n=this;this.map._addUnselectCb((function(){n._unSelectLayer(t)})),this.options&&!this.options.multiselect&&this._selectedLayers.forEach((function(t){return n._unSelectLayer(t)})),this._selectedLayers.push(t),this.selected=!0;var r=this.options,i=r.selectedPaint,a=r.popupOnSelect,s=r.popupOptions;if(i&&t.layer&&this._setPaint(t,i),a&&this._openPopup(t,s,e,o),this.options.onSelect){var p=t.feature?[t.feature]:[];this.options.onSelect(O({type:e,layer:this,features:p},F(p)))}},e.prototype._unSelectLayer=function(t){var e=this._selectedLayers.indexOf(t);-1!==e&&(this._selectedLayers.splice(e,1),this.options&&(this.options.paint&&this._setPaint(t,this.options.paint),this.options.popupOnSelect&&t.layer&&this._removePopup(t.layer))),this.selected=this._selectedLayers.length>0},e.prototype._createDivIcon=function(t){var e=L(t,[]);return new i(O({className:""},e))},e.prototype._createPaintToLayer=function(t){var e=this;if(t&&t.type)if("icon"===t.type){if(t.className||t.html)return function(o,n){var r=e._createDivIcon(t);return new a(n,{icon:r})}}else if("pin"===t.type)return function(t,e){return new a(e)};return function(o,n){return new s(n,e._preparePaint(O(O({},E),t)))}},e.prototype._createPaintOptions=function(t,e){var o={},n=t&&this._preparePaint(t)||{};return t&&(o.style=function(){return n}),"point"===e?o.pointToLayer=this._createPaintToLayer(t):"line"===e&&(n.stroke=!0),o},e.prototype._addMapListener=function(){var t=this.map;if(t){var e=this.options,o=e.labelField,n=e.labelOnHover,r=e.unselectOnClick;(null==r||r)&&t.on("click",this.$unselect),o&&!n&&(t.on("zoomend",this.$updateTooltip),t.on("moveend",this.$updateTooltip))}},e.prototype._removeMapListener=function(){this.map.off("zoomend",this.$updateTooltip),this.map.off("moveend",this.$updateTooltip),this.map.off("click",this.$unselect)},e}(D);function V(t,e,o){var n=new XMLHttpRequest;for(var r in n.open("GET",t),n.responseType="arraybuffer",o)n.setRequestHeader(r,o[r]);return n.onload=function(){var t=new Uint8Array(this.response),o=new Blob([t],{type:"image/png"}),n=(window.URL||window.webkitURL).createObjectURL(o);e(n)},n.send(),function(){n.abort()}}var G=function(t){function e(e,o,n){var r=t.call(this,e,o,n)||this;return r._abort=[],r}return P(e,t),e.prototype.cancelLoad=function(){this._abort&&(this._abort.forEach((function(t){return t()})),this._abort=[])},e.prototype._initImage=function(){t.prototype._initImage.call(this);var e=this.options.headers;if(e){var o=this._image,n=o.src;o.src="",this._abort.push(V(n,(function(t){o.src=t}),e))}},e}(p),N=function(t){function e(e,o){var n=t.call(this,o)||this;n.defaultWmsParams={service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},n.options={crs:null,uppercase:!1,attribution:"",opacity:1,isBack:!1,minZoom:0,maxZoom:18,pane:"tilePane",headers:null,viewPortBuffer:0,setViewDelay:100},n._url=e;var r,i={},a={};for(r in o)r in n.options?a[r]=o[r]:i[r]=o[r];return u.setOptions(n,a),n.wmsParams=u.extend({},n.defaultWmsParams,i),n}return P(e,t),e.prototype.setParams=function(t){u.extend(this.wmsParams,t),this.update()},e.prototype.getAttribution=function(){return this.options.attribution||""},e.prototype.onAdd=function(){return this.update(),this},e.prototype.onRemove=function(t){return this._currentOverlay&&(this._currentOverlay.cancelLoad(),t.removeLayer(this._currentOverlay),delete this._currentOverlay),this._currentUrl&&delete this._currentUrl,this},e.prototype.getEvents=function(){return{moveend:v(this.update,this.options.setViewDelay)}},e.prototype.update=function(){var t=this;if(this._map){this.updateWmsParams();var e=this.getImageUrl();if(this._currentUrl!==e){this._currentUrl=e;var o=this.options.viewPortBuffer||0,n=this._map.getBounds().pad(o),r=new G(e,n,{opacity:0,pane:this.options.pane,headers:this.options.headers});r.addTo(this._map),this._currentOverlay&&this._currentOverlay.cancelLoad(),r.once("load",(function(){t._map&&(r._url===t._currentUrl?(t._currentOverlay&&t._map.removeLayer(t._currentOverlay),t._currentOverlay=r,r.setOpacity(void 0!==t.options.opacity?t.options.opacity:1),!0===t.options.isBack&&r.bringToBack(),!1===t.options.isBack&&r.bringToFront(),void 0!==t.options.zIndex&&r.setZIndex(t.options.zIndex)):t._map.removeLayer(r))}),this);var i=this.options,a=i.minZoom,s=i.maxZoom;(a&&this._map.getZoom()<a||s&&this._map.getZoom()>s)&&this._map.removeLayer(r)}}},e.prototype.setOpacity=function(t){this.options.opacity=t,this._currentOverlay&&this._currentOverlay.setOpacity(t)},e.prototype.bringToBack=function(){this.options.isBack=!0,this._currentOverlay&&this._currentOverlay.bringToBack()},e.prototype.bringToFront=function(){this.options.isBack=!1,this._currentOverlay&&this._currentOverlay.bringToFront()},e.prototype.setZIndex=function(t){this.options.zIndex=t,this._currentOverlay&&this._currentOverlay.setZIndex(t)},e.prototype.updateWmsParams=function(t){t||(t=this._map);var e=this.options.viewPortBuffer||0,o=t.getBounds().pad(e),n=t.getSize();if(0!==this.options.viewPortBuffer){var r=e+1;n.x=Math.ceil(n.x*r),n.y=Math.ceil(n.y*r)}var i=parseFloat(this.wmsParams.version),a=this.options.crs||t.options.crs,s=i>=1.3?"crs":"srs";if(a){var p=a.project(o.getNorthWest()),l=a.project(o.getSouthEast()),h={width:n.x,height:n.y};h[s]=a.code,h.bbox=(i>=1.3&&a===c.EPSG4326?[l.y,p.x,p.y,l.x]:[p.x,l.y,l.x,p.y]).join(","),u.extend(this.wmsParams,h)}},e.prototype.getImageUrl=function(){var t=u.getParamString(this.wmsParams,this._url,this.options.uppercase||!1);return this._url+t},e}(l),H=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return P(e,t),e.prototype.addLayer=function(t){var e=t&&t.url;if(e){var o=(t=O({transparent:!0},t)).updateWmsParams;if(this.layer=new N(e,O(O(O({pane:this.pane,headers:t.headers,setViewDelay:t.setViewDelay},t),t.params),t.nativeOptions)),o){var n=this.layer.updateWmsParams;this.layer.updateWmsParams=function(t){n.call(this,t),this.wmsParams=o(this.wmsParams)}}return this.layer}},e}(D);
|
|
15
|
+
***************************************************************************** */var b=function(t,e){return(b=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o])})(t,e)};function P(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function o(){this.constructor=t}b(t,e),t.prototype=null===e?Object.create(e):(o.prototype=e.prototype,new o)}var O=function(){return(O=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)};function L(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(t);r<n.length;r++)e.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(t,n[r])&&(o[n[r]]=t[n[r]])}return o}function w(t,e,o,n){return new(o||(o=Promise))((function(r,i){function a(t){try{p(n.next(t))}catch(e){i(e)}}function s(t){try{p(n.throw(t))}catch(e){i(e)}}function p(t){var e;t.done?r(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(a,s)}p((n=n.apply(t,e||[])).next())}))}function C(t,e){var o,n,r,i,a={label:0,sent:function(){if(1&r[0])throw r[1];return r[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(o)throw new TypeError("Generator is already executing.");for(;a;)try{if(o=1,n&&(r=2&i[0]?n.return:i[0]?n.throw||((r=n.return)&&r.call(n),0):n.next)&&!(r=r.call(n,i[1])).done)return r;switch(n=0,r&&(i=[2&i[0],r.value]),i[0]){case 0:case 1:r=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,n=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!(r=a.trys,(r=r.length>0&&r[r.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!r||i[1]>r[0]&&i[1]<r[3])){a.label=i[1];break}if(6===i[0]&&a.label<r[1]){a.label=r[1],r=i;break}if(r&&a.label<r[2]){a.label=r[2],a.ops.push(i);break}r[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(s){i=[6,s],n=0}finally{o=r=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}function x(t,e,o){if(o||2===arguments.length)for(var n,r=0,i=e.length;r<i;r++)!n&&r in e||(n||(n=Array.prototype.slice.call(e,0,r)),n[r]=e[r]);return t.concat(n||Array.prototype.slice.call(e))}function S(t){var e=t.containerPoint,o=t.latlng;return{latLng:o,lngLat:[o.lng,o.lat],pixel:{left:e.x,top:e.y},source:t}}function T(t,n,r){return void 0===n&&(n={}),new(e.extend({onAdd:function(){var e=document.createElement("div"),i=t.onAdd(r);return e.classList.add("leaflet-control"),n.bar&&e.classList.add("leaflet-bar"),n.addClass&&e.classList.add(n.addClass),n.margin||n.bar||(e.style.marginBottom="0px",e.style.marginTop="0px",e.style.marginLeft="0px",e.style.marginRight="0px"),i&&e.appendChild(i),o.disableClickPropagation(e),e},onRemove:function(){t.onRemove()}}))}var M=function(t){function e(e){var o=t.call(this,e)||this,n=e&&e.customAttribution;if(n){var r=[];Array.isArray(n)?r=n:n&&(r=[n]),r.forEach((function(t){return o.addAttribution(t)}))}return o}return P(e,t),e}(e.Attribution);function k(t){var e=t.getNorthEast(),o=t.getSouthWest();return[o.lng,o.lat,e.lng,e.lat]}var E={Point:"point",LineString:"line",MultiPoint:"point",Polygon:"polygon",MultiLineString:"line",MultiPolygon:"polygon",GeometryCollection:"polygon"},Z={stroke:!1,opacity:1},B={};for(var z in E){var A=E[z],U=B[A]||[];U.push(z),B[A]=U}function I(t,e){return-1!==(B[e]||[]).indexOf(t)}function W(t){var e=new n;return(Array.isArray(t)?t:[t]).forEach((function(t){return e.addData(t)})),e.getBounds()}function F(t){return{getBounds:function(){return function(t){return k(W(t))}(t)},getCenter:function(){return function(t){var e=W(t).getCenter();return[e.lng,e.lat]}(t)}}}function j(t){for(var e={},o=0;o<t.length;o++)e[t[o]]=1+(e[t[o]]||0);var n="";for(var r in e){e[r]>(n?e[n]:0)&&(n=r)}return n}var D=function(){function t(t,e){if(this.map=t,this.options=e,this.pane="order-0",void 0!==e.order){var o="order-"+e.order,n=t.getPane(o);n||(n=t.createPane(o)),n.style.zIndex=String(Math.round(100*e.order)),this.pane=o}}return t.prototype.addLayer=function(t){Object.assign(this.options,t)},t}(),R=function(t){function e(e,o){var n=t.call(this,e,o)||this;return n.selected=!1,n._layers=[],n._selectedLayers=[],n._filteredLayers=[],n._openedPopup=[],n.$updateTooltip=v((function(){n.updateTooltip()}),300),n.$unselect=function(){n.unselect()},n}return P(e,t),e.prototype.addLayer=function(t){return Object.assign(this.options,t),this.paint=t.paint,this.layer=new r([],O(O({},t.nativeOptions),{pane:this.pane})),this.selectedPaint=t.selectedPaint,t.paint=this.paint,t.data&&this.addData(t.data),this._addMapListener(),this.layer},e.prototype.beforeRemove=function(){this._removeMapListener()},e.prototype.select=function(t){var e=this;t?this._layers.filter(t).forEach((function(t){e._selectLayer(t,"api")})):this.selected||(this.selected=!0,this.selectedPaint&&this._setPaintEachLayer(this.selectedPaint))},e.prototype.unselect=function(t){var e=this;if(t)this._layers.filter(t).forEach((function(t){e._unSelectLayer(t)}));else if(this.selected){for(var o=0,n=this._openedPopup;o<n.length;o++){this._removePopup(n[o][0])}this.paint&&this._setPaintEachLayer(this.paint),this._selectedLayers.length=0,this.selected=!1}},e.prototype.getSelected=function(){var t=this;return this._selectedLayers.map((function(e){return O({target:t,feature:e.feature,layer:e},F(e.feature))}))},e.prototype.getFiltered=function(){return this._filteredLayers},e.prototype.filter=function(t){var e=this;this._filterFun=t;var o=this.layer,n=o&&o._map;if(o&&n){o.remove();var r=[];this._layers.forEach((function(n){var i=n.feature,a=n.layer;a&&(!t||t(O({target:e,feature:i,layer:a},F(i)))?(o.addLayer(a),r.push(O({target:e,feature:i,layer:a},F(i)))):o.removeLayer(a))})),this._filteredLayers=r,o.addTo(n)}return this._filteredLayers},e.prototype.cleanFilter=function(){this.filter()},e.prototype.getLayers=function(){var t=this;return this._layers.map((function(e){var o=e.layer,n=e.feature;return O({feature:n,layer:o,visible:o&&!!o._map,target:t},F(n))}))},e.prototype.clearLayer=function(t){this.unselect();var e=this.layer;if(e)if(t)for(var o=this._layers.length;o--;){var n=this._layers[o];if(n){var r=n.feature,i=n.layer;if(r&&i)t(r)&&(e.removeLayer(i),this._layers.splice(o,1))}}else e.clearLayers(),this._layers=[]},e.prototype.setData=function(t){this.clearLayer(),this.addData(t)},e.prototype.addData=function(t){var e,o=this.options;if(o){if(t){var r=void 0;if(o.type)r=o.type;else{var i=function(t){var e;e="FeatureCollection"===t.type?j(t.features.map((function(t){return t.geometry.type}))):"GeometryCollection"===t.type?j(t.geometries.map((function(t){return t.type}))):"Feature"===t.type?t.geometry.type:t.type;return e}(t);r=E[i]}if(this.type&&this.type!==r)return void console.warn("no other data type than layer can be added");this.type=r,(t=function(t,e){if("FeatureCollection"===t.type)(o=t).features=o.features.filter((function(t){return I(t.geometry.type,e)}));else if("Feature"===t.type){if(!I(t.geometry.type,e))return!1}else if("GeometryCollection"===t.type){var o;(o=t).geometries=o.geometries.filter((function(t){return I(t.type,e)}))}return t}(t,r))&&(e=this._getGeoJsonOptions(o,r))}new n(t||void 0,e)}},e.prototype.openPopup=function(t,e){var o=this;t&&this._layers.filter(t).forEach((function(t){o._openPopup(t,e,"api")}))},e.prototype.closePopup=function(t){var e=this;(t?this._openedPopup.filter((function(e){return t(e[2])})):this._openedPopup).forEach((function(t){e._removePopup(t[0])}))},e.prototype.updateTooltip=function(t){var e=this;t?this._updateTooltip(t):this.getLayers().forEach((function(t){return e._updateTooltip({feature:t.feature,layer:t.layer})}))},e.prototype.getExtent=function(){return this.getBounds()},e.prototype.getBounds=function(){if(this.layer){var t=this.layer.getBounds();if(t.isValid())return k(t)}},e.prototype.setOpacity=function(t){this.options.opacity=t,this.setPaint(this.paint),this.setSelectedPaint(this.selectedPaint)},e.prototype.setPaint=function(t){if(t){this.paint=t;for(var e=0,o=this._layers;e<o.length;e++){this._setPaint(o[e],t)}}},e.prototype.setSelectedPaint=function(t){if(t){this.selectedPaint=t;for(var e=0,o=this._selectedLayers;e<o.length;e++){this._setPaint(o[e],t)}}},e.prototype.updatePaint=function(t){this.paint=O(O({},this.paint),t);for(var e=0,o=this._layers;e<o.length;e++){this._setPaint(o[e],this.paint)}},e.prototype.updateSelectedPaint=function(t){this.selectedPaint=O(O({},this.selectedPaint),t);for(var e=0,o=this._selectedLayers;e<o.length;e++){this._setPaint(o[e],this.selectedPaint)}},e.prototype._updateTooltip=function(t){var e=t.feature,o=t.layer;if(e&&o&&e.properties&&this.options.labelField){o.unbindTooltip();var n=e.properties[this.options.labelField];if(void 0!==n){var r=!this.options.labelOnHover;o.bindTooltip(String(n),{permanent:r,sticky:!1})}}},e.prototype._openPopup=function(t,e,o,n){var r,i;return void 0===e&&(e={}),w(this,void 0,void 0,(function(){var a,s,p,u,c,l,h,f,y,d,v,_,g,b,P,L=this;return C(this,(function(w){switch(w.label){case 0:return a=t.feature,s=t.layer,p=O({minWidth:300},e),u=p.minWidth,c=p.autoPan,l=p.maxWidth,f=null!=(h=p.closeButton)?h:!this.options.selectOnHover,d=[],v=function(t){d.push(t)},_=function(){y&&L._removePopup(y)},e.createPopupContent?[4,e.createPopupContent(O({layer:s,feature:a,target:this,type:o,close:_,onClose:v},F(a)))]:[3,2];case 1:return g=w.sent(),[3,3];case 2:g=e.popupContent,w.label=3;case 3:return g&&s&&(b={minWidth:u,autoPan:c,closeButton:f,closeOnClick:!1,autoClose:!1},m(l)&&(b.maxWidth=l),y=s.bindPopup(g,b),(null===(i=null===(r=this.options.popupOptions)||void 0===r?void 0:r.unselectOnClose)||void 0===i||i)&&(P=s.getPopup())&&P.once("remove",(function(){_()}),this),this._openedPopup.push([y,d,t]),y.openPopup(n)),[2]}}))}))},e.prototype._removePopup=function(t){var e,o;if(this.map){t.closePopup().unbindPopup();var n=this._openedPopup.findIndex((function(e){return e[0]===t}));if(-1!==n){for(var r=null===(o=null===(e=this.options.popupOptions)||void 0===e?void 0:e.unselectOnClose)||void 0===o||o,i=this._openedPopup[n],a=i[1],s=i[2],p=0,u=a;p<u.length;p++){(0,u[p])(s)}a.length=0,r&&this._unSelectLayer(s),this._openedPopup.splice(n,1)}}},e.prototype._setPaintEachLayer=function(t){var e=this;this._layers.forEach((function(o){e._setPaint(o,t)}))},e.prototype._setPaint=function(t,e){var o=void 0,n=t.layer,r=t.feature;if(n&&r&&(_(e)?o=e(r):g(e)&&(o=e),o))if("point"===this.type&&"icon"===o.type){var i=n,a=this._createDivIcon(o);i.setIcon(a)}else"setStyle"in n&&n.setStyle(this._preparePaint(o))},e.prototype._preparePaint=function(t){if("get-paint"!==t.type){var e="line"===this.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(var n=0,r=e;n<r.length;n++){var i=r[n],a=i[0],s=i[1],p=t[s];m(this.options.opacity)&&-1!==s.toLowerCase().indexOf("opacity")&&(p=Number(p)*this.options.opacity),void 0!==p&&Object.defineProperty(o,a,{enumerable:!0,value:p})}return o}return Z},e.prototype._getGeoJsonOptions=function(t,e){var o=this,n=t.paint,r={};return"function"==typeof n?"point"===e?r.pointToLayer=function(t,e){var r=n(t);return o._createPaintToLayer(r)(t,e)}:r={style:function(t){return o._preparePaint(O(O({},Z),t?n(t):{type:"path"}))}}:r=this._createPaintOptions(n,e),r.onEachFeature=function(t,e){o._onEachFeature(t,e)},r},e.prototype._onEachFeature=function(t,e){var o=this,n=this.layer;if(n){var r=O({target:this,feature:t,layer:e},F(t));e.options.pane=this.pane,this._layers.push(r);var i=!0;if(this._filterFun&&(i=this._filterFun(r)),i){var a=this.options,s=a.popup,p=a.popupOptions,u=a.selectable,c=a.interactive,l=a.selectOnHover;e.options.interactive=!m(c)||c,n.addLayer(e),u&&(l?(e.on("mouseover",(function(){o._selectLayer(r,"hover")})),e.on("mouseout",(function(){o._unSelectLayer(r)}))):e.on("click",(function(t){return o._selectOnLayerClick(t)}),this)),this._handleMouseEvents(e),setTimeout((function(){s&&o._openPopup(O({target:o,layer:e,feature:t},F(t)),p,"api"),o._updateTooltip({layer:e,feature:t})}))}}},e.prototype._handleMouseEvents=function(t){var e=this,o=this.options,n=o.onMouseOut,r=o.onMouseOver,i=o.onClick||o.onLayerClick;i&&t.on("click",(function(o){var n=!!e._getSelected(t);i(O({selected:n},e._createMouseEvent(o)))}),this),n&&t.on("mouseout",(function(t){n(e._createMouseEvent(t))}),this),r&&t.on("mouseover",(function(t){r(e._createMouseEvent(t))}),this)},e.prototype._createMouseEvent=function(t){return function(t){var e=t.source,o=e.target.feature;return O({layer:t.layer,feature:o,event:S(e),source:e},F(o))}({layer:this,source:t})},e.prototype._getSelected=function(t){return this._selectedLayers.find((function(e){return e.layer===t}))},e.prototype._selectOnLayerClick=function(t){o.stopPropagation(t);var e=t.target,n=e.feature,r=O({target:this,layer:e,feature:n},F(n)),i=this._getSelected(e);i?this.options&&this.options.unselectOnSecondClick&&this._unSelectLayer(i):this._selectLayer(r,"click",t.latlng)},e.prototype._selectLayer=function(t,e,o){var n=this;this.map._addUnselectCb((function(){n._unSelectLayer(t)})),this.options&&!this.options.multiselect&&this._selectedLayers.forEach((function(t){return n._unSelectLayer(t)})),this._selectedLayers.push(t),this.selected=!0;var r=this.options,i=r.selectedPaint,a=r.popupOnSelect,s=r.popupOptions;if(i&&t.layer&&this._setPaint(t,i),a&&this._openPopup(t,s,e,o),this.options.onSelect){var p=t.feature?[t.feature]:[];this.options.onSelect(O({type:e,layer:this,features:p},F(p)))}},e.prototype._unSelectLayer=function(t){var e=this._selectedLayers.indexOf(t);-1!==e&&(this._selectedLayers.splice(e,1),this.options&&(this.options.paint&&this._setPaint(t,this.options.paint),this.options.popupOnSelect&&t.layer&&this._removePopup(t.layer))),this.selected=this._selectedLayers.length>0},e.prototype._createDivIcon=function(t){var e=L(t,[]);return new i(O({className:""},e))},e.prototype._createPaintToLayer=function(t){var e=this;if(t&&t.type)if("icon"===t.type){if(t.className||t.html)return function(o,n){var r=e._createDivIcon(t);return new a(n,{icon:r})}}else if("pin"===t.type)return function(t,e){return new a(e)};return function(o,n){return new s(n,e._preparePaint(O(O({},Z),t)))}},e.prototype._createPaintOptions=function(t,e){var o={},n=t&&this._preparePaint(t)||{};return t&&(o.style=function(){return n}),"point"===e?o.pointToLayer=this._createPaintToLayer(t):"line"===e&&(n.stroke=!0),o},e.prototype._addMapListener=function(){var t=this.map;if(t){var e=this.options,o=e.labelField,n=e.labelOnHover,r=e.unselectOnClick;(null==r||r)&&t.on("click",this.$unselect),o&&!n&&(t.on("zoomend",this.$updateTooltip),t.on("moveend",this.$updateTooltip))}},e.prototype._removeMapListener=function(){this.map.off("zoomend",this.$updateTooltip),this.map.off("moveend",this.$updateTooltip),this.map.off("click",this.$unselect)},e}(D);function V(t,e,o){var n=new XMLHttpRequest;for(var r in n.open("GET",t),n.responseType="arraybuffer",o)n.setRequestHeader(r,o[r]);return n.onload=function(){var t=new Uint8Array(this.response),o=new Blob([t],{type:"image/png"}),n=(window.URL||window.webkitURL).createObjectURL(o);e(n)},n.send(),function(){n.abort()}}var G=function(t){function e(e,o,n){var r=t.call(this,e,o,n)||this;return r._abort=[],r}return P(e,t),e.prototype.cancelLoad=function(){this._abort&&(this._abort.forEach((function(t){return t()})),this._abort=[])},e.prototype._initImage=function(){t.prototype._initImage.call(this);var e=this.options.headers;if(e){var o=this._image,n=o.src;o.src="",this._abort.push(V(n,(function(t){o.src=t}),e))}},e}(p),N=function(t){function e(e,o){var n=t.call(this,o)||this;n.defaultWmsParams={service:"WMS",request:"GetMap",version:"1.1.1",layers:"",styles:"",format:"image/jpeg",transparent:!1},n.options={crs:null,uppercase:!1,attribution:"",opacity:1,isBack:!1,minZoom:0,maxZoom:18,pane:"tilePane",headers:null,viewPortBuffer:0,setViewDelay:100},n._url=e;var r,i={},a={};for(r in o)r in n.options?a[r]=o[r]:i[r]=o[r];return u.setOptions(n,a),n.wmsParams=u.extend({},n.defaultWmsParams,i),n}return P(e,t),e.prototype.setParams=function(t){u.extend(this.wmsParams,t),this.update()},e.prototype.getAttribution=function(){return this.options.attribution||""},e.prototype.onAdd=function(){return this.update(),this},e.prototype.onRemove=function(t){return this._currentOverlay&&(this._currentOverlay.cancelLoad(),t.removeLayer(this._currentOverlay),delete this._currentOverlay),this._currentUrl&&delete this._currentUrl,this},e.prototype.getEvents=function(){return{moveend:v(this.update,this.options.setViewDelay)}},e.prototype.update=function(){var t=this;if(this._map){this.updateWmsParams();var e=this.getImageUrl();if(this._currentUrl!==e){this._currentUrl=e;var o=this.options.viewPortBuffer||0,n=this._map.getBounds().pad(o),r=new G(e,n,{opacity:0,pane:this.options.pane,headers:this.options.headers});r.addTo(this._map),this._currentOverlay&&this._currentOverlay.cancelLoad(),r.once("load",(function(){t._map&&(r._url===t._currentUrl?(t._currentOverlay&&t._map.removeLayer(t._currentOverlay),t._currentOverlay=r,r.setOpacity(void 0!==t.options.opacity?t.options.opacity:1),!0===t.options.isBack&&r.bringToBack(),!1===t.options.isBack&&r.bringToFront(),void 0!==t.options.zIndex&&r.setZIndex(t.options.zIndex)):t._map.removeLayer(r))}),this);var i=this.options,a=i.minZoom,s=i.maxZoom;(a&&this._map.getZoom()<a||s&&this._map.getZoom()>s)&&this._map.removeLayer(r)}}},e.prototype.setOpacity=function(t){this.options.opacity=t,this._currentOverlay&&this._currentOverlay.setOpacity(t)},e.prototype.bringToBack=function(){this.options.isBack=!0,this._currentOverlay&&this._currentOverlay.bringToBack()},e.prototype.bringToFront=function(){this.options.isBack=!1,this._currentOverlay&&this._currentOverlay.bringToFront()},e.prototype.setZIndex=function(t){this.options.zIndex=t,this._currentOverlay&&this._currentOverlay.setZIndex(t)},e.prototype.updateWmsParams=function(t){t||(t=this._map);var e=this.options.viewPortBuffer||0,o=t.getBounds().pad(e),n=t.getSize();if(0!==this.options.viewPortBuffer){var r=e+1;n.x=Math.ceil(n.x*r),n.y=Math.ceil(n.y*r)}var i=parseFloat(this.wmsParams.version),a=this.options.crs||t.options.crs,s=i>=1.3?"crs":"srs";if(a){var p=a.project(o.getNorthWest()),l=a.project(o.getSouthEast()),h={width:n.x,height:n.y};h[s]=a.code,h.bbox=(i>=1.3&&a===c.EPSG4326?[l.y,p.x,p.y,l.x]:[p.x,l.y,l.x,p.y]).join(","),u.extend(this.wmsParams,h)}},e.prototype.getImageUrl=function(){var t=u.getParamString(this.wmsParams,this._url,this.options.uppercase||!1);return this._url+t},e}(l),H=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return P(e,t),e.prototype.addLayer=function(t){var e=t&&t.url;if(e){var o=(t=O({transparent:!0},t)).updateWmsParams;if(this.layer=new N(e,O(O(O({pane:this.pane,headers:t.headers,setViewDelay:t.setViewDelay},t),t.params),t.nativeOptions)),o){var n=this.layer.updateWmsParams;this.layer.updateWmsParams=function(t){n.call(this,t),this.wmsParams=o(this.wmsParams)}}return this.layer}},e}(D);
|
|
16
16
|
/*!
|
|
17
17
|
* leaflet.wms.js
|
|
18
18
|
* A collection of Leaflet utilities for working with Web Mapping services.
|
|
19
19
|
* (c) 2014-2016, Houston Engineering, Inc.
|
|
20
20
|
* MIT License
|
|
21
|
-
*/function $(t,e){var o;function n(){for(var r=this,i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];n.clear(),o=setTimeout((function(){o=null,t.apply(r,i)}),e)}return void 0===e&&(e=10),n.clear=function(){o&&(clearTimeout(o),o=null)},n}function q(t){return function(t){function e(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];var n=t.apply(this,e)||this;return n.options.setViewDelay&&(n._update=$((function(){for(var t,e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];(t=h.prototype._update).call.apply(t,x([n],e,!1))}),n.options.setViewDelay)),n}return P(e,t),e.prototype.createTile=function(t,e){var o=this.getTileUrl(t),n=document.createElement("img");return n.abort=V(o,(function(t){n.src=t,e(null,n)}),this.options.headers),(this.options.crossOrigin||""===this.options.crossOrigin)&&(n.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),n.alt="",n.setAttribute("role","presentation"),n},e.prototype._abortLoading=function(){var t=this._tiles,e=this._tileZoom;for(var o in t)if(t[o].coords.z!==e){var n=t[o].el;n.onload=u.falseFn,n.onerror=u.falseFn,n.complete||(n.abort&&n.abort(),n.src=u.emptyImageUrl,f.remove(n),delete t[o])}},e}(t)}var J=q(function(t){function e(e,o){var n=t.call(this,e,o)||this;return Object.assign(n.options,o),n}return P(e,t),e}(y)),X=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return P(e,t),e.prototype.addLayer=function(t){if(this.options=Object.assign(this.options,t),t){var e=t.url,o=L(t,["url"]);if(e){var n=O({pane:this.pane,attribution:o.attribution,minZoom:o.minZoom,maxZoom:o.maxZoom},o.nativeOptions);o.subdomains&&(n.subdomains=o.subdomains);return o.headers?new J(e,O(O({},n),{headers:o.headers,setViewDelay:o.setViewDelay})):new y(e,n)}}},e}(D),K=q(function(t){function e(e,o){return t.call(this,e,o)||this}return P(e,t),e}(y.WMS)),Q=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return P(e,t),e.prototype.addLayer=function(t){Object.assign(this.options,t);var e=t.url,o=L(t,["url"]);if(e){var n=O({pane:this.pane,attribution:o.attribution,minZoom:o.minZoom,maxZoom:o.maxZoom,layers:t.layers,format:t.format},t.nativeOptions);return o.headers?new K(e,O(O({},n),{headers:o.headers})):new y.WMS(e,n)}},e}(D),Y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return P(e,t),e.prototype.addLayer=function(e){return t.prototype.addLayer.call(this,O(O({name:"OpenStreetMap",attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'},e),{url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}))},e}(X);function tt(t){return[[t[3],t[0]],[t[1],t[2]]]}var et=function(){function n(){this.options={target:"map"},this.layerAdapters=n.layerAdapters,this.controlAdapters=n.controlAdapters,this.emitter=new t,this._unselectCb=[],this._universalEvents=["move","zoom","
|
|
21
|
+
*/function $(t,e){var o;function n(){for(var r=this,i=[],a=0;a<arguments.length;a++)i[a]=arguments[a];n.clear(),o=setTimeout((function(){o=null,t.apply(r,i)}),e)}return void 0===e&&(e=10),n.clear=function(){o&&(clearTimeout(o),o=null)},n}function q(t){return function(t){function e(){for(var e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];var n=t.apply(this,e)||this;return n.options.setViewDelay&&(n._update=$((function(){for(var t,e=[],o=0;o<arguments.length;o++)e[o]=arguments[o];(t=h.prototype._update).call.apply(t,x([n],e,!1))}),n.options.setViewDelay)),n}return P(e,t),e.prototype.createTile=function(t,e){var o=this.getTileUrl(t),n=document.createElement("img");return n.abort=V(o,(function(t){n.src=t,e(null,n)}),this.options.headers),(this.options.crossOrigin||""===this.options.crossOrigin)&&(n.crossOrigin=!0===this.options.crossOrigin?"":this.options.crossOrigin),n.alt="",n.setAttribute("role","presentation"),n},e.prototype._abortLoading=function(){var t=this._tiles,e=this._tileZoom;for(var o in t)if(t[o].coords.z!==e){var n=t[o].el;n.onload=u.falseFn,n.onerror=u.falseFn,n.complete||(n.abort&&n.abort(),n.src=u.emptyImageUrl,f.remove(n),delete t[o])}},e}(t)}var J=q(function(t){function e(e,o){var n=t.call(this,e,o)||this;return Object.assign(n.options,o),n}return P(e,t),e}(y)),X=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return P(e,t),e.prototype.addLayer=function(t){if(this.options=Object.assign(this.options,t),t){var e=t.url,o=L(t,["url"]);if(e){var n=O({pane:this.pane,attribution:o.attribution,minZoom:o.minZoom,maxZoom:o.maxZoom},o.nativeOptions);o.subdomains&&(n.subdomains=o.subdomains);return o.headers?new J(e,O(O({},n),{headers:o.headers,setViewDelay:o.setViewDelay})):new y(e,n)}}},e}(D),K=q(function(t){function e(e,o){return t.call(this,e,o)||this}return P(e,t),e}(y.WMS)),Q=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return P(e,t),e.prototype.addLayer=function(t){Object.assign(this.options,t);var e=t.url,o=L(t,["url"]);if(e){var n=O({pane:this.pane,attribution:o.attribution,minZoom:o.minZoom,maxZoom:o.maxZoom,layers:t.layers,format:t.format},t.nativeOptions);return o.headers?new K(e,O(O({},n),{headers:o.headers})):new y.WMS(e,n)}},e}(D),Y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return P(e,t),e.prototype.addLayer=function(e){return t.prototype.addLayer.call(this,O(O({name:"OpenStreetMap",attribution:'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'},e),{url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}))},e}(X);function tt(t){return[[t[3],t[0]],[t[1],t[2]]]}var et=function(){function n(){this.options={target:"map"},this.layerAdapters=n.layerAdapters,this.controlAdapters=n.controlAdapters,this.emitter=new t,this._unselectCb=[],this._universalEvents=["move","zoom","zoomend","zoomstart","moveend","movestart"],this._positionEvents=["mousemove","mouseout","mouseover"]}return n.prototype.create=function(t){var e=this;if(this.options=O({},t),this.options.target){var o=this.options,n=o.zoom,r=o.center,i=o.maxZoom,a=o.minZoom,s=o.maxBounds,p=o.mapAdapterOptions;this.map=this.options.map||new d(this.options.target,O({attributionControl:!1,zoomControl:!1,maxBounds:s?tt(s):void 0,maxZoom:i,minZoom:a,center:r&&[r[1],r[0]],zoom:n},p));var u=this.map.createPane("order-0");this.map._addUnselectCb=function(t){e._addUnselectCb(t)},u.style.zIndex=String(0),this.emitter.emit("create",this),this._addMapListeners()}},n.prototype.destroy=function(){this.map&&this.map.remove(),this._stopWatchSizeChangeToUpdateMinZoom()},n.prototype.getContainer=function(){return this.map&&this.map.getContainer()},n.prototype.getControlContainer=function(){var t=this.map&&this.map._controlContainer;if(t)return t;throw new Error("Leaflet Map is not initialized yet")},n.prototype.setCursor=function(t){this.map&&(this.map.getContainer().style.cursor=t)},n.prototype.setView=function(t,e){var o=this.map;if(o)if(Array.isArray(t)){var n=t[0],r=t[1];this.map&&("number"==typeof e?this.map.setView([r,n],e,{animate:!1}):this.setCenter([n,r]))}else{var i=t.zoom,a=t.center,s=t.maxBounds,p=t.bounds,u=t.minZoom,c=t.maxZoom;if(a&&void 0!==i?this.setView(a,i):(void 0!==i&&this.setZoom(i),a&&this.setCenter(a)),p&&this.fitBounds(p),void 0!==s)if(s){var l=tt(s);o.setMaxBounds(l),o.setMinZoom(o.getBoundsZoom(l)),this._watchSizeChangeToUpdateMinZoom(l)}else o.setMaxBounds(null),this._stopWatchSizeChangeToUpdateMinZoom();void 0!==c&&o.setMaxZoom(c),void 0!==u&&(this._stopWatchSizeChangeToUpdateMinZoom(),o.setMinZoom(u))}},n.prototype.setCenter=function(t){this.map&&this.map.panTo([t[1],t[0]])},n.prototype.getCenter=function(){var t=this.map;if(t){var e=t.getBounds().getCenter();return[e.lng,e.lat]}},n.prototype.setZoom=function(t){this.map&&this.map.setZoom(t)},n.prototype.getZoom=function(){return this.map&&this.map.getZoom()||void 0},n.prototype.getBounds=function(){if(this.map){var t=this.map.getBounds(),e=t.getSouthWest(),o=t.getNorthEast();return[e.lng,e.lat,o.lng,o.lat]}},n.prototype.fitBounds=function(t,e){if(void 0===e&&(e={}),this.map){var o=e.maxZoom,n=e.offset,r=e.padding,i={};o&&(i.maxZoom=o),r&&(i.padding=[r,r]),n&&(i.padding=n),this.map.fitBounds(tt(t),i)}},n.prototype.getLayerAdapter=function(t){return n.layerAdapters[t]},n.prototype.createControl=function(t,e){return T(t,e,this)},n.prototype.createButtonControl=function(t){return function(t,e){var n=document.createElement("a"),r=t.title||"";n.href="#",n.title=r,n.setAttribute("role","button"),n.setAttribute("aria-label",r),t.addClass&&n.classList.add(t.addClass),o.disableClickPropagation(n),o.on(n,"click",o.stop),t.html instanceof HTMLElement?n.appendChild(t.html):"string"==typeof t.html&&(n.innerHTML=t.html);var i=function(e){e.stopPropagation(),t.onClick()};return T({onAdd:function(){return void 0!==t.onClick&&n.addEventListener("click",i),n},onRemove:function(){var e=n.parentNode;e&&e.removeChild(n),void 0!==t.onClick&&n.removeEventListener("click",i)}},{bar:!0},e)}(t,this)},n.prototype.addControl=function(t,e){if(t.options.position=e.replace("-",""),this.map)return this.map.addControl(t),t},n.prototype.removeControl=function(t){this.map&&this.map.removeControl(t)},n.prototype.removeLayer=function(t){t&&t.remove&&t.remove()},n.prototype.showLayer=function(t){this.map&&t.addTo(this.map)},n.prototype.hideLayer=function(t){t.remove()},n.prototype.setLayerOpacity=function(t,e){"setOpacity"in t&&t.setOpacity(e)},n.prototype.setLayerOrder=function(t,e,o){},n.prototype.onMapClick=function(t){var e=S(t);this.emitter.emit("preclick",e),this.emitter.emit("click",e)},n.prototype.locate=function(t,e){var o=this.map;if(o&&(o.locate(t),e)){var n=e.locationfound,r=e.locationerror,i=function(t){n({lngLat:[t.latlng.lng,t.latlng.lat]})};void 0!==n&&o.on("locationfound",i,this),r&&o.on("locationerror",r,this);return{stop:function(){void 0!==n&&o.off("locationfound",i),r&&o.off("locationerror",r)}}}return{stop:function(){}}},n.prototype._addUnselectCb=function(t){for(var e=0,o=this._unselectCb;e<o.length;e++){(0,o[e])()}this._unselectCb.length=0,this._unselectCb.push(t)},n.prototype._watchSizeChangeToUpdateMinZoom=function(t){this._stopWatchSizeChangeToUpdateMinZoom();var e=this.getContainer(),o=this.map;e&&o&&window.ResizeObserver&&(this._resizeObserver=new ResizeObserver((function(){o.setMinZoom(o.getBoundsZoom(t))})),this._resizeObserver.observe(e))},n.prototype._stopWatchSizeChangeToUpdateMinZoom=function(){var t=this.map;t&&t.setMinZoom(0),this._resizeObserver&&(this._resizeObserver.disconnect(),this._resizeObserver=void 0)},n.prototype._addMapListeners=function(){var t=this,e=this.map;if(e){e.on("click",(function(e){t.onMapClick(e)}));for(var o=function(o){e.on(o,(function(){return t.emitter.emit(o,t)}),e)},n=0,r=this._universalEvents;n<r.length;n++){o(r[n])}for(var i=function(o){e.on(o,(function(e){return t.emitter.emit(o,S(e))}),e)},a=0,s=this._positionEvents;a<s.length;a++){i(s[a])}}},n.layerAdapters={GEOJSON:R,IMAGE:H,TILE:X,WMS:Q,OSM:Y},n.controlAdapters={ZOOM:e.Zoom,ATTRIBUTION:M},n.Map=d,n}();export{et as default};
|
|
22
22
|
//# sourceMappingURL=leaflet-map-adapter.esm-bundler.prod.js.map
|