diff --git a/src/dist/layer.js b/src/dist/layer.js index f3d1db9..fd3cb82 100644 --- a/src/dist/layer.js +++ b/src/dist/layer.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 22-08-2024 */ +/*! @maps4html/mapml 28-08-2024 */ import"./leaflet.js";import"./mapml.js";class MapLayer extends HTMLElement{static get observedAttributes(){return["src","label","checked","hidden","opacity"]}#hasConnected;get src(){return this.hasAttribute("src")?this.getAttribute("src"):""}set src(e){e&&this.setAttribute("src",e)}get label(){return this._layer?this._layer.getName():this.hasAttribute("label")?this.getAttribute("label"):""}set label(e){e&&this.setAttribute("label",e)}get checked(){return this.hasAttribute("checked")}set checked(e){e?this.setAttribute("checked",""):this.removeAttribute("checked")}get hidden(){return this.hasAttribute("hidden")}set hidden(e){e?this.setAttribute("hidden",""):this.removeAttribute("hidden")}get opacity(){return+(this._opacity??this.getAttribute("opacity"))}set opacity(e){1<+e||+e<0||this.setAttribute("opacity",e)}get extent(){return this._layer&&!this._layer.bounds&&this._layer._calculateBounds(),this._layer?Object.assign(M._convertAndFormatPCRS(this._layer.bounds,M[this.getProjection()],this.getProjection()),{zoom:this._layer.zoomBounds}):null}attributeChangedCallback(e,t,r){if(this.#hasConnected)switch(e){case"label":this._layer.setName(r);break;case"checked":"string"==typeof r?this.parentElement._map.addLayer(this._layer):this.parentElement._map.removeLayer(this._layer),this._layerControlCheckbox.checked=this.checked,this.dispatchEvent(new CustomEvent("map-change"));break;case"hidden":"string"==typeof r?this._layerControl.removeLayer(this._layer):(this._layerControl.addOrUpdateOverlay(this._layer,this.label),this._validateDisabled());break;case"opacity":t!==r&&this._layer&&(this._opacity=r,this._layer.changeOpacity(r));break;case"src":t!==r&&(this._onRemove(),this.isConnected&&this._onAdd())}}constructor(){super(),this._opacity=this.opacity||1,this._renderingMapContent=M.options.contentPreference,this.attachShadow({mode:"open"})}disconnectedCallback(){this.hasAttribute("data-moving")||this._onRemove()}_onRemove(){this._observer&&this._observer.disconnect();let e=this._layer,t=this._layerControl;this._layerControlHTML;delete this._layer,delete this._layerControl,delete this._layerControlHTML,delete this._fetchError,this.shadowRoot.innerHTML="",this.src&&(this.innerHTML=""),e&&e.off(),e&&e._map&&e._map.removeLayer(e),t&&!this.hidden&&t.removeLayer(e)}connectedCallback(){if(!this.hasAttribute("data-moving")){this.#hasConnected=!0,this._createLayerControlHTML=M._createLayerControlHTML.bind(this);const e=this._onAdd.bind(this),t=this._onRemove.bind(this);this.parentElement.whenReady().then(()=>{t(),e()}).catch(e=>{throw new Error("Map never became ready: "+e)})}}_onAdd(){new Promise((e,a)=>{this.addEventListener("changestyle",function(e){e.stopPropagation(),e.detail&&(this._renderingMapContent=e.detail._renderingMapContent,this.src=e.detail.src)},{once:!0}),this.addEventListener("zoomchangesrc",function(e){e.stopPropagation(),this.src=e.detail.href},{once:!0});let t=this.baseURI||document.baseURI;const r=new Headers;if(r.append("Accept","text/mapml"),this.src)fetch(this.src,{headers:r}).then(e=>{if(!e.ok)throw new Error("HTTP error! Status: "+e.status);return e.text()}).then(e=>{let t=(new DOMParser).parseFromString(e,"text/xml");if(t.querySelector("parsererror")||!t.querySelector("mapml-"))throw this._fetchError=!0,console.log("Error fetching layer content:\n\n"+e+"\n"),new Error("Parser error");return t}).then(e=>{this.copyRemoteContentToShadowRoot(e.querySelector("mapml-"));let t=this.shadowRoot.querySelectorAll("*"),r=[];for(let e=0;e{this.selectAlternateOrChangeProjection(),this.checkForPreferredContent()}).then(()=>{this._layer=M.mapMLLayer(new URL(this.src,t).href,this,{projection:this.getProjection(),opacity:this.opacity}),this._createLayerControlHTML(),this._attachedToMap(),this._runMutationObserver(this.shadowRoot.children),this._bindMutationObserver(),this._validateDisabled(),this.dispatchEvent(new CustomEvent("loadedmetadata",{detail:{target:this}})),e()}).catch(e=>{a(e)});else{let t=this.querySelectorAll("*"),r=[];for(let e=0;e{this.selectAlternateOrChangeProjection(),this.checkForPreferredContent()}).then(()=>{this._layer=M.mapMLLayer(null,this,{projection:this.getProjection(),opacity:this.opacity}),this._createLayerControlHTML(),this._attachedToMap(),this._runMutationObserver(this.children),this._bindMutationObserver(),this._validateDisabled(),this.dispatchEvent(new CustomEvent("loadedmetadata",{detail:{target:this}})),e()}).catch(e=>{a(e)})}}).catch(e=>{"changeprojection"===e.message?e.cause.href?(console.log("Changing layer src to: "+e.cause.href),this.src=e.cause.href):e.cause.mapprojection&&(console.log("Changing map projection to match layer: "+e.cause.mapprojection),this.parentElement.projection=e.cause.mapprojection):"findmatchingpreferredcontent"===e.message?e.cause.href&&(console.log("Changing layer to matching preferred content at: "+e.cause.href),this.src=e.cause.href):"Failed to fetch"===e.message?this._fetchError=!0:(console.log(e),this.dispatchEvent(new CustomEvent("error",{detail:{target:this}})))})}selectAlternateOrChangeProjection(){let e=this.src?this.shadowRoot:this,t=this.getProjection()!==this.parentElement.projection&&e.querySelector("map-link[rel=alternate][projection="+this.parentElement.projection+"][href]");if(t){var r=new URL(t.getAttribute("href"),t.getBase()).href;throw new Error("changeprojection",{cause:{href:r}})}r=this.getProjection();if(r!==this.parentElement.projection&&1===this.parentElement.layers.length)throw new Error("changeprojection",{cause:{mapprojection:r}})}checkForPreferredContent(){let e=this.src?this.shadowRoot:this,t=e.querySelector(`map-link[rel="style"][media="prefers-map-content=${this._renderingMapContent}"][href]`);if(t){var r=new URL(t.getAttribute("href"),t.getBase()).href;throw new Error("findmatchingpreferredcontent",{cause:{href:r}})}}copyRemoteContentToShadowRoot(e){let t=this.shadowRoot,r=document.createDocumentFragment();var a=e.querySelectorAll("map-head > *, map-body > *");for(let e=0;e{var r=t[0].attributes.units.value;let a=!0;for(let e=0;e{this.whenReady().then(()=>{delete this._layer.bounds,e.addFeature(this._layer._mapmlvectors)})},i=e=>{this.whenReady().then(()=>{this._layer.appendStyleLink(e)})},s=e=>{this.whenReady().then(()=>{this._layer.appendStyleElement(e)})},o=e=>{this.whenReady().then(()=>{delete this._layer.bounds,this._validateDisabled()})};let n=this.src?this.shadowRoot:this,h=n instanceof ShadowRoot?":host":":scope";var l=e=>{this.whenReady().then(()=>{this._layer._calculateBounds(),this._validateDisabled()})};for(let t=0;t [name=${e.getAttribute("name")}]`)&&e.hasAttribute("content")&&l(e)}}}_bindMutationObserver(){this._observer=new MutationObserver(e=>{for(var t of e)"childList"===t.type&&this._runMutationObserver(t.addedNodes)}),this._observer.observe(this.src?this.shadowRoot:this,{childList:!0})}_attachedToMap(){for(var e=0,t=1,r=this.parentNode.children;e{let s=this._layer,e=s?._map;if(e){this._validateLayerZoom({zoom:e.getZoom()});const o=(this.src?this.shadowRoot:this).querySelectorAll("map-extent");let t=[];for(let e=0;e{let t=0,r=0,a=["_staticTileLayer","_mapmlvectors","_extentLayer"];for(let e=0;e{console.log(e)})}},0)}_validateLayerZoom(e){var t=e.zoom,r=this.extent.zoom.minZoom,a=this.extent.zoom.maxZoom,i=(this.src?this.shadowRoot:this).querySelector("map-link[rel=zoomin]"),e=(this.src?this.shadowRoot:this).querySelector("map-link[rel=zoomout]");let s;r<=t&&t<=a||(i&&a{e.disabled=!0}))):(e.disabled=!1,a.disabled=!1,t.style.fontStyle="normal",r.style.fontStyle="normal",i&&(i.style.fontStyle="normal",i.querySelectorAll("input").forEach(e=>{e.disabled=!1})))}queryable(){let e=this.src?this.shadowRoot:this;return e.querySelector("map-extent[checked] > map-link[rel=query]")&&this.checked&&this._layer&&!this.hidden}getAlternateStyles(e){if(1{e.hasAttribute("href")?e.setAttribute("href",decodeURI(new URL(e.attributes.href.value,this.baseURI||document.baseURI).href)):e.hasAttribute("tref")&&e.setAttribute("tref",decodeURI(new URL(e.attributes.tref.value,this.baseURI||document.baseURI).href))})}var e=t.outerHTML;return t.remove(),e}zoomTo(){this.whenReady().then(()=>{let e=this.parentElement._map,t=this.extent,r=t.topLeft.pcrs,a=t.bottomRight.pcrs,i=L.bounds(L.point(r.horizontal,r.vertical),L.point(a.horizontal,a.vertical)),s=e.options.crs.unproject(i.getCenter(!0));var o=t.zoom.maxZoom,n=t.zoom.minZoom;e.setView(s,M.getMaxZoom(i,e,n,o),{animate:!1})})}mapml2geojson(e={}){return M.mapml2geojson(this,e)}pasteFeature(e){switch(typeof e){case"string":e.trim(),""===e.slice(-14)&&this.insertAdjacentHTML("beforeend",e);break;case"object":"MAP-FEATURE"===e.nodeName.toUpperCase()&&this.appendChild(e)}}whenReady(){return new Promise((t,r)=>{let a,i;this._layer&&this._layerControlHTML&&(!this.src||this.shadowRoot?.childNodes.length)?t():(a=setInterval(function(e){e._layer&&e._layerControlHTML&&(!e.src||e.shadowRoot?.childNodes.length)?(clearInterval(a),clearTimeout(i),t()):e._fetchError&&(clearInterval(a),clearTimeout(i),r("Error fetching layer content"))},200,this),i=setTimeout(function(){clearInterval(a),clearTimeout(i),r("Timeout reached waiting for layer to be ready")},5e3))})}whenElemsReady(){let e=[],t=this.src?this.shadowRoot:this;for(var r of[...t.querySelectorAll("map-extent"),...t.querySelectorAll("map-feature")])e.push(r.whenReady());return Promise.allSettled(e)}}export{MapLayer}; //# sourceMappingURL=layer.js.map \ No newline at end of file diff --git a/src/dist/leaflet.js b/src/dist/leaflet.js index aeb3cd9..cbf0007 100644 --- a/src/dist/leaflet.js +++ b/src/dist/leaflet.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 22-08-2024 */ +/*! @maps4html/mapml 28-08-2024 */ !function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self).leaflet={})}(this,function(t){"use strict";function l(t){for(var i,e,s=1,n=arguments.length;s=this.min.x&&e.x<=this.max.x&&i.y>=this.min.y&&e.y<=this.max.y},intersects:function(t){t=B(t);var i=this.min,e=this.max,s=t.min,n=t.max,t=n.x>=i.x&&s.x<=e.x,e=n.y>=i.y&&s.y<=e.y;return t&&e},overlaps:function(t){t=B(t);var i=this.min,e=this.max,s=t.min,n=t.max,t=n.x>i.x&&s.xi.y&&s.y=s.lat&&e.lat<=n.lat&&i.lng>=s.lng&&e.lng<=n.lng},intersects:function(t){t=R(t);var i=this._southWest,e=this._northEast,s=t.getSouthWest(),n=t.getNorthEast(),t=n.lat>=i.lat&&s.lat<=e.lat,e=n.lng>=i.lng&&s.lng<=e.lng;return t&&e},overlaps:function(t){t=R(t);var i=this._southWest,e=this._northEast,s=t.getSouthWest(),n=t.getNorthEast(),t=n.lat>i.lat&&s.lati.lng&&s.lng","http://www.w3.org/2000/svg"===(Tt.firstChild&&Tt.firstChild.namespaceURI));function St(t){return 0<=navigator.userAgent.toLowerCase().indexOf(t)}var Et={ie:Y,ielt9:$,edge:tt,webkit:it,android:et,android23:st,androidStock:ot,opera:at,chrome:rt,gecko:ht,safari:lt,phantom:ct,opera12:ut,win:dt,ie3d:_t,webkit3d:pt,gecko3d:mt,any3d:ft,mobile:gt,mobileWebkit:vt,mobileWebkit3d:yt,msPointer:Mt,pointer:xt,touch:bt,touchNative:wt,mobileOpera:Pt,mobileGecko:F,retina:Lt,passiveEvents:Ct,canvas:nt,svg:Q,vml:!Q&&function(){try{var t=document.createElement("div");t.innerHTML='';var i=t.firstChild;return i.style.behavior="url(#default#VML)",i&&"object"==typeof i.adj}catch(t){return!1}}(),inlineSvg:Tt,mac:0===navigator.platform.indexOf("Mac"),linux:0===navigator.platform.indexOf("Linux")},kt=Et.msPointer?"MSPointerDown":"pointerdown",zt=Et.msPointer?"MSPointerMove":"pointermove",At=Et.msPointer?"MSPointerUp":"pointerup",Ot=Et.msPointer?"MSPointerCancel":"pointercancel",It={touchstart:kt,touchmove:zt,touchend:At,touchcancel:Ot},Zt={touchstart:function(t,i){i.MSPOINTER_TYPE_TOUCH&&i.pointerType===i.MSPOINTER_TYPE_TOUCH&&Oi(i);Gt(t,i)},touchmove:Gt,touchend:Gt,touchcancel:Gt},Bt={},Nt=!1;function Rt(t,i,e){return"touchstart"===i&&(Nt||(document.addEventListener(kt,jt,!0),document.addEventListener(zt,Dt,!0),document.addEventListener(At,qt,!0),document.addEventListener(Ot,qt,!0),Nt=!0)),Zt[i]?(e=Zt[i].bind(this,e),t.addEventListener(It[i],e,!1),e):(console.warn("wrong event specified:",i),c)}function jt(t){Bt[t.pointerId]=t}function Dt(t){Bt[t.pointerId]&&(Bt[t.pointerId]=t)}function qt(t){delete Bt[t.pointerId]}function Gt(t,i){if(i.pointerType!==(i.MSPOINTER_TYPE_MOUSE||"mouse")){for(var e in i.touches=[],Bt)i.touches.push(Bt[e]);i.changedTouches=[i],t(i)}}var Ft=200;function Ht(t,e){t.addEventListener("dblclick",e);var s,n=0;function i(t){var i;1===t.detail?"mouse"===t.pointerType||t.sourceCapabilities&&!t.sourceCapabilities.firesTouchEvents||((i=Zi(t)).some(function(t){return t instanceof HTMLLabelElement&&t.attributes.for})&&!i.some(function(t){return t instanceof HTMLInputElement||t instanceof HTMLSelectElement})||((i=Date.now())-n<=Ft?2===++s&&e(function(t){var i,e,s={};for(e in t)i=t[e],s[e]=i&&i.bind?i.bind(t):i;return(t=s).type="dblclick",s.detail=2,s.isTrusted=!1,s._simulated=!0,s}(t)):s=1,n=i)):s=t.detail}return t.addEventListener("click",i),{dblclick:e,simDblclick:i}}var Ut,Wt,Vt,Kt,Xt,Jt,Qt=_i(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),Yt=_i(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),$t="webkitTransition"===Yt||"OTransition"===Yt?Yt+"End":"transitionend";function ti(t){return"string"==typeof t?document.getElementById(t):t}function ii(t,i){var e=t.style[i]||t.currentStyle&&t.currentStyle[i];return"auto"===(e=(!e||"auto"===e)&&document.defaultView?(t=document.defaultView.getComputedStyle(t,null))?t[i]:null:e)?null:e}function ei(t,i,e){t=document.createElement(t);return t.className=i||"",e&&e.appendChild(t),t}function si(t){var i=t.parentNode;i&&i.removeChild(t)}function ni(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function oi(t){var i=t.parentNode;i&&i.lastChild!==t&&i.appendChild(t)}function ai(t){var i=t.parentNode;i&&i.firstChild!==t&&i.insertBefore(t,i.firstChild)}function ri(t,i){if(void 0!==t.classList)return t.classList.contains(i);t=ui(t);return 0this.options.maxZoom)?this.setZoom(t):this},panInsideBounds:function(t,i){this._enforcingBounds=!0;var e=this.getCenter(),t=this._limitCenter(e,this._zoom,R(t));return e.equals(t)||this.panTo(t,i),this._enforcingBounds=!1,this},panInside:function(t,i){var e=I((i=i||{}).paddingTopLeft||i.padding||[0,0]),s=I(i.paddingBottomRight||i.padding||[0,0]),n=this.project(this.getCenter()),o=this.project(t),t=this.getPixelBounds(),e=B([t.min.add(e),t.max.subtract(s)]),t=e.getSize();return e.contains(o)||(this._enforcingBounds=!0,s=o.subtract(e.getCenter()),t=e.extend(o).getSize().subtract(t),n.x+=s.x<0?-t.x:t.x,n.y+=s.y<0?-t.y:t.y,this.panTo(this.unproject(n),i),this._enforcingBounds=!1),this},invalidateSize:function(t){if(!this._loaded)return this;t=l({animate:!1,pan:!0},!0===t?{animate:!0}:t);var i=this.getSize();this._sizeChanged=!0,this._lastCenter=null;var e=this.getSize(),s=i.divideBy(2).round(),n=e.divideBy(2).round(),n=s.subtract(n);return n.x||n.y?(t.animate&&t.pan?this.panBy(n):(t.pan&&this._rawPanBy(n),this.fire("move"),t.debounceMoveend?(clearTimeout(this._sizeTimer),this._sizeTimer=setTimeout(r(this.fire,this,"moveend"),200)):this.fire("moveend")),this.fire("resize",{oldSize:i,newSize:e})):this},stop:function(){return this.setZoom(this._limitZoom(this._zoom)),this.options.zoomSnap||this.fire("viewreset"),this._stop()},locate:function(t){if(t=this._locateOptions=l({timeout:1e4,watch:!1},t),!("geolocation"in navigator))return this._handleGeolocationError({code:0,message:"Geolocation not supported."}),this;var i=r(this._handleGeolocationResponse,this),e=r(this._handleGeolocationError,this);return t.watch?this._locationWatchId=navigator.geolocation.watchPosition(i,e,t):navigator.geolocation.getCurrentPosition(i,e,t),this},stopLocate:function(){return navigator.geolocation&&navigator.geolocation.clearWatch&&navigator.geolocation.clearWatch(this._locationWatchId),this._locateOptions&&(this._locateOptions.setView=!1),this},_handleGeolocationError:function(t){var i;this._container._leaflet_id&&(i=t.code,t=t.message||(1===i?"permission denied":2===i?"position unavailable":"timeout"),this._locateOptions.setView&&!this._loaded&&this.fitWorld(),this.fire("locationerror",{code:i,message:"Geolocation error: "+t+"."}))},_handleGeolocationResponse:function(t){if(this._container._leaflet_id){var i,e=new j(t.coords.latitude,t.coords.longitude),s=e.toBounds(2*t.coords.accuracy),n=this._locateOptions;n.setView&&(i=this.getBoundsZoom(s),this.setView(e,n.maxZoom?Math.min(i,n.maxZoom):i));var o,a={latlng:e,bounds:s,timestamp:t.timestamp};for(o in t.coords)"number"==typeof t.coords[o]&&(a[o]=t.coords[o]);this.fire("locationfound",a)}},addHandler:function(t,i){if(!i)return this;i=this[t]=new i(this);return this._handlers.push(i),this.options[t]&&i.enable(),this},remove:function(){if(this._initEvents(!0),this.options.maxBounds&&this.off("moveend",this._panInsideMaxBounds),this._containerId!==this._container._leaflet_id)throw new Error("Map container is being reused by another instance");try{delete this._container._leaflet_id,delete this._containerId}catch(t){this._container._leaflet_id=void 0,this._containerId=void 0}for(var t in void 0!==this._locationWatchId&&this.stopLocate(),this._stop(),si(this._mapPane),this._clearControlPos&&this._clearControlPos(),this._resizeRequest&&(T(this._resizeRequest),this._resizeRequest=null),this._clearHandlers(),this._loaded&&this.fire("unload"),this._layers)this._layers[t].remove();for(t in this._panes)si(this._panes[t]);return this._layers=[],this._panes=[],delete this._mapPane,delete this._renderer,this},createPane:function(t,i){i=ei("div","leaflet-pane"+(t?" leaflet-"+t.replace("Pane","")+"-pane":""),i||this._mapPane);return t&&(this._panes[t]=i),i},getCenter:function(){return this._checkIfLoaded(),this._lastCenter&&!this._moved()?this._lastCenter.clone():this.layerPointToLatLng(this._getCenterLayerPoint())},getZoom:function(){return this._zoom},getBounds:function(){var t=this.getPixelBounds();return new N(this.unproject(t.getBottomLeft()),this.unproject(t.getTopRight()))},getMinZoom:function(){return void 0===this.options.minZoom?this._layersMinZoom||0:this.options.minZoom},getMaxZoom:function(){return void 0===this.options.maxZoom?void 0===this._layersMaxZoom?1/0:this._layersMaxZoom:this.options.maxZoom},getBoundsZoom:function(t,i,e){t=R(t),e=I(e||[0,0]);var s=this.getZoom()||0,n=this.getMinZoom(),o=this.getMaxZoom(),a=t.getNorthWest(),r=t.getSouthEast(),t=this.getSize().subtract(e),e=B(this.project(r,s),this.project(a,s)).getSize(),r=Et.any3d?this.options.zoomSnap:1,a=t.x/e.x,e=t.y/e.y,e=i?Math.max(a,e):Math.min(a,e),s=this.getScaleZoom(e,s);return r&&(s=Math.round(s/(r/100))*(r/100),s=i?Math.ceil(s/r)*r:Math.floor(s/r)*r),Math.max(n,Math.min(o,s))},getSize:function(){return this._size&&!this._sizeChanged||(this._size=new A(this._container.clientWidth||0,this._container.clientHeight||0),this._sizeChanged=!1),this._size.clone()},getPixelBounds:function(t,i){i=this._getTopLeftPoint(t,i);return new Z(i,i.add(this.getSize()))},getPixelOrigin:function(){return this._checkIfLoaded(),this._pixelOrigin},getPixelWorldBounds:function(t){return this.options.crs.getProjectedBounds(void 0===t?this.getZoom():t)},getPane:function(t){return"string"==typeof t?this._panes[t]:t},getPanes:function(){return this._panes},getContainer:function(){return this._container},getZoomScale:function(t,i){var e=this.options.crs;return i=void 0===i?this._zoom:i,e.scale(t)/e.scale(i)},getScaleZoom:function(t,i){var e=this.options.crs;i=void 0===i?this._zoom:i;i=e.zoom(t*e.scale(i));return isNaN(i)?1/0:i},project:function(t,i){return i=void 0===i?this._zoom:i,this.options.crs.latLngToPoint(D(t),i)},unproject:function(t,i){return i=void 0===i?this._zoom:i,this.options.crs.pointToLatLng(I(t),i)},layerPointToLatLng:function(t){t=I(t).add(this.getPixelOrigin());return this.unproject(t)},latLngToLayerPoint:function(t){return this.project(D(t))._round()._subtract(this.getPixelOrigin())},wrapLatLng:function(t){return this.options.crs.wrapLatLng(D(t))},wrapLatLngBounds:function(t){return this.options.crs.wrapLatLngBounds(R(t))},distance:function(t,i){return this.options.crs.distance(D(t),D(i))},containerPointToLayerPoint:function(t){return I(t).subtract(this._getMapPanePos())},layerPointToContainerPoint:function(t){return I(t).add(this._getMapPanePos())},containerPointToLatLng:function(t){t=this.containerPointToLayerPoint(I(t));return this.layerPointToLatLng(t)},latLngToContainerPoint:function(t){return this.layerPointToContainerPoint(this.latLngToLayerPoint(D(t)))},mouseEventToContainerPoint:function(t){return Bi(t,this._container)},mouseEventToLayerPoint:function(t){return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(t))},mouseEventToLatLng:function(t){return this.layerPointToLatLng(this.mouseEventToLayerPoint(t))},_initContainer:function(t){t=this._container=ti(t);if(!t)throw new Error("Map container not found.");if(t._leaflet_id)throw new Error("Map container is already initialized.");bi(t,"scroll",this._onScroll,this),this._containerId=h(t)},_initLayout:function(){var t=this._container;this._fadeAnimated=this.options.fadeAnimation&&Et.any3d,hi(t,"leaflet-container"+(Et.touch?" leaflet-touch":"")+(Et.retina?" leaflet-retina":"")+(Et.ielt9?" leaflet-oldie":"")+(Et.safari?" leaflet-safari":"")+(this._fadeAnimated?" leaflet-fade-anim":""));var i=ii(t,"position");"absolute"!==i&&"relative"!==i&&"fixed"!==i&&"sticky"!==i&&(t.style.position="relative"),this._initPanes(),this._initControlPos&&this._initControlPos()},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),mi(this._mapPane,new A(0,0)),this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane"),this.options.markerZoomAnimation||(hi(t.markerPane,"leaflet-zoom-hide"),hi(t.shadowPane,"leaflet-zoom-hide"))},_resetView:function(t,i,e){mi(this._mapPane,new A(0,0));var s=!this._loaded;this._loaded=!0,i=this._limitZoom(i),this.fire("viewprereset");var n=this._zoom!==i;this._moveStart(n,e)._move(t,i)._moveEnd(n),this.fire("viewreset"),s&&this.fire("load")},_moveStart:function(t,i){return t&&this.fire("zoomstart"),i||this.fire("movestart"),this},_move:function(t,i,e,s){void 0===i&&(i=this._zoom);var n=this._zoom!==i;return this._zoom=i,this._lastCenter=t,this._pixelOrigin=this._getNewPixelOrigin(t),s?e&&e.pinch&&this.fire("zoom",e):((n||e&&e.pinch)&&this.fire("zoom",e),this.fire("move",e)),this},_moveEnd:function(t){return t&&this.fire("zoomend"),this.fire("moveend")},_stop:function(){return T(this._flyToFrame),this._panAnim&&this._panAnim.stop(),this},_rawPanBy:function(t){mi(this._mapPane,this._getMapPanePos().subtract(t))},_getZoomSpan:function(){return this.getMaxZoom()-this.getMinZoom()},_panInsideMaxBounds:function(){this._enforcingBounds||this.panInsideBounds(this.options.maxBounds)},_checkIfLoaded:function(){if(!this._loaded)throw new Error("Set map center and zoom first.")},_initEvents:function(t){this._targets={};var i=t?Li:bi;i((this._targets[h(this._container)]=this)._container,"click dblclick mousedown mouseup mouseover mouseout mousemove contextmenu keypress keydown keyup",this._handleDOMEvent,this),this.options.trackResize&&i(window,"resize",this._onResize,this),Et.any3d&&this.options.transform3DLimit&&(t?this.off:this.on).call(this,"moveend",this._onMoveEnd)},_onResize:function(){T(this._resizeRequest),this._resizeRequest=C(function(){this.invalidateSize({debounceMoveend:!0})},this)},_onScroll:function(){this._container.scrollTop=0,this._container.scrollLeft=0},_onMoveEnd:function(){var t=this._getMapPanePos();Math.max(Math.abs(t.x),Math.abs(t.y))>=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(t,i){for(var e,s=[],n="mouseout"===i||"mouseover"===i,o=t.target||t.srcElement,a=!1;o;){if((e=this._targets[h(o)])&&("click"===i||"preclick"===i)&&this._draggableMoved(e)){a=!0;break}if(e&&e.listens(i,!0)){if(n&&!ji(o,t))break;if(s.push(e),n)break}if(o===this._container)break;o=o.parentNode}return s=!(s.length||a||n)&&this.listens(i,!0)?[this]:s},_isClickDisabled:function(t){for(;t&&t!==this._container;){if(t._leaflet_disable_click)return!0;t=t.parentNode}},_handleDOMEvent:function(t){var i,e=t.target||t.srcElement;!this._loaded||e._leaflet_disable_events||"click"===t.type&&this._isClickDisabled(e)||("mousedown"===(i=t.type)&&yi(e),this._fireDOMEvent(t,i))},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(t,i,e){"click"===t.type&&((a=l({},t)).type="preclick",this._fireDOMEvent(a,a.type,e));var s=this._findEventTargets(t,i);if(e){for(var n=[],o=0;othis.options.zoomAnimationThreshold)return!1;var s=this.getZoomScale(i),s=this._getCenterOffset(t)._divideBy(1-1/s);return!(!0!==e.animate&&!this.getSize().contains(s))&&(C(function(){this._moveStart(!0,e.noMoveStart||!1)._animateZoom(t,i,!0)},this),!0)},_animateZoom:function(t,i,e,s){this._mapPane&&(e&&(this._animatingZoom=!0,this._animateToCenter=t,this._animateToZoom=i,hi(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:t,zoom:i,noUpdate:s}),this._tempFireZoomEvent||(this._tempFireZoomEvent=this._zoom!==this._animateToZoom),this._move(this._animateToCenter,this._animateToZoom,void 0,!0),setTimeout(r(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&li(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom,void 0,!0),this._tempFireZoomEvent&&this.fire("zoom"),delete this._tempFireZoomEvent,this.fire("move"),this._moveEnd(!0))}});function Gi(t){return new Fi(t)}var Fi=E.extend({options:{position:"topright"},initialize:function(t){_(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var i=this._map;return i&&i.removeControl(this),this.options.position=t,i&&i.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this.remove(),this._map=t;var i=this._container=this.onAdd(t),e=this.getPosition(),t=t._controlCorners[e];return hi(i,"leaflet-control"),-1!==e.indexOf("bottom")?t.insertBefore(i,t.firstChild):t.appendChild(i),this._map.on("unload",this.remove,this),this},remove:function(){return this._map&&(si(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null),this},_refocusOnMap:function(t){this._map&&t&&0",i=document.createElement("div");return i.innerHTML=t,i.firstChild},_addItem:function(t){var i,e=document.createElement("label"),s=this._map.hasLayer(t.layer);t.overlay?((i=document.createElement("input")).type="checkbox",i.className="leaflet-control-layers-selector",i.defaultChecked=s):i=this._createRadioElement("leaflet-base-layers_"+h(this),s),this._layerControlInputs.push(i),i.layerId=h(t.layer),bi(i,"click",this._onInputClick,this);var n=document.createElement("span");n.innerHTML=" "+t.name;s=document.createElement("span");return e.appendChild(s),s.appendChild(i),s.appendChild(n),(t.overlay?this._overlaysList:this._baseLayersList).appendChild(e),this._checkDisabledLayers(),e},_onInputClick:function(){if(!this._preventClick){var t,i,e=this._layerControlInputs,s=[],n=[];this._handlingClick=!0;for(var o=e.length-1;0<=o;o--)t=e[o],i=this._getLayer(t.layerId).layer,t.checked?s.push(i):t.checked||n.push(i);for(o=0;oi.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expandSafely:function(){var t=this._section;this._preventClick=!0,bi(t,"click",Oi),this.expand();var i=this;setTimeout(function(){Li(t,"click",Oi),i._preventClick=!1})}}),Ui=Fi.extend({options:{position:"topleft",zoomInText:'',zoomInTitle:"Zoom in",zoomOutText:'',zoomOutTitle:"Zoom out"},onAdd:function(t){var i="leaflet-control-zoom",e=ei("div",i+" leaflet-bar"),s=this.options;return this._zoomInButton=this._createButton(s.zoomInText,s.zoomInTitle,i+"-in",e,this._zoomIn),this._zoomOutButton=this._createButton(s.zoomOutText,s.zoomOutTitle,i+"-out",e,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),e},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(t,i,e,s,n){s=ei("a",e,s);return s.innerHTML=t,s.href="#",s.title=i,s.setAttribute("role","button"),s.setAttribute("aria-label",i),Ai(s),bi(s,"click",Ii),bi(s,"click",n,this),bi(s,"click",this._refocusOnMap,this),s},_updateDisabled:function(){var t=this._map,i="leaflet-disabled";li(this._zoomInButton,i),li(this._zoomOutButton,i),this._zoomInButton.setAttribute("aria-disabled","false"),this._zoomOutButton.setAttribute("aria-disabled","false"),!this._disabled&&t._zoom!==t.getMinZoom()||(hi(this._zoomOutButton,i),this._zoomOutButton.setAttribute("aria-disabled","true")),!this._disabled&&t._zoom!==t.getMaxZoom()||(hi(this._zoomInButton,i),this._zoomInButton.setAttribute("aria-disabled","true"))}});qi.mergeOptions({zoomControl:!0}),qi.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new Ui,this.addControl(this.zoomControl))});var Wi=Fi.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(t){var i="leaflet-control-scale",e=ei("div",i),s=this.options;return this._addScales(s,i+"-line",e),t.on(s.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),e},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,i,e){t.metric&&(this._mScale=ei("div",i,e)),t.imperial&&(this._iScale=ei("div",i,e))},_update:function(){var t=this._map,i=t.getSize().y/2,i=t.distance(t.containerPointToLatLng([0,i]),t.containerPointToLatLng([this.options.maxWidth,i]));this._updateScales(i)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(t){var i=this._getRoundNum(t);this._updateScale(this._mScale,i<1e3?i+" m":i/1e3+" km",i/t)},_updateImperial:function(t){var i,e=3.2808399*t;5280'+(Et.inlineSvg?' ':"")+"Leaflet"},initialize:function(t){_(this,t),this._attributions={}},onAdd:function(t){for(var i in(t.attributionControl=this)._container=ei("div","leaflet-control-attribution"),Ai(this._container),t._layers)t._layers[i].getAttribution&&this.addAttribution(t._layers[i].getAttribution());return this._update(),t.on("layeradd",this._addAttribution,this),this._container},onRemove:function(t){t.off("layeradd",this._addAttribution,this)},_addAttribution:function(t){t.layer.getAttribution&&(this.addAttribution(t.layer.getAttribution()),t.layer.once("remove",function(){this.removeAttribution(t.layer.getAttribution())},this))},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t&&(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update()),this},removeAttribution:function(t){return t&&this._attributions[t]&&(this._attributions[t]--,this._update()),this},_update:function(){if(this._map){var t,i=[];for(t in this._attributions)this._attributions[t]&&i.push(t);var e=[];this.options.prefix&&e.push(this.options.prefix),i.length&&e.push(i.join(", ")),this._container.innerHTML=e.join(' ')}}});qi.mergeOptions({attributionControl:!0}),qi.addInitHook(function(){this.options.attributionControl&&(new Vi).addTo(this)});Fi.Layers=Hi,Fi.Zoom=Ui,Fi.Scale=Wi,Fi.Attribution=Vi,Gi.layers=function(t,i,e){return new Hi(t,i,e)},Gi.zoom=function(t){return new Ui(t)},Gi.scale=function(t){return new Wi(t)},Gi.attribution=function(t){return new Vi(t)};xt=E.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this},enabled:function(){return!!this._enabled}});xt.addTo=function(t,i){return t.addHandler(i,this),this};var bt={Events:k},Ki=Et.touch?"touchstart mousedown":"mousedown",Xi=z.extend({options:{clickTolerance:3},initialize:function(t,i,e,s){_(this,s),this._element=t,this._dragStartTarget=i||t,this._preventOutline=e},enable:function(){this._enabled||(bi(this._dragStartTarget,Ki,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(Xi._dragging===this&&this.finishDrag(!0),Li(this._dragStartTarget,Ki,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(t){var i,e;this._enabled&&(this._moved=!1,ri(this._element,"leaflet-zoom-anim")||(t.touches&&1!==t.touches.length?Xi._dragging===this&&this.finishDrag():Xi._dragging||t.shiftKey||1!==t.which&&1!==t.button&&!t.touches||((Xi._dragging=this)._preventOutline&&yi(this._element),gi(),Vt(),this._moving||(this.fire("down"),i=t.touches?t.touches[0]:t,e=xi(this._element),this._startPoint=new A(i.clientX,i.clientY),this._startPos=fi(this._element),this._parentScale=wi(e),t="mousedown"===t.type,bi(document,t?"mousemove":"touchmove",this._onMove,this),bi(document,t?"mouseup":"touchend touchcancel",this._onUp,this)))))},_onMove:function(t){var i;this._enabled&&(t.touches&&1i&&(e.push(t[s]),n=s);ni.max.x&&(e|=2),t.yi.max.y&&(e|=8),e}function oe(t,i,e,s){var n=i.x,o=i.y,a=e.x-n,r=e.y-o,i=a*a+r*r;return 0this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()t.y!=s.y>t.y&&t.x<(s.x-e.x)*(t.y-e.y)/(s.y-e.y)+e.x&&(l=!l);return l||ye.prototype._containsPoint.call(this,t,!0)}});var xe=ue.extend({initialize:function(t,i){_(this,i),this._layers={},t&&this.addData(t)},addData:function(t){var i,e,s,n=g(t)?t:t.features;if(n){for(i=0,e=n.length;io.x&&(a=e.x+r-o.x+n.x),e.x-a-s.x<(r=0)&&(a=e.x-s.x),e.y+i+n.y>o.y&&(r=e.y+i-o.y+n.y),e.y-r-s.y<0&&(r=e.y-s.y),(a||r)&&(this.options.keepInView&&(this._autopanning=!0),t.fire("autopanstart").panBy([a,r]))))},_getAnchor:function(){return I(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}});qi.mergeOptions({closePopupOnClick:!0}),qi.include({openPopup:function(t,i,e){return this._initOverlay(Ze,t,i,e).openOn(this),this},closePopup:function(t){return(t=arguments.length?t:this._popup)&&t.close(),this}}),k.include({bindPopup:function(t,i){return this._popup=this._initOverlay(Ze,this._popup,t,i),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(t){return this._popup&&(this instanceof ue||(this._popup._source=this),this._popup._prepareOpen(t||this._latlng)&&this._popup.openOn(this._map)),this},closePopup:function(){return this._popup&&this._popup.close(),this},togglePopup:function(){return this._popup&&this._popup.toggle(this),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(t){var i;this._popup&&this._map&&(Ii(t),i=t.layer||t.target,this._popup._source!==i||i instanceof fe?(this._popup._source=i,this.openPopup(t.latlng)):this._map.hasLayer(this._popup)?this.closePopup():this.openPopup(t.latlng))},_movePopup:function(t){this._popup.setLatLng(t.latlng)},_onKeyPress:function(t){13===t.originalEvent.keyCode&&this._openPopup(t)}});var Be=Ie.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,opacity:.9},onAdd:function(t){Ie.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&(this.addEventParent(this._source),this._source.fire("tooltipopen",{tooltip:this},!0))},onRemove:function(t){Ie.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&(this.removeEventParent(this._source),this._source.fire("tooltipclose",{tooltip:this},!0))},getEvents:function(){var t=Ie.prototype.getEvents.call(this);return this.options.permanent||(t.preclick=this.close),t},_initLayout:function(){var t="leaflet-tooltip "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=ei("div",t),this._container.setAttribute("role","tooltip"),this._container.setAttribute("id","leaflet-tooltip-"+h(this))},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var i,e=this._map,s=this._container,n=e.latLngToContainerPoint(e.getCenter()),o=e.layerPointToContainerPoint(t),a=this.options.direction,r=s.offsetWidth,h=s.offsetHeight,l=I(this.options.offset),e=this._getAnchor(),h="top"===a?(i=r/2,h):"bottom"===a?(i=r/2,0):(i="center"===a?r/2:"right"===a?0:"left"===a?r:o.xthis.options.maxZoom||sthis.options.maxZoom||void 0!==this.options.minZoom&&ne.max.x)||!i.wrapLat&&(t.ye.max.y))return!1}if(!this.options.bounds)return!0;t=this._tileCoordsToBounds(t);return R(this.options.bounds).overlaps(t)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(t){var i=this._map,e=this.getTileSize(),s=t.scaleBy(e),e=s.add(e);return[i.unproject(s,t.z),i.unproject(e,t.z)]},_tileCoordsToBounds:function(t){t=this._tileCoordsToNwSe(t),t=new N(t[0],t[1]);return t=!this.options.noWrap?this._map.wrapLatLngBounds(t):t},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var i=t.split(":"),t=new A(+i[0],+i[1]);return t.z=+i[2],t},_removeTile:function(t){var i=this._tiles[t];i&&(si(i.el),delete this._tiles[t],this.fire("tileunload",{tile:i.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){hi(t,"leaflet-tile");var i=this.getTileSize();t.style.width=i.x+"px",t.style.height=i.y+"px",t.onselectstart=c,t.onmousemove=c,Et.ielt9&&this.options.opacity<1&&di(t,this.options.opacity)},_addTile:function(t,i){var e=this._getTilePos(t),s=this._tileCoordsToKey(t),n=this.createTile(this._wrapCoords(t),r(this._tileReady,this,t));this._initTile(n),this.createTile.length<2&&C(r(this._tileReady,this,t,null,n)),mi(n,e),this._tiles[s]={el:n,coords:t,current:!0},i.appendChild(n),this.fire("tileloadstart",{tile:n,coords:t})},_tileReady:function(t,i,e){i&&this.fire("tileerror",{error:i,tile:e,coords:t});var s=this._tileCoordsToKey(t);(e=this._tiles[s])&&(e.loaded=+new Date,this._map._fadeAnimated?(di(e.el,0),T(this._fadeFrame),this._fadeFrame=C(this._updateOpacity,this)):(e.active=!0,this._pruneTiles()),i||(hi(e.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:e.el,coords:t})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),Et.ielt9||!this._map._fadeAnimated?C(this._pruneTiles,this):setTimeout(r(this._pruneTiles,this),250)))},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(t){var i=new A(this._wrapX?n(t.x,this._wrapX):t.x,this._wrapY?n(t.y,this._wrapY):t.y);return i.z=t.z,i},_pxBoundsToTileRange:function(t){var i=this.getTileSize();return new Z(t.min.unscaleBy(i).floor(),t.max.unscaleBy(i).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}});var je=Re.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1,referrerPolicy:!1},initialize:function(t,i){this._url=t,(i=_(this,i)).detectRetina&&Et.retina&&0')}}catch(t){}return function(t){return document.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}(),nt={_initContainer:function(){this._container=ei("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(Ge.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var i=t._container=Ue("shape");hi(i,"leaflet-vml-shape "+(this.options.className||"")),i.coordsize="1 1",t._path=Ue("path"),i.appendChild(t._path),this._updateStyle(t),this._layers[h(t)]=t},_addPath:function(t){var i=t._container;this._container.appendChild(i),t.options.interactive&&t.addInteractiveTarget(i)},_removePath:function(t){var i=t._container;si(i),t.removeInteractiveTarget(i),delete this._layers[h(t)]},_updateStyle:function(t){var i=t._stroke,e=t._fill,s=t.options,n=t._container;n.stroked=!!s.stroke,n.filled=!!s.fill,s.stroke?(i=i||(t._stroke=Ue("stroke")),n.appendChild(i),i.weight=s.weight+"px",i.color=s.color,i.opacity=s.opacity,s.dashArray?i.dashStyle=g(s.dashArray)?s.dashArray.join(" "):s.dashArray.replace(/( *, *)/g," "):i.dashStyle="",i.endcap=s.lineCap.replace("butt","flat"),i.joinstyle=s.lineJoin):i&&(n.removeChild(i),t._stroke=null),s.fill?(e=e||(t._fill=Ue("fill")),n.appendChild(e),e.color=s.fillColor||s.color,e.opacity=s.fillOpacity):e&&(n.removeChild(e),t._fill=null)},_updateCircle:function(t){var i=t._point.round(),e=Math.round(t._radius),s=Math.round(t._radiusY||e);this._setPath(t,t._empty()?"M0 0":"AL "+i.x+","+i.y+" "+e+","+s+" 0,23592600")},_setPath:function(t,i){t._path.v=i},_bringToFront:function(t){oi(t._container)},_bringToBack:function(t){ai(t._container)}},We=Et.vml?Ue:X,Ve=Ge.extend({_initContainer:function(){this._container=We("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=We("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){si(this._container),Li(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_update:function(){var t,i,e;this._map._animatingZoom&&this._bounds||(Ge.prototype._update.call(this),i=(t=this._bounds).getSize(),e=this._container,this._svgSize&&this._svgSize.equals(i)||(this._svgSize=i,e.setAttribute("width",i.x),e.setAttribute("height",i.y)),mi(e,t.min),e.setAttribute("viewBox",[t.min.x,t.min.y,i.x,i.y].join(" ")),this.fire("update"))},_initPath:function(t){var i=t._path=We("path");t.options.className&&hi(i,t.options.className),t.options.interactive&&hi(i,"leaflet-interactive"),this._updateStyle(t),this._layers[h(t)]=t},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){si(t._path),t.removeInteractiveTarget(t._path),delete this._layers[h(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var i=t._path,t=t.options;i&&(t.stroke?(i.setAttribute("stroke",t.color),i.setAttribute("stroke-opacity",t.opacity),i.setAttribute("stroke-width",t.weight),i.setAttribute("stroke-linecap",t.lineCap),i.setAttribute("stroke-linejoin",t.lineJoin),t.dashArray?i.setAttribute("stroke-dasharray",t.dashArray):i.removeAttribute("stroke-dasharray"),t.dashOffset?i.setAttribute("stroke-dashoffset",t.dashOffset):i.removeAttribute("stroke-dashoffset")):i.setAttribute("stroke","none"),t.fill?(i.setAttribute("fill",t.fillColor||t.color),i.setAttribute("fill-opacity",t.fillOpacity),i.setAttribute("fill-rule",t.fillRule||"evenodd")):i.setAttribute("fill","none"))},_updatePoly:function(t,i){this._setPath(t,J(t._parts,i))},_updateCircle:function(t){var i=t._point,e=Math.max(Math.round(t._radius),1),s="a"+e+","+(Math.max(Math.round(t._radiusY),1)||e)+" 0 1,0 ",e=t._empty()?"M0 0":"M"+(i.x-e)+","+i.y+s+2*e+",0 "+s+2*-e+",0 ";this._setPath(t,e)},_setPath:function(t,i){t._path.setAttribute("d",i)},_bringToFront:function(t){oi(t._path)},_bringToBack:function(t){ai(t._path)}});function Ke(t){return Et.svg||Et.vml?new Ve(t):null}Et.vml&&Ve.include(nt),qi.include({getRenderer:function(t){t=(t=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer)||(this._renderer=this._createRenderer());return this.hasLayer(t)||this.addLayer(t),t},_getPaneRenderer:function(t){if("overlayPane"===t||void 0===t)return!1;var i=this._paneRenderers[t];return void 0===i&&(i=this._createRenderer({pane:t}),this._paneRenderers[t]=i),i},_createRenderer:function(t){return this.options.preferCanvas&&He(t)||Ke(t)}});var Xe=Me.extend({initialize:function(t,i){Me.prototype.initialize.call(this,this._boundsToLatLngs(t),i)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return[(t=R(t)).getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});Ve.create=We,Ve.pointsToPath=J,xe.geometryToLayer=we,xe.coordsToLatLng=Pe,xe.coordsToLatLngs=Le,xe.latLngToCoords=Ce,xe.latLngsToCoords=Te,xe.getFeature=Se,xe.asFeature=Ee,qi.mergeOptions({boxZoom:!0});F=xt.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){bi(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){Li(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){si(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){if(!t.shiftKey||1!==t.which&&1!==t.button)return!1;this._clearDeferredResetState(),this._resetState(),Vt(),gi(),this._startPoint=this._map.mouseEventToContainerPoint(t),bi(document,{contextmenu:Ii,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=ei("div","leaflet-zoom-box",this._container),hi(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var i=new Z(this._point,this._startPoint),t=i.getSize();mi(this._box,i.min),this._box.style.width=t.x+"px",this._box.style.height=t.y+"px"},_finish:function(){this._moved&&(si(this._box),li(this._container,"leaflet-crosshair")),Kt(),vi(),Li(document,{contextmenu:Ii,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){1!==t.which&&1!==t.button||(this._finish(),this._moved&&(this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(r(this._resetState,this),0),t=new N(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point)),this._map.fitBounds(t).fire("boxzoomend",{boxZoomBounds:t})))},_onKeyDown:function(t){27===t.keyCode&&(this._finish(),this._clearDeferredResetState(),this._resetState())}});qi.addInitHook("addHandler","boxZoom",F),qi.mergeOptions({doubleClickZoom:!0});Q=xt.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var i=this._map,e=i.getZoom(),s=i.options.zoomDelta,s=t.originalEvent.shiftKey?e-s:e+s;"center"===i.options.doubleClickZoom?i.setZoom(s):i.setZoomAround(t.containerPoint,s)}});qi.addInitHook("addHandler","doubleClickZoom",Q),qi.mergeOptions({dragging:!0,inertia:!0,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});V=xt.extend({addHooks:function(){var t;this._draggable||(t=this._map,this._draggable=new Xi(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))),hi(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){li(this._map._container,"leaflet-grab"),li(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var t,i=this._map;i._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity?(t=R(this._map.options.maxBounds),this._offsetLimit=B(this._map.latLngToContainerPoint(t.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(t.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))):this._offsetLimit=null,i.fire("movestart").fire("dragstart"),i.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){var i,e;this._map.options.inertia&&(i=this._lastTime=+new Date,e=this._lastPos=this._draggable._absPos||this._draggable._newPos,this._positions.push(e),this._times.push(i),this._prunePositions(i)),this._map.fire("move",t).fire("drag",t)},_prunePositions:function(t){for(;1i.max.x&&(t.x=this._viscousLimit(t.x,i.max.x)),t.y>i.max.y&&(t.y=this._viscousLimit(t.y,i.max.y)),this._draggable._newPos=this._draggable._startPos.add(t))},_onPreDragWrap:function(){var t=this._worldWidth,i=Math.round(t/2),e=this._initialWorldOffset,s=this._draggable._newPos.x,n=(s-i+e)%t+i-e,i=(s+i+e)%t-i-e,i=Math.abs(n+e)i.getMaxZoom()&&1=this.text.length)return;t=this.text[this.place++]}switch(this.state){case 1:return this.neutral(t);case 2:return this.keyword(t);case 4:return this.quoted(t);case 5:return this.afterquote(t);case 3:return this.number(t);case-1:return}},C.prototype.afterquote=function(t){if('"'===t)return this.word+='"',void(this.state=4);if(d.test(t))return this.word=this.word.trim(),void this.afterItem(t);throw new Error("havn't handled \""+t+'" in afterquote yet, index '+this.place)},C.prototype.afterItem=function(t){if(","===t)return null!==this.word&&this.currentObject.push(this.word),this.word=null,void(this.state=1);"]"===t&&(this.level--,null!==this.word&&(this.currentObject.push(this.word),this.word=null),this.state=1,this.currentObject=this.stack.pop(),this.currentObject||(this.state=-1))},C.prototype.number=function(t){if(!L.test(t)){if(d.test(t))return this.word=parseFloat(this.word),void this.afterItem(t);throw new Error("havn't handled \""+t+'" in number yet, index '+this.place)}this.word+=t},C.prototype.quoted=function(t){'"'!==t?this.word+=t:this.state=5},C.prototype.keyword=function(t){if(u.test(t))this.word+=t;else{if("["===t){var i=[];return i.push(this.word),this.level++,null===this.root?this.root=i:this.currentObject.push(i),this.stack.push(this.currentObject),this.currentObject=i,void(this.state=1)}if(!d.test(t))throw new Error("havn't handled \""+t+'" in keyword yet, index '+this.place);this.afterItem(t)}},C.prototype.neutral=function(t){if(s.test(t))return this.word=t,void(this.state=2);if('"'===t)return this.word="",void(this.state=4);if(L.test(t))return this.word=t,void(this.state=3);if(!d.test(t))throw new Error("havn't handled \""+t+'" in neutral yet, index '+this.place);this.afterItem(t)},C.prototype.output=function(){for(;this.placeMath.PI&&(s-=2*Math.PI),t=Math.sin(n),n=Math.cos(n),{x:((e=e/Math.sqrt(1-i*(t*t)))+o)*n*Math.cos(s),y:(e+o)*n*Math.sin(s),z:(e*(1-i)+o)*t}}function Y(t,i,e,s){var n,o,a,r,h,l,c,u,d,_,p,m=1e-12,f=t.x,g=t.y,v=t.z||0,y=Math.sqrt(f*f+g*g),M=Math.sqrt(f*f+g*g+v*v);if(y/ex?Math.tan(e):0,c=Math.pow(i,2),u=Math.pow(c,2),d=1-this.es*Math.pow(n,2);a/=Math.sqrt(d);i=qt(e,n,o,this.en),d=this.a*(this.k0*a*(1+r/6*(1-c+h+r/20*(5-18*c+u+14*h-58*c*h+r/42*(61+179*u-u*c-479*c)))))+this.x0,u=this.a*(this.k0*(i-this.ml0+n*s*a/2*(1+r/12*(5-c+9*h+4*l+r/30*(61+u-58*c+270*h-330*c*h+r/56*(1385+543*u-u*c-3111*c))))))+this.y0}else{c=o*Math.sin(s);if(Math.abs(Math.abs(c)-1)x?Math.tan(i):0,s=this.ep2*Math.pow(e,2),l=Math.pow(s,2),n=Math.pow(r,2),o=Math.pow(n,2),h=1-this.es*Math.pow(a,2),a=c*Math.sqrt(h)/this.k0,l=i-(h*=r)*(r=Math.pow(a,2))/(1-this.es)*.5*(1-r/12*(5+3*n-9*s*n+s-4*l-r/30*(61+90*n-252*s*n+45*o+46*s-r/56*(1385+3633*n+4095*o+1574*o*n)))),q(this.long0+a*(1-r/6*(1+2*n+s-r/20*(5+28*n+24*o+8*s*n+6*s-r/42*(61+662*n+1320*o+720*o*n))))/e)):(l=g*D(u),0)):(c=.5*((d=Math.exp(c/this.k0))-1/d),d=this.lat0+u/this.k0,d=Math.cos(d),h=Math.sqrt((1-Math.pow(d,2))/(1+Math.pow(c,2))),l=Math.asin(h),u<0&&(l=-l),0==c&&0===d?0:q(Math.atan2(c,d)+this.long0));return t.x=d,t.y=l,t},names:["Transverse_Mercator","Transverse Mercator","tmerc"]},Wt=function(t){var t=Math.exp(t);return t=(t-1/t)/2},Vt=function(t,i){t=Math.abs(t),i=Math.abs(i);var e=Math.max(t,i),i=Math.min(t,i)/(e||1);return e*Math.sqrt(1+Math.pow(i,2))},Kt=function(t){var i=1+t,e=i-1;return 0==e?t:t*Math.log(i)/e},Xt=function(t){var t=Math.exp(t);return t=(t+1/t)/2};var Jt={init:function(){if(void 0===this.es||this.es<=0)throw new Error("incorrect elliptical usage");this.x0=void 0!==this.x0?this.x0:0,this.y0=void 0!==this.y0?this.y0:0,this.long0=void 0!==this.long0?this.long0:0,this.lat0=void 0!==this.lat0?this.lat0:0,this.cgb=[],this.cbg=[],this.utg=[],this.gtu=[];var t=(i=this.es/(1+Math.sqrt(1-this.es)))/(2-i),i=t;this.cgb[0]=t*(2+t*(-2/3+t*(t*(116/45+t*(26/45+-2854/675*t))-2))),this.cbg[0]=t*(t*(2/3+t*(4/3+t*(-82/45+t*(32/45+4642/4725*t))))-2),this.cgb[1]=(i*=t)*(7/3+t*(t*(-227/45+t*(2704/315+2323/945*t))-1.6)),this.cbg[1]=i*(5/3+t*(-16/15+t*(-13/9+t*(904/315+-1522/945*t)))),this.cgb[2]=(i*=t)*(56/15+t*(-136/35+t*(-1262/105+73814/2835*t))),this.cbg[2]=i*(-26/15+t*(34/21+t*(1.6+-12686/2835*t))),this.cgb[3]=(i*=t)*(4279/630+t*(-332/35+-399572/14175*t)),this.cbg[3]=i*(1237/630+t*(-24832/14175*t-2.4)),this.cgb[4]=(i*=t)*(4174/315+-144838/6237*t),this.cbg[4]=i*(-734/315+109598/31185*t),this.cgb[5]=601676/22275*(i*=t),this.cbg[5]=444337/155925*i,i=Math.pow(t,2),this.Qn=this.k0/(1+t)*(1+i*(.25+i*(1/64+i/256))),this.utg[0]=t*(t*(2/3+t*(-37/96+t*(1/360+t*(81/512+-96199/604800*t))))-.5),this.gtu[0]=t*(.5+t*(-2/3+t*(5/16+t*(41/180+t*(-127/288+7891/37800*t))))),this.utg[1]=i*(-1/48+t*(-1/15+t*(437/1440+t*(-46/105+1118711/3870720*t)))),this.gtu[1]=i*(13/48+t*(t*(557/1440+t*(281/630+-1983433/1935360*t))-.6)),this.utg[2]=(i*=t)*(-17/480+t*(37/840+t*(209/4480+-5569/90720*t))),this.gtu[2]=i*(61/240+t*(-103/140+t*(15061/26880+167603/181440*t))),this.utg[3]=(i*=t)*(-4397/161280+t*(11/504+830251/7257600*t)),this.gtu[3]=i*(49561/161280+t*(-179/168+6601661/7257600*t)),this.utg[4]=(i*=t)*(-4583/161280+108847/3991680*t),this.gtu[4]=i*(34729/80640+-3418889/1995840*t),this.utg[5]=-.03233083094085698*(i*=t),this.gtu[5]=.6650675310896665*i,i=Ft(this.cbg,this.lat0),this.Zb=-this.Qn*(i+function(t,i){for(var e,s=2*Math.cos(i),n=t.length-1,o=t[n],a=0;0<=--n;)e=s*o-a+t[n],a=o,o=e;return Math.sin(i)*e}(this.gtu,2*i))},forward:function(t){var i=q(t.x-this.long0),e=t.y,e=Ft(this.cbg,e),s=Math.sin(e),n=Math.cos(e),o=Math.sin(i),a=Math.cos(i);e=Math.atan2(s,a*n),i=Math.atan2(o*n,Vt(s,n*a)),n=Math.tan(i),a=Math.abs(n),a=Kt(a*(1+a/(Vt(1,a)+1)));var r,a=Ht(this.gtu,2*e,2*(i=n<0?-a:a));return e+=a[0],i+=a[1],e=Math.abs(i)<=2.623395162778?(r=this.a*(this.Qn*i)+this.x0,this.a*(this.Qn*e+this.Zb)+this.y0):r=1/0,t.x=r,t.y=e,t},inverse:function(t){var i,e,s,n,o=(t.x-this.x0)*(1/this.a),a=(t.y-this.y0)*(1/this.a);return a=(a-this.Zb)/this.Qn,o/=this.Qn,a=Math.abs(o)<=2.623395162778?(a+=(n=Ht(this.utg,2*a,2*o))[0],o+=n[1],o=Math.atan(Wt(o)),i=Math.sin(a),e=Math.cos(a),s=Math.sin(o),n=Math.cos(o),a=Math.atan2(i*n,Vt(s,n*e)),o=Math.atan2(s,n*e),e=q(o+this.long0),Ft(this.cgb,a)):e=1/0,t.x=e,t.y=a,t},names:["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc"]};function Qt(t,i){return Math.pow((1-t)/(1+t),i)}var Yt={init:function(){var t=function(t,i){if(void 0===t){if((t=Math.floor(30*(q(i)+Math.PI)/Math.PI)+1)<0)return 0;if(60x?this.ns=Math.log(i/s)/Math.log(e/n):this.ns=t,isNaN(this.ns)&&(this.ns=t),this.f0=i/(this.ns*Math.pow(e,this.ns)),this.rh=this.a*this.f0*Math.pow(o,this.ns),this.title||(this.title="Lambert Conformal Conic"))},forward:function(t){var i=t.x,e=t.y;Math.abs(2*Math.abs(e)-Math.PI)<=x&&(e=D(e)*(g-2*x));var s,n=Math.abs(Math.abs(e)-g);if(xx?this.ns0=(this.ms1*this.ms1-this.ms2*this.ms2)/(this.qs2-this.qs1):this.ns0=this.con,this.c=this.ms1*this.ms1+this.ns0*this.qs1,this.rh=this.a*Math.sqrt(this.c-this.ns0*this.qs0)/this.ns0)},forward:function(t){var i=t.x,e=t.y;this.sin_phi=Math.sin(e),this.cos_phi=Math.cos(e);var s=pi(this.e3,this.sin_phi,this.cos_phi),e=this.a*Math.sqrt(this.c-this.ns0*s)/this.ns0,s=this.ns0*q(i-this.long0),i=e*Math.sin(s)+this.x0,s=this.rh-e*Math.cos(s)+this.y0;return t.x=i,t.y=s,t},inverse:function(t){var i,e,s,n;return t.x-=this.x0,t.y=this.rh-t.y+this.y0,e=0<=this.ns0?(i=Math.sqrt(t.x*t.x+t.y*t.y),1):(i=-Math.sqrt(t.x*t.x+t.y*t.y),-1),(s=0)!==i&&(s=Math.atan2(e*t.x,e*t.y)),e=i*this.ns0/this.a,n=this.sphere?Math.asin((this.c-e*e)/(2*this.ns0)):(n=(this.c-e*e)/this.ns0,this.phi1z(this.e3,n)),s=q(s/this.ns0+this.long0),t.x=s,t.y=n,t},names:["Albers_Conic_Equal_Area","Albers","aea"],phi1z:function(t,i){var e,s,n,o=wi(.5*i);if(tMath.PI&&(e=Math.PI),s=(2*i+Math.sin(2*i))/Math.PI,12*g*this.a?void 0:(r=i/this.a,h=Math.sin(r),a=Math.cos(r),e=this.long0,Math.abs(i)<=x?s=this.lat0:(s=wi(a*this.sin_p12+t.y*h*this.cos_p12/i),o=Math.abs(this.lat0)-g,e=Math.abs(o)<=x?0<=this.lat0?q(this.long0+Math.atan2(t.x,-t.y)):q(this.long0-Math.atan2(-t.x,t.y)):q(this.long0+Math.atan2(t.x*h,i*this.cos_p12*a-t.y*this.sin_p12*h))),t.x=e,t.y=s,t):(r=ai(this.es),o=ri(this.es),a=hi(this.es),h=li(this.es),Math.abs(this.sin_p12-1)<=x?(n=this.a*oi(r,o,a,h,g),i=Math.sqrt(t.x*t.x+t.y*t.y),s=di((n-i)/this.a,r,o,a,h),e=q(this.long0+Math.atan2(t.x,-1*t.y))):Math.abs(this.sin_p12+1)<=x?(n=this.a*oi(r,o,a,h,g),i=Math.sqrt(t.x*t.x+t.y*t.y),s=di((i-n)/this.a,r,o,a,h),e=q(this.long0+Math.atan2(t.x,t.y))):(i=Math.sqrt(t.x*t.x+t.y*t.y),n=Math.atan2(t.x,t.y),r=ci(this.a,this.e,this.sin_p12),o=Math.cos(n),h=-(a=this.e*this.cos_p12*o)*a/(1-this.es),a=3*this.es*(1-h)*this.sin_p12*this.cos_p12*o/(1-this.es),r=1-h*(h=(r=i/r)-h*(1+h)*Math.pow(r,3)/6-a*(1+3*h)*Math.pow(r,4)/24)*h/2-r*h*h*h/6,o=Math.asin(this.sin_p12*Math.cos(h)+this.cos_p12*Math.sin(h)*o),e=q(this.long0+Math.asin(Math.sin(n)*Math.sin(h)/Math.cos(o))),h=Math.sin(o),s=Math.atan2((h-this.es*r*this.sin_p12)*Math.tan(o),h*(1-this.es))),t.x=e,t.y=s,t)},names:["Azimuthal_Equidistant","aeqd"]};var Bi={init:function(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0)},forward:function(t){var i,e,s=t.x,n=t.y,o=q(s-this.long0),a=Math.sin(n),r=Math.cos(n),s=Math.cos(o);return(0<(n=this.sin_p14*a+this.cos_p14*r*s)||Math.abs(n)<=x)&&(i=+this.a*r*Math.sin(o),e=this.y0+ +this.a*(this.cos_p14*a-this.sin_p14*r*s)),t.x=i,t.y=e,t},inverse:function(t){var i,e,s,n,o,a;return t.x-=this.x0,t.y-=this.y0,i=Math.sqrt(t.x*t.x+t.y*t.y),n=wi(i/this.a),e=Math.sin(n),s=Math.cos(n),o=this.long0,Math.abs(i)<=x?(a=this.lat0,t.x=o,t.y=a,t):(a=wi(s*this.sin_p14+t.y*e*this.cos_p14/i),n=Math.abs(this.lat0)-g,o=Math.abs(n)<=x?0<=this.lat0?q(this.long0+Math.atan2(t.x,-t.y)):q(this.long0-Math.atan2(-t.x,t.y)):q(this.long0+Math.atan2(t.x*e,i*this.cos_p14*s-t.y*this.sin_p14*e)),t.x=o,t.y=a,t)},names:["ortho"]},Ni=1,Ri=2,ji=3,Di=4,qi=5,Gi=6,Fi={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4};function Hi(t,i,e,s){var n;return t=g-w/2?this.face=qi:this.lat0<=-(g-w/2)?this.face=Gi:Math.abs(this.long0)<=w?this.face=Ni:Math.abs(this.long0)<=g+w?this.face=0=Math.abs(t.y)?l.value=Fi.AREA_0:0<=t.y&&t.y>=Math.abs(t.x)?(l.value=Fi.AREA_1,i-=g):t.x<0&&-t.x>=Math.abs(t.y)?(l.value=Fi.AREA_2,i=i<0?i+c:i-c):(l.value=Fi.AREA_3,i+=g),n=c/12*Math.tan(i),o=Math.sin(n)/(Math.cos(n)-1/Math.sqrt(2)),o=Math.atan(o),(e=1-(i=Math.cos(i))*i*(e=Math.tan(e))*e*(1-Math.cos(Math.atan(1/Math.cos(o)))))<-1?e=-1:1i.y)--e;else{if(!(Xi[e+1][0]<=i.y))break;++e}var s=Xi[e],n=function(t,i,e,s){for(var n=i;s;--s){var o=t(n);if(n-=o,Math.abs(o){(t=t.split(" ")).forEach(function(t){r.DomUtil[i].call(this,e,t)})},i=(t,i)=>e("addClass",t,i),s=(t,i)=>e("removeClass",t,i),t=r.Marker.extend({initialize(t,i){r.Util.setOptions(this,i),this._latlng=t,this.createIcon()},createIcon(){var t=this.options;let i="";void 0!==t.color&&(i+=`stroke:${t.color};`),void 0!==t.weight&&(i+=`stroke-width:${t.weight};`),void 0!==t.fillColor&&(i+=`fill:${t.fillColor};`),void 0!==t.fillOpacity&&(i+=`fill-opacity:${t.fillOpacity};`),void 0!==t.opacity&&(i+=`opacity:${t.opacity};`);t=this._getIconSVG(t,i);this._locationIcon=r.divIcon({className:t.className,html:t.svg,iconSize:[t.w,t.h]}),this.setIcon(this._locationIcon)},_getIconSVG(t,i){var e=t.radius,s=e+t.weight,t=2*s;return{className:"leaflet-control-locate-location",svg:``+'',w:t,h:t}},setStyle(t){r.Util.setOptions(this,t),this.createIcon()}});var n=t.extend({initialize(t,i,e){r.Util.setOptions(this,e),this._latlng=t,this._heading=i,this.createIcon()},setHeading(t){this._heading=t},_getIconSVG(t,i){var e=t.radius,s=t.width+t.weight,e=2*(e+t.depth+t.weight),t=`M0,0 l${t.width/2},${t.depth} l-${s},0 z`;return{className:"leaflet-control-locate-heading",svg:``+'',w:s,h:e}}}),n=r.Control.extend({options:{position:"topleft",layer:void 0,setView:"untilPanOrZoom",keepCurrentZoomLevel:!1,initialZoomLevel:!1,getLocationBounds(t){return t.bounds},flyTo:!1,clickBehavior:{inView:"stop",outOfView:"setView",inViewNotFollowing:"inView"},returnToPrevBounds:!1,cacheLocation:!0,drawCircle:!0,drawMarker:!0,showCompass:!0,markerClass:t,compassClass:n,circleStyle:{className:"leaflet-control-locate-circle",color:"#136AEC",fillColor:"#136AEC",fillOpacity:.15,weight:0},markerStyle:{className:"leaflet-control-locate-marker",color:"#fff",fillColor:"#2A93EE",fillOpacity:1,weight:3,opacity:1,radius:9},compassStyle:{fillColor:"#2A93EE",fillOpacity:1,weight:0,color:"#fff",opacity:1,radius:9,width:9,depth:6},followCircleStyle:{},followMarkerStyle:{},followCompassStyle:{},icon:"leaflet-control-locate-location-arrow",iconLoading:"leaflet-control-locate-spinner",iconElementTag:"span",textElementTag:"small",circlePadding:[0,0],metric:!0,createButtonCallback(t,i){const e=r.DomUtil.create("a","leaflet-bar-part leaflet-bar-part-single",t);e.title=i.strings.title,e.href="#",e.setAttribute("role","button");const s=r.DomUtil.create(i.iconElementTag,i.icon,e);if(void 0!==i.strings.text){const n=r.DomUtil.create(i.textElementTag,"leaflet-locate-text",e);n.textContent=i.strings.text,e.classList.add("leaflet-locate-text-active"),e.parentNode.style.display="flex",0new r.Control.Locate(t),n},window); //# sourceMappingURL=leaflet.js.map \ No newline at end of file diff --git a/src/dist/map-area.js b/src/dist/map-area.js index ef0ef0c..1df30de 100644 --- a/src/dist/map-area.js +++ b/src/dist/map-area.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 22-08-2024 */ +/*! @maps4html/mapml 28-08-2024 */ import"./leaflet.js";import"./mapml.js";class MapArea extends HTMLAreaElement{static get observedAttributes(){return["coords","alt","href","shape","rel","type","target"]}get alt(){return this.hasAttribute("alt")?this.getAttribute("alt"):""}set alt(t){this.setAttribute("controls",t)}get coords(){return this.hasAttribute("coords")?this.getAttribute("coords"):""}set coords(t){}get href(){return this.hasAttribute("href")?this.getAttribute("href"):""}set href(t){this.href=t}get shape(){return this.hasAttribute("shape")?this.getAttribute("shape"):"default"}set shape(t){(t=t.toLowerCase()).search(/default|circle|rect|poly/)&&(this.shape=t)}get rel(){return this.hasAttribute("rel")?this.getAttribute("rel"):""}set rel(t){this.rel=t}get type(){return this.hasAttribute("type")?this.getAttribute("type"):""}set type(t){this.type=t}get target(){return this.hasAttribute("target")?this.getAttribute("target"):""}constructor(){super()}attributeChangedCallback(t,e,r){}connectedCallback(){this.parentElement.whenReady().then(()=>{this._attachedToMap()})}_attachedToMap(){this._map=this.parentElement._map;var t=this.parentElement._map;if(!this._feature){var e,r,s=this._styleToPathOptions(window.getComputedStyle(this)),i=this.coords?this._coordsToArray(this.coords):null;if(i&&this.parentElement.poster)for(var a=(this.parentElement.poster.width-this.parentElement.width)/2,h=(this.parentElement.poster.height-this.parentElement.height)/2,o=0;o{this.parentElement.querySelector("map-caption").textContent!==t&&this.parentElement.setAttribute("aria-label",this.parentElement.querySelector("map-caption").textContent)}),this.observer.observe(this,{characterData:!0,subtree:!0,attributes:!0,childList:!0}),this.parentElement.hasAttribute("aria-label")||(e=this.textContent,this.parentElement.setAttribute("aria-label",e))}}disconnectedCallback(){this.observer.disconnect()}}export{MapCaption}; //# sourceMappingURL=map-caption.js.map \ No newline at end of file diff --git a/src/dist/map-extent.js b/src/dist/map-extent.js index ee10ee3..0de84b7 100644 --- a/src/dist/map-extent.js +++ b/src/dist/map-extent.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 22-08-2024 */ +/*! @maps4html/mapml 28-08-2024 */ class MapExtent extends HTMLElement{static get observedAttributes(){return["checked","label","opacity","hidden"]}#hasConnected;get units(){return this.getAttribute("units")||M.FALLBACK_PROJECTION}get checked(){return this.hasAttribute("checked")}set checked(e){e?this.setAttribute("checked",""):this.removeAttribute("checked")}get label(){return this.hasAttribute("label")?this.getAttribute("label"):M.options.locale.dfExtent}set label(e){e&&this.setAttribute("label",e)}get opacity(){return+(this._opacity??this.getAttribute("opacity"))}set opacity(e){1<+e||+e<0||this.setAttribute("opacity",e)}get hidden(){return this.hasAttribute("hidden")}set hidden(e){e?this.setAttribute("hidden",""):this.removeAttribute("hidden")}get extent(){const e=e=>Object.assign(M._convertAndFormatPCRS(e._extentLayer.bounds,M[e.units],e.units),{zoom:e._extentLayer.zoomBounds});var t;return this._extentLayer.bounds?e(this):((t=this)._calculateBounds(),e(t))}getOuterHTML(){let t=this.cloneNode(!0);if(this.querySelector("map-link")){let e=t.querySelectorAll("map-link");e.forEach(e=>{e.hasAttribute("href")?e.setAttribute("href",decodeURI(new URL(e.attributes.href.value,this.baseURI||document.baseURI).href)):e.hasAttribute("tref")&&e.setAttribute("tref",decodeURI(new URL(e.attributes.tref.value,this.baseURI||document.baseURI).href))})}var e=t.outerHTML;return t.remove(),e}zoomTo(){var e=this.extent;let t=this.getMapEl()._map,a=e.topLeft.pcrs.horizontal,r=e.bottomRight.pcrs.horizontal,n=e.bottomRight.pcrs.vertical,i=e.topLeft.pcrs.vertical,o=L.bounds(L.point(a,n),L.point(r,i)),s=t.options.crs.unproject(o.getCenter(!0)),l=e.zoom.maxZoom,h=e.zoom.minZoom;t.setView(s,M.getMaxZoom(o,t,h,l),{animate:!1})}getMapEl(){return M.getClosest(this,"mapml-viewer,map[is=web-map]")}getLayerEl(){return M.getClosest(this,"layer-")}attributeChangedCallback(e,t,a){if(this.#hasConnected)switch(e){case"units":break;case"label":t!==a&&(this._layerControlHTML.querySelector(".mapml-extent-item-name").innerHTML=a||M.options.locale.dfExtent);break;case"checked":this.parentLayer.whenReady().then(()=>{this._handleChange(),this._calculateBounds(),this._layerControlCheckbox.checked=null!==a}).catch(e=>{console.log("Error while waiting on parentLayer for map-extent checked callback: "+e)});break;case"opacity":t!==a&&(this._opacity=a,this._extentLayer&&this._extentLayer.changeOpacity(a));break;case"hidden":t!==a&&this.parentLayer.whenReady().then(()=>{let e=this.parentLayer._propertiesGroupAnatomy;var t=Array.from(this.parentLayer.src?this.parentLayer.shadowRoot.querySelectorAll(":host > map-extent:not([hidden])"):this.parentLayer.querySelectorAll(":scope > map-extent:not([hidden])")).indexOf(this);null!==a?this._layerControlHTML.remove():0===t?e.insertAdjacentElement("afterbegin",this._layerControlHTML):0 map-extent:not([hidden])"):this.parentLayer.querySelectorAll(":scope > map-extent:not([hidden])"))[t-1]._layerControlHTML.insertAdjacentElement("afterend",this._layerControlHTML),this._validateLayerControlContainerHidden()}).catch(()=>{console.log("Error while waiting on parentLayer for map-extent hidden callback")})}}constructor(){super(),this._createLayerControlExtentHTML=M._createLayerControlExtentHTML.bind(this),this._changeHandler=this._handleChange.bind(this)}async connectedCallback(){this.parentLayer=this.getLayerEl(),this.hasAttribute("data-moving")||this.parentLayer.hasAttribute("data-moving")||(this.mapEl=this.getMapEl(),await this.mapEl.whenProjectionDefined(this.units).catch(()=>{throw new Error("Undefined projection:"+this.units)}),this.isConnected&&(this.#hasConnected=!0,this._map=this.mapEl._map,this.parentLayer.addEventListener("map-change",this._changeHandler),this.mapEl.addEventListener("map-projectionchange",this._changeHandler),this._opacity=this.opacity||1,this._extentLayer=M.extentLayer({opacity:this.opacity,crs:M[this.units],extentZIndex:Array.from(this.parentLayer.src?this.parentLayer.shadowRoot.querySelectorAll(":host > map-extent"):this.parentLayer.querySelectorAll(":scope > map-extent")).indexOf(this),extentEl:this}),this._layerControlHTML=this._createLayerControlExtentHTML(),this._calculateBounds(),this._runMutationObserver(this.children),this._bindMutationObserver()))}_bindMutationObserver(){this._observer=new MutationObserver(e=>{for(var t of e)"childList"===t.type&&this._runMutationObserver(t.addedNodes)}),this._observer.observe(this,{childList:!0})}_runMutationObserver(a){var r=e=>{this.whenReady().then(()=>{this._calculateBounds(),this._validateDisabled()})},n=e=>{this.whenReady().then(()=>{this._extentLayer.appendStyleLink(e)})},i=e=>{this.whenReady().then(()=>{this._extentLayer.appendStyleElement(e)})};for(let t=0;t{let t=r.length,a=0;for(let e=0;e map-meta[name=${e}]`)||this.parentLayer.shadowRoot.querySelector(`:host > map-meta[name=${e}]`):this.querySelector(`:scope > map-meta[name=${e}]`)||this.parentLayer.querySelector(`:scope > map-meta[name=${e}]`)}toggleLayerControlDisabled(){let e=this._layerControlCheckbox,t=this._layerControlLabel,a=this._opacityControl,r=this._opacitySlider,n=this._selectdetails;this.disabled?(e.disabled=!0,r.disabled=!0,t.style.fontStyle="italic",a.style.fontStyle="italic",n&&n.forEach(e=>{e.querySelectorAll("select").forEach(e=>{e.disabled=!0,e.style.fontStyle="italic"}),e.style.fontStyle="italic"})):(e.disabled=!1,r.disabled=!1,t.style.fontStyle="normal",a.style.fontStyle="normal",n&&n.forEach(e=>{e.querySelectorAll("select").forEach(e=>{e.disabled=!1,e.style.fontStyle="normal"}),e.style.fontStyle="normal"}))}_handleChange(){this.checked&&!this.disabled?(this._extentLayer.addTo(this.parentLayer._layer),this._extentLayer.setZIndex(Array.from(this.parentLayer.src?this.parentLayer.shadowRoot.querySelectorAll(":host > map-extent"):this.parentLayer.querySelectorAll(":scope > map-extent")).indexOf(this))):this.parentLayer._layer?.removeLayer(this._extentLayer)}_validateLayerControlContainerHidden(){let e=this.parentLayer._propertiesGroupAnatomy;e&&(0===(this.parentLayer.src?this.parentLayer.shadowRoot.querySelectorAll(":host > map-extent:not([hidden])"):this.parentLayer.querySelectorAll(":scope > map-extent:not([hidden])")).length?e.setAttribute("hidden",""):e.removeAttribute("hidden"))}disconnectedCallback(){this.hasAttribute("data-moving")||this.parentLayer.hasAttribute("data-moving")||!this._extentLayer||(this._validateLayerControlContainerHidden(),this._layerControlHTML.remove(),this.parentLayer._layer&&this.parentLayer._layer.removeLayer(this._extentLayer),this.parentLayer.removeEventListener("map-change",this._changeHandler),this.mapEl.removeEventListener("map-projectionchange",this._changeHandler),delete this._extentLayer,this.parentLayer._layer&&delete this.parentLayer._layer.bounds)}_calculateBounds(){delete this._extentLayer.bounds,delete this._extentLayer.zoomBounds,this.parentLayer._layer&&delete this.parentLayer._layer.bounds;let t=this.querySelectorAll("map-link[rel=image],map-link[rel=tile],map-link[rel=features],map-link[rel=query]"),a=this.querySelector(":scope > map-meta[name=extent][content]")?M.getBoundsFromMeta(this):void 0,r=this.querySelector(":scope > map-meta[name=zoom][content]")?M.getZoomBoundsFromMeta(this):void 0;for(let e=0;e{let r,n;this._extentLayer?t():(r=setInterval(function(e){e._extentLayer?(clearInterval(r),clearTimeout(n),t()):e.isConnected||(clearInterval(r),clearTimeout(n),a("map-extent was disconnected while waiting to be ready"))},300,this),n=setTimeout(function(){clearInterval(r),clearTimeout(n),a("Timeout reached waiting for extent to be ready")},1e4))})}whenLinksReady(){var e;let t=[];for(e of[...this.querySelectorAll("map-link[rel=image],map-link[rel=tile],map-link[rel=features],map-link[rel=query]")])t.push(e.whenReady());return Promise.allSettled(t)}}export{MapExtent}; //# sourceMappingURL=map-extent.js.map \ No newline at end of file diff --git a/src/dist/map-feature.js b/src/dist/map-feature.js index 820d22f..578b8cf 100644 --- a/src/dist/map-feature.js +++ b/src/dist/map-feature.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 22-08-2024 */ +/*! @maps4html/mapml 28-08-2024 */ class MapFeature extends HTMLElement{static get observedAttributes(){return["zoom","min","max"]}#hasConnected;get zoom(){let t={},e=this.getMeta("zoom");return e&&(t=M._metaContentToObject(e.getAttribute("content"))),"MAP-LINK"===this._parentEl.nodeName?+(this.hasAttribute("zoom")?this.getAttribute("zoom"):t.value||t.max||this._initialZoom):+(this.hasAttribute("zoom")?this.getAttribute("zoom"):this._initialZoom)}set zoom(t){t=parseInt(t,10);!isNaN(t)&&t>=this.min&&t<=this.max&&this.setAttribute("zoom",t)}get min(){let t={},e=this.getMeta("zoom");e&&(t=M._metaContentToObject(e.getAttribute("content")));return"MAP-LINK"===this._parentEl.nodeName?+(this.hasAttribute("min")?this.getAttribute("min"):t.min||this._parentEl.getZoomBounds().minZoom):+(this.hasAttribute("min")?this.getAttribute("min"):t.min||0)}set min(t){var e=parseInt(t,10),t=this.getLayerEl().extent.zoom;isNaN(e)||(e>=t.minZoom&&e<=t.maxZoom?this.setAttribute("min",e):this.setAttribute("min",t.minZoom))}get max(){let t={},e=this.getMeta("zoom");e&&(t=M._metaContentToObject(e.getAttribute("content")));var o=this.getMapEl()._map.options.crs.options.resolutions.length-1;return"MAP-LINK"===this._parentEl.nodeName?+(this.hasAttribute("max")?this.getAttribute("max"):t.max||this._parentEl.getZoomBounds().maxZoom):+(this.hasAttribute("max")?this.getAttribute("max"):t.max||o)}set max(t){var e=parseInt(t,10),t=this.getLayerEl().extent.zoom;isNaN(e)||(e>=t.minZoom&&e<=t.maxZoom?this.setAttribute("max",e):this.setAttribute("max",t.maxZoom))}get extent(){if(this.isConnected)return this._getFeatureExtent||(this._getFeatureExtent=this._memoizeExtent()),this._getFeatureExtent()}getMapEl(){return M.getClosest(this,"mapml-viewer,map[is=web-map]")}getLayerEl(){return M.getClosest(this,"layer-")}attributeChangedCallback(t,e,o){if(this.#hasConnected)switch(t){case"min":case"max":case"zoom":e!==o&&this.reRender(this._featureLayer)}}constructor(){super()}connectedCallback(){this.#hasConnected=!0,this._initialZoom=this.getMapEl().zoom,this._parentEl="LAYER-"===this.parentNode.nodeName.toUpperCase()||"MAP-LINK"===this.parentNode.nodeName.toUpperCase()?this.parentNode:this.parentNode.host,this.getLayerEl().hasAttribute("data-moving")||this._parentEl.parentElement?.hasAttribute("data-moving")||(this._observer=new MutationObserver(t=>{for(var e of t){if("attributes"===e.type&&e.target===this)return;this.reRender(this._featureLayer)}}),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,characterData:!0}))}disconnectedCallback(){this.getLayerEl()?.hasAttribute("data-moving")||this._parentEl.parentElement?.hasAttribute("data-moving")||(this._observer.disconnect(),this._featureLayer&&this.removeFeature(this._featureLayer))}reRender(e){if(this._groupEl.isConnected){var o=this._getFallbackCS();let t=document.createElement("span");this._groupEl.insertAdjacentElement("beforebegin",t),e._staticFeature&&e._removeFromFeaturesList(this._geometry),e.removeLayer(this._geometry),this._geometry=e.createGeometry(this,o).addTo(e),t.replaceWith(this._geometry.options.group),e._validateRendering(),delete this._getFeatureExtent,this._setUpEvents()}}removeFeature(t){t.removeLayer(this._geometry),t._staticFeature&&t._removeFromFeaturesList(this._geometry),t.options.properties=null,delete this._geometry,this._getFeatureExtent&&delete this._getFeatureExtent}addFeature(t){this._featureLayer=t;var e,o=this.getLayerEl();this.querySelector("map-geometry")&&(e=this._getFallbackCS(),o.src&&o.shadowRoot,this._geometry=t.createGeometry(this,e),this._geometry&&(t.addLayer(this._geometry),this._setUpEvents()))}_setUpEvents(){["click","focus","blur","keyup","keydown"].forEach(o=>{this._groupEl.addEventListener(o,e=>{if("click"===o){let t=new PointerEvent(o,{cancelable:!0});t.originalEvent=e,this.dispatchEvent(t)}else if("keyup"===o||"keydown"===o){let t=new KeyboardEvent(o,{cancelable:!0});t.originalEvent=e,this.dispatchEvent(t)}else{let t=new FocusEvent(o,{cancelable:!0});t.originalEvent=e,this.dispatchEvent(t)}})})}_getFallbackCS(){let e;if("MAP-LINK"===this._parentEl.nodeName)e=this._parentEl.shadowRoot.querySelector("map-meta[name=cs][content]")||this._parentEl.parentElement.getMeta("cs");else{let t=this.getLayerEl();e=(t.src?t.shadowRoot:t).querySelector("map-meta[name=cs][content]")}return e?M._metaContentToObject(e.getAttribute("content")).content:"gcrs"}_memoizeExtent(){let p;return function(){if(p&&this._getFeatureExtent)return p;{let i=this.getMapEl()._map,t=this.querySelector("map-geometry"),e=t.getAttribute("cs")||this._getFallbackCS(),o=this.zoom,r=t.querySelectorAll("map-point, map-linestring, map-polygon, map-multipoint, map-multilinestring"),n=[1/0,1/0,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(var a of r){var m=a.querySelectorAll("map-coordinates");for(let t=0;t]+>/g,"").replace(/\s+/g," ").split(/[<>\ ]/g);switch(t.tagName.toUpperCase()){case"MAP-POINT":o=M._updateExtent(o,+r[0],+r[1]);break;case"MAP-LINESTRING":case"MAP-POLYGON":case"MAP-MULTIPOINT":case"MAP-MULTILINESTRING":for(let t=0;ti&&(i=this.min)),ir&&(i=r),i}getMeta(t){var e=t.toLowerCase();if("cs"===e||"zoom"===e||"projection"===e){var o=this._parentEl.shadowRoot.querySelector(`map-meta[name=${e}][content]`);return"MAP-LINK"===this._parentEl.nodeName?o||this._parentEl.parentElement.getMeta(t):(this._parentEl.src?this._parentEl.shadowRoot:this._parentEl).querySelector(`map-meta[name=${e}][content]`)}}mapml2geojson(t){t=Object.assign({},{propertyFunction:null,transform:!0},t);let e={type:"Feature",properties:{},geometry:{}},o=this.querySelector("map-properties");o?"function"==typeof t.propertyFunction?e.properties=t.propertyFunction(o):o.querySelector("table")?(a=o.querySelector("table").cloneNode(!0),e.properties=M._table2properties(a)):e.properties={prop0:o.innerHTML.replace(/(<([^>]+)>)/gi,"").replace(/\s/g,"")}:e.properties=null;let r=null,i=null,n=this.getMapEl()._map;t.transform&&(r=new proj4.Proj(n.options.crs.code),i=new proj4.Proj("EPSG:4326"),"EPSG:3857"!==n.options.crs.code&&"EPSG:4326"!==n.options.crs.code||(t.transform=!1));var s=this.querySelector("map-geometry").querySelector("map-geometrycollection"),a=this.querySelector("map-geometry").querySelectorAll("map-point, map-polygon, map-linestring, map-multipoint, map-multipolygon, map-multilinestring");if(s){e.geometry.type="GeometryCollection",e.geometry.geometries=[];for(var m of a)e.geometry.geometries.push(M._geometry2geojson(m,r,i,t.transform))}else e.geometry=M._geometry2geojson(a[0],r,i,t.transform);return e}click(){let t=this._groupEl,e=t.getBoundingClientRect();var o=new MouseEvent("click",{clientX:e.x+e.width/2,clientY:e.y+e.height/2,button:0}),r=this.querySelector("map-properties");if("link"===t.getAttribute("role"))for(var i of t.children)i.mousedown.call(this._geometry,o),i.mouseup.call(this._geometry,o);let n=new PointerEvent("click",{cancelable:!0});if(n.originalEvent=o,this.dispatchEvent(n),r&&this.isConnected){let t=this._geometry,e=t._layers;for(var s in e)e[s].isPopupOpen()&&e[s].closePopup();t.isPopupOpen()?t.closePopup():n.originalEvent.cancelBubble||t.openPopup()}}focus(t){this._groupEl.focus(t)}blur(){document.activeElement.shadowRoot?.activeElement!==this._groupEl&&document.activeElement.shadowRoot?.activeElement.parentNode!==this._groupEl||(this._groupEl.blur(),this.getMapEl()._map.getContainer().focus())}zoomTo(){let t=this.extent,e=this.getMapEl()._map,o=t.topLeft.pcrs,r=t.bottomRight.pcrs,i=L.bounds(L.point(o.horizontal,o.vertical),L.point(r.horizontal,r.vertical)),n=e.options.crs.unproject(i.getCenter(!0));e.setView(n,this.getZoomToZoom(),{animate:!1})}whenReady(){return new Promise((e,t)=>{let o,r;this.isConnected?e():(o=setInterval(function(t){t.isConnected&&(clearInterval(o),clearTimeout(r),e())},200,this),r=setTimeout(function(){clearInterval(o),clearTimeout(r),t("Timeout reached waiting for feature to be ready")},5e3))})}}export{MapFeature}; //# sourceMappingURL=map-feature.js.map \ No newline at end of file diff --git a/src/dist/map-input.js b/src/dist/map-input.js index 0aaf449..0c5a733 100644 --- a/src/dist/map-input.js +++ b/src/dist/map-input.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 22-08-2024 */ +/*! @maps4html/mapml 28-08-2024 */ class MapInput extends HTMLElement{static get observedAttributes(){return["name","type","value","axis","units","position","rel","min","max","step"]}get name(){return this.getAttribute("name")}set name(t){t&&this.setAttribute("name",t)}get type(){return this.getAttribute("type")}set type(t){["location"].includes(t)&&this.setAttribute("type",t)}get value(){return this.input.getValue()}set value(t){t&&this.setAttribute("value",t)}get axis(){return this.getAttribute("axis")}set axis(t){t&&this.setAttribute("axis",t)}get units(){return this.getAttribute("units")}set units(t){t&&this.setAttribute("units",t)}get position(){return this.getAttribute("position")}set position(t){t&&this.setAttribute("position",t)}get rel(){return this.getAttribute("rel")}set rel(t){t&&this.setAttribute("rel",t)}get min(){if("zoom"===this.type)return this.hasAttribute("min")?this.getAttribute("min"):this.parentElement.querySelector("map-meta[name=zoom]")?M._metaContentToObject(this.parentElement.querySelector("map-meta[name=zoom]").getAttribute("content")).min:this.getLayerEl().extent?.zoom.minZoom.toString()}set min(t){t&&this.setAttribute("min",t)}get max(){if("zoom"===this.type)return this.hasAttribute("max")?this.getAttribute("max"):this.parentElement.querySelector("map-meta[name=zoom]")?M._metaContentToObject(this.parentElement.querySelector("map-meta[name=zoom]").getAttribute("content")).max:this.getLayerEl().extent?.zoom.maxZoom.toString()}set max(t){t&&this.setAttribute("max",t)}get step(){return"zoom"!==this.type?null:this.getAttribute("step")||"1"}set step(t){t&&this.setAttribute("step",t)}getMapEl(){return M.getClosest(this,"mapml-viewer,map[is=web-map]")}getLayerEl(){return M.getClosest(this,"layer-")}attributeChangedCallback(e,t,i){this.whenReady().then(()=>{switch(e){case"name":t!==i&&null!==t&&(this.input.name=i);break;case"type":break;case"value":t!==i&&null!==t&&(this.input.value=i);break;case"axis":t!==i&&this.input&&(this.input.axis=i);break;case"units":t!==i&&this.input&&(this.input.units=i);break;case"position":t!==i&&this.input&&(this.input.position=i);break;case"rel":t!==i&&this.input&&(this.input.rel=i);break;case"min":t!==i&&this.input&&(this.input.min=i);break;case"max":t!==i&&this.input&&(this.input.max=i);break;case"step":t!==i&&this.input&&(this.input.step=i)}}).catch(t=>{console.log(t,` in mapInput.attributeChangeCallback when changing attribute `+e)})}constructor(){super()}connectedCallback(){this.parentElement.whenReady().then(()=>{switch("MAP-EXTENT"===this.parentElement.nodeName&&(this._layer=this.parentElement._layer),this.type){case"zoom":this.initialValue=+this.getAttribute("value"),this.input=new M.ZoomInput(this.name,this.min,this.max,this.initialValue,this.step,this._layer);break;case"location":this.input=new M.LocationInput(this.name,this.position,this.axis,this.units,this.min,this.max,this.rel,this._layer);break;case"width":this.input=new M.WidthInput(this.name,this._layer);break;case"height":this.input=new M.HeightInput(this.name,this._layer);break;case"hidden":this.input=new M.HiddenInput(this.name,this.initialValue)}}).catch(t=>{console.log(t,"\nin mapInput.connectedCallback")})}disconnectedCallback(){}checkValidity(){if(this.input.validateInput())return!0;var t=new Event("invalid",{bubbles:!0,cancelable:!0,composed:!0});return this.dispatchEvent(t),!1}reportValidity(){if(this.input.validateInput())return!0;var t=new Event("invalid",{bubbles:!0,cancelable:!0,composed:!0});return this.dispatchEvent(t),console.log("Input type='"+this.type+"' is not valid!"),!1}whenReady(){return new Promise((e,i)=>{let n,s;this.input?e():(n=setInterval(function(t){t.input?(clearInterval(n),clearTimeout(s),e()):t.isConnected||(clearInterval(n),clearTimeout(s),i("map-input was disconnected while waiting to be ready"))},300,this),s=setTimeout(function(){clearInterval(n),clearTimeout(s),i("Timeout reached waiting for input to be ready")},1e4))})}}export{MapInput}; diff --git a/src/dist/map-link.js b/src/dist/map-link.js index e263f18..6a3c85c 100644 --- a/src/dist/map-link.js +++ b/src/dist/map-link.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 22-08-2024 */ +/*! @maps4html/mapml 28-08-2024 */ -class MapLink extends HTMLElement{static get observedAttributes(){return["type","rel","media","href","hreflang","tref","tms","projection"]}#hasConnected;get type(){return this.getAttribute("type")||"image/*"}set type(t){"text/mapml"!==t&&!t.startsWith("image/")||this.setAttribute("type",t)}get rel(){return this.getAttribute("rel")}set rel(t){["license","alternate","self","style","tile","image","features","zoomin","zoomout","legend","query","stylesheet"].includes(t)&&this.setAttribute("type",t)}get href(){return this.hasAttribute("href")?new URL(this.getAttribute("href"),this.getBase()).href:this.hasAttribute("tref")?this.resolve():void 0}set href(t){t&&this.setAttribute("href",t)}get hreflang(){return this.getAttribute("hreflang")}set hreflang(t){t&&this.setAttribute("hreflang",t)}get tref(){return this.hasAttribute("tref")?this.getAttribute("tref"):M.BLANK_TT_TREF}set tref(t){t&&this.setAttribute("tref",t)}get media(){return M._metaContentToObject(this.getAttribute("media"))}set media(t){this.setAttribute("media",t)}get tms(){return this.hasAttribute("tms")}set tms(t){t&&this.setAttribute("tms","")}get projection(){return this.getAttribute("projection")}set projection(t){["OSMTILE","CBMTILE","WGS84","APSTILE"].includes(t)&&this.setAttribute("projection",t)}get extent(){return this._templateVars?Object.assign(M._convertAndFormatPCRS(this.getBounds(),M[this.parentExtent.units],this.parentExtent.units),{zoom:this.getZoomBounds()}):null}zoomTo(){var h=this.extent;if(h){let t=this.getMapEl()._map,e=h.topLeft.pcrs.horizontal,i=h.bottomRight.pcrs.horizontal,s=h.bottomRight.pcrs.vertical,a=h.topLeft.pcrs.vertical,r=L.bounds(L.point(e,s),L.point(i,a)),o=t.options.crs.unproject(r.getCenter(!0)),n=h.zoom.maxZoom,l=h.zoom.minZoom;t.setView(o,M.getMaxZoom(r,t,l,n),{animate:!1})}}getMapEl(){return M.getClosest(this,"mapml-viewer,map[is=web-map]")}getLayerEl(){return M.getClosest(this,"layer-")}attributeChangedCallback(t,e,i){if(this.#hasConnected)switch(t){case"type":case"rel":case"href":case"hreflang":break;case"tref":e!==i&&this._initTemplateVars()}}constructor(){super()}connectedCallback(){if(this.#hasConnected=!0,!(this.getLayerEl().hasAttribute("data-moving")||this.parentExtent&&this.parentExtent.hasAttribute("data-moving")))switch(this.rel.toLowerCase()){case"tile":case"image":case"features":case"query":this._initTemplateVars(),this._createTemplatedLink();break;case"style":case"self":case"style self":case"self style":this._createSelfOrStyleLink();break;case"zoomin":case"zoomout":case"legend":break;case"stylesheet":this._createStylesheetLink();break;case"alternate":this._createAlternateLink()}}disconnectedCallback(){"stylesheet"===this.rel.toLowerCase()&&this._stylesheetHost&&this.link.remove()}_createAlternateLink(t){this.href&&this.projection&&(this._alternate=!0)}_createStylesheetLink(){var t,e;this._stylesheetHost=this.getRootNode()instanceof ShadowRoot?this.getRootNode().host:this.parentElement,void 0!==this._stylesheetHost&&(this.link=document.createElement("link"),(this.link.mapLink=this).link.setAttribute("href",new URL(this.href,this.getBase()).href),e=(t=this).link,Array.from(t.attributes).forEach(t=>{"href"!==t.nodeName&&e.setAttribute(t.nodeName,t.nodeValue)}),this._stylesheetHost._layer?this._stylesheetHost._layer.appendStyleLink(this):this._stylesheetHost._templatedLayer?this._stylesheetHost._templatedLayer.appendStyleLink(this):this._stylesheetHost._extentLayer&&this._stylesheetHost._extentLayer.appendStyleLink(this))}async _createTemplatedLink(){if(this.parentExtent="MAP-EXTENT"===this.parentNode.nodeName.toUpperCase()?this.parentNode:this.parentNode.host,this.tref&&this.parentExtent){try{await this.parentExtent.whenReady(),await this._templateVars.inputsReady}catch(t){return void console.log("Error while creating templated link: "+t)}this.mapEl=this.getMapEl(),this.zIndex=Array.from(this.parentExtent.querySelectorAll("map-link[rel=image],map-link[rel=tile],map-link[rel=features]")).indexOf(this),"tile"===this.rel?this._templatedLayer=M.templatedTileLayer(this._templateVars,{zoomBounds:this.getZoomBounds(),extentBounds:this.getBounds(),crs:M[this.parentExtent.units],errorTileUrl:"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",zIndex:this.zIndex,pane:this.parentExtent._extentLayer.getContainer(),linkEl:this}).addTo(this.parentExtent._extentLayer):"image"===this.rel?this._templatedLayer=M.templatedImageLayer(this._templateVars,{zoomBounds:this.getZoomBounds(),extentBounds:this.getBounds(),zIndex:this.zIndex,pane:this.parentExtent._extentLayer.getContainer(),linkEl:this}).addTo(this.parentExtent._extentLayer):"features"===this.rel?(this.attachShadow({mode:"open"}),this._templatedLayer=M.templatedFeaturesLayer(this._templateVars,{zoomBounds:this.getZoomBounds(),extentBounds:this.getBounds(),zIndex:this.zIndex,pane:this.parentExtent._extentLayer.getContainer(),linkEl:this}).addTo(this.parentExtent._extentLayer)):"query"===this.rel&&(this.attachShadow({mode:"open"}),L.extend(this._templateVars,this._setupQueryVars(this._templateVars)),L.extend(this._templateVars,{extentBounds:this.getBounds()}))}}_setupQueryVars(t){for(var e={query:{}},i=t.values,s=0;s{let s,a,r;switch(this.rel.toLowerCase()){case"tile":case"image":case"features":r="_templatedLayer";break;case"style":case"self":case"style self":case"self style":r="_styleOption";break;case"query":r="shadowRoot";break;case"alternate":r="_alternate";break;default:e()}this[r]&&e(),s=setInterval(function(t){t[r]?(clearInterval(s),clearTimeout(a),e()):t.isConnected||(clearInterval(s),clearTimeout(a),i("map-link was disconnected while waiting to be ready"))},300,this),a=setTimeout(function(){clearInterval(s),clearTimeout(a),i("Timeout reached waiting for link to be ready")},1e4)})}}export{MapLink}; +class MapLink extends HTMLElement{static get observedAttributes(){return["type","rel","media","href","hreflang","tref","tms","projection"]}#hasConnected;get type(){return this.getAttribute("type")||"image/*"}set type(t){"text/mapml"!==t&&!t.startsWith("image/")||this.setAttribute("type",t)}get rel(){return this.getAttribute("rel")}set rel(t){["license","alternate","self","style","tile","image","features","zoomin","zoomout","legend","query","stylesheet"].includes(t)&&this.setAttribute("type",t)}get href(){return this.hasAttribute("href")?new URL(this.getAttribute("href"),this.getBase()).href:this.hasAttribute("tref")?this.resolve():void 0}set href(t){t&&this.setAttribute("href",t)}get hreflang(){return this.getAttribute("hreflang")}set hreflang(t){t&&this.setAttribute("hreflang",t)}get tref(){return this.hasAttribute("tref")?this.getAttribute("tref"):M.BLANK_TT_TREF}set tref(t){t&&this.setAttribute("tref",t)}get media(){return M._metaContentToObject(this.getAttribute("media"))}set media(t){this.setAttribute("media",t)}get tms(){return this.hasAttribute("tms")}set tms(t){t&&this.setAttribute("tms","")}get projection(){return this.getAttribute("projection")}set projection(t){["OSMTILE","CBMTILE","WGS84","APSTILE"].includes(t)&&this.setAttribute("projection",t)}get extent(){return this._templateVars?Object.assign(M._convertAndFormatPCRS(this.getBounds(),M[this.parentExtent.units],this.parentExtent.units),{zoom:this.getZoomBounds()}):null}zoomTo(){var h=this.extent;if(h){let t=this.getMapEl()._map,e=h.topLeft.pcrs.horizontal,s=h.bottomRight.pcrs.horizontal,i=h.bottomRight.pcrs.vertical,a=h.topLeft.pcrs.vertical,r=L.bounds(L.point(e,i),L.point(s,a)),o=t.options.crs.unproject(r.getCenter(!0)),n=h.zoom.maxZoom,l=h.zoom.minZoom;t.setView(o,M.getMaxZoom(r,t,l,n),{animate:!1})}}getMapEl(){return M.getClosest(this,"mapml-viewer,map[is=web-map]")}getLayerEl(){return M.getClosest(this,"layer-")}attributeChangedCallback(t,e,s){if(this.#hasConnected)switch(t){case"type":case"rel":case"href":case"hreflang":break;case"tref":e!==s&&this._initTemplateVars()}}constructor(){super()}connectedCallback(){if(this.#hasConnected=!0,!(this.getLayerEl().hasAttribute("data-moving")||this.parentExtent&&this.parentExtent.hasAttribute("data-moving")))switch(this.rel.toLowerCase()){case"tile":case"image":case"features":case"query":this._initTemplateVars(),this._createTemplatedLink();break;case"style":case"self":case"style self":case"self style":this._createSelfOrStyleLink();break;case"zoomin":case"zoomout":case"legend":break;case"stylesheet":var t;"application/pmtiles+stylesheet"===this.type?(t=new URL(this.href,this.getBase()).href,import(t).then(t=>{this._pmtilesRules=t.pmtilesRules}).catch(t=>{console.error("Error importing pmtiles symbolizer rules or theme: \n"+t)})):this._createStylesheetLink();break;case"alternate":this._createAlternateLink()}}disconnectedCallback(){"stylesheet"===this.rel.toLowerCase()&&this._stylesheetHost&&this.link.remove()}_createAlternateLink(t){this.href&&this.projection&&(this._alternate=!0)}_createStylesheetLink(){var t,e;this._stylesheetHost=this.getRootNode()instanceof ShadowRoot?this.getRootNode().host:this.parentElement,void 0!==this._stylesheetHost&&(this.link=document.createElement("link"),(this.link.mapLink=this).link.setAttribute("href",new URL(this.href,this.getBase()).href),e=(t=this).link,Array.from(t.attributes).forEach(t=>{"href"!==t.nodeName&&e.setAttribute(t.nodeName,t.nodeValue)}),this._stylesheetHost._layer?this._stylesheetHost._layer.appendStyleLink(this):this._stylesheetHost._templatedLayer?this._stylesheetHost._templatedLayer.appendStyleLink(this):this._stylesheetHost._extentLayer&&this._stylesheetHost._extentLayer.appendStyleLink(this))}async _createTemplatedLink(){if(this.parentExtent="MAP-EXTENT"===this.parentNode.nodeName.toUpperCase()?this.parentNode:this.parentNode.host,this.tref&&this.parentExtent){try{await this.parentExtent.whenReady(),await this._templateVars.inputsReady}catch(t){return void console.log("Error while creating templated link: "+t)}var t;this.mapEl=this.getMapEl(),this.zIndex=Array.from(this.parentExtent.querySelectorAll("map-link[rel=image],map-link[rel=tile],map-link[rel=features]")).indexOf(this),"tile"===this.rel&&"application/pmtiles"===this.type||"application/vnd.mapbox-vector-tile"===this.type?(t='map-link[rel="stylesheet"][type="application/pmtiles+stylesheet"]',t=M.getClosest(this,"map-extent:has("+t+"),layer-:has("+t+"),mapml-viewer:has("+t+")")?.querySelector(t)._pmtilesRules,t={zoomBounds:this.getZoomBounds(),extentBounds:this.getBounds(),crs:M[this.parentExtent.units],zIndex:this.zIndex,pane:this.parentExtent._extentLayer.getContainer(),linkEl:this,pmtilesRules:t},this._templatedLayer=M.templatedPMTilesLayer(this._templateVars,t).addTo(this.parentExtent._extentLayer)):"tile"===this.rel?this._templatedLayer=M.templatedTileLayer(this._templateVars,{zoomBounds:this.getZoomBounds(),extentBounds:this.getBounds(),crs:M[this.parentExtent.units],errorTileUrl:"data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==",zIndex:this.zIndex,pane:this.parentExtent._extentLayer.getContainer(),linkEl:this}).addTo(this.parentExtent._extentLayer):"image"===this.rel?this._templatedLayer=M.templatedImageLayer(this._templateVars,{zoomBounds:this.getZoomBounds(),extentBounds:this.getBounds(),zIndex:this.zIndex,pane:this.parentExtent._extentLayer.getContainer(),linkEl:this}).addTo(this.parentExtent._extentLayer):"features"===this.rel?(this.attachShadow({mode:"open"}),this._templatedLayer=M.templatedFeaturesLayer(this._templateVars,{zoomBounds:this.getZoomBounds(),extentBounds:this.getBounds(),zIndex:this.zIndex,pane:this.parentExtent._extentLayer.getContainer(),linkEl:this}).addTo(this.parentExtent._extentLayer)):"query"===this.rel&&(this.attachShadow({mode:"open"}),L.extend(this._templateVars,this._setupQueryVars(this._templateVars)),L.extend(this._templateVars,{extentBounds:this.getBounds()}))}}_setupQueryVars(t){for(var e={query:{}},s=t.values,i=0;i{let i,a,r;switch(this.rel.toLowerCase()){case"tile":case"image":case"features":r="_templatedLayer";break;case"style":case"self":case"style self":case"self style":r="_styleOption";break;case"query":r="shadowRoot";break;case"alternate":r="_alternate";break;case"stylesheet":"application/pmtiles+stylesheet"===this.type?r=_pmtilesRules:e();break;default:e()}this[r]&&e(),i=setInterval(function(t){t[r]?(clearInterval(i),clearTimeout(a),e()):t.isConnected||(clearInterval(i),clearTimeout(a),s("map-link was disconnected while waiting to be ready"))},300,this),a=setTimeout(function(){clearInterval(i),clearTimeout(a),s("Timeout reached waiting for link to be ready")},1e4)})}}export{MapLink}; //# sourceMappingURL=map-link.js.map \ No newline at end of file diff --git a/src/dist/map-link.js.map b/src/dist/map-link.js.map index 2499d8c..8d3dabd 100644 --- a/src/dist/map-link.js.map +++ b/src/dist/map-link.js.map @@ -1 +1 @@ -{"version":3,"file":"map-link.js","sources":["../src/map-link.js"],"sourcesContent":["/* global M */\n\nexport class MapLink extends HTMLElement {\n static get observedAttributes() {\n return [\n 'type',\n 'rel',\n // 'title',\n 'media',\n 'href',\n 'hreflang',\n 'tref',\n 'tms',\n 'projection'\n ];\n }\n /* jshint ignore:start */\n #hasConnected;\n /* jshint ignore:end */\n get type() {\n return this.getAttribute('type') || 'image/*';\n }\n set type(val) {\n // improve this\n if (val === 'text/mapml' || val.startsWith('image/')) {\n this.setAttribute('type', val);\n }\n }\n get rel() {\n // rel value has no default value\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel#:~:text=The%20rel%20attribute%20has%20no%20default%20value.\n return this.getAttribute('rel');\n }\n set rel(val) {\n // improve this\n if (\n [\n 'license',\n 'alternate',\n 'self',\n 'style',\n 'tile',\n 'image',\n 'features',\n 'zoomin',\n 'zoomout',\n 'legend',\n 'query',\n 'stylesheet'\n ].includes(val)\n ) {\n this.setAttribute('type', val);\n }\n }\n // get title() {\n // return this.getAttribute('title');\n // }\n // set title(val) {\n // if (val) {\n // this.setAttribute('title', val);\n // }\n // }\n get href() {\n if (this.hasAttribute('href')) {\n return new URL(this.getAttribute('href'), this.getBase()).href;\n } else if (this.hasAttribute('tref')) {\n return this.resolve();\n }\n }\n set href(val) {\n // improve this\n if (val) {\n this.setAttribute('href', val);\n }\n }\n get hreflang() {\n return this.getAttribute('hreflang');\n }\n set hreflang(val) {\n // improve this\n if (val) {\n this.setAttribute('hreflang', val);\n }\n }\n get tref() {\n if (!this.hasAttribute('tref')) {\n return M.BLANK_TT_TREF;\n }\n return this.getAttribute('tref');\n }\n set tref(val) {\n // improve this\n if (val) {\n this.setAttribute('tref', val);\n }\n }\n get media() {\n // return the content of media attribute as an object\n // maybe memoizing the object to avoid repeated formatting\n // the Util function may need to be renamed?\n return M._metaContentToObject(this.getAttribute('media'));\n }\n set media(val) {\n this.setAttribute('media', val);\n }\n get tms() {\n return this.hasAttribute('tms');\n }\n set tms(val) {\n // improve this\n if (val) {\n this.setAttribute('tms', '');\n }\n }\n get projection() {\n return this.getAttribute('projection');\n }\n set projection(val) {\n // improve this\n if (['OSMTILE', 'CBMTILE', 'WGS84', 'APSTILE'].includes(val)) {\n this.setAttribute('projection', val);\n }\n }\n get extent() {\n // calculate the bounds of content, return it.\n // _templateVars existence happens for both templated layers and query links\n return this._templateVars\n ? Object.assign(\n M._convertAndFormatPCRS(\n this.getBounds(),\n M[this.parentExtent.units],\n this.parentExtent.units\n ),\n { zoom: this.getZoomBounds() }\n )\n : null;\n }\n zoomTo() {\n let extent = this.extent;\n if (!extent) return;\n let map = this.getMapEl()._map,\n xmin = extent.topLeft.pcrs.horizontal,\n xmax = extent.bottomRight.pcrs.horizontal,\n ymin = extent.bottomRight.pcrs.vertical,\n ymax = extent.topLeft.pcrs.vertical,\n bounds = L.bounds(L.point(xmin, ymin), L.point(xmax, ymax)),\n center = map.options.crs.unproject(bounds.getCenter(true)),\n maxZoom = extent.zoom.maxZoom,\n minZoom = extent.zoom.minZoom;\n map.setView(center, M.getMaxZoom(bounds, map, minZoom, maxZoom), {\n animate: false\n });\n }\n getMapEl() {\n return M.getClosest(this, 'mapml-viewer,map[is=web-map]');\n }\n getLayerEl() {\n return M.getClosest(this, 'layer-');\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n //['type','rel','href','hreflang','tref','tms','projection'];\n // fold to lowercase\n if (this.#hasConnected /* jshint ignore:line */) {\n switch (name) {\n case 'type':\n // rel = tile, features, etc. TBD when it is used\n // ttype = !t.hasAttribute('type')\n // ? 'image/*'\n // : t.getAttribute('type').toLowerCase(),\n\n if (oldValue !== newValue) {\n // default value image/*\n // handle side effects\n }\n break;\n case 'rel':\n // mandatory attribute, no default value\n if (oldValue !== newValue) {\n // handle side effects\n if (newValue === 'query') {\n }\n }\n break;\n // case 'title':\n // if (oldValue !== newValue) {\n // // handle side effects\n // }\n // break;\n case 'href':\n // rel = license, legend, stylesheet, self, style, self style, style self, zoomin, zoomout\n if (oldValue !== newValue) {\n // handle side effects\n }\n break;\n case 'hreflang':\n // rel = *all*\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#hreflang\n // idea is that we can have multiple map-links with different hreflang, and map-extent chooses a map-link that matches with user's lang. Not a priority. - create an use-case issue?\n if (oldValue !== newValue) {\n // handle side effects\n }\n break;\n case 'tref':\n // rel = tile, image, features, query\n if (oldValue !== newValue) {\n // create or reset the _templateVars property\n this._initTemplateVars();\n }\n break;\n case 'media':\n break;\n case 'tms':\n // rel = tile\n if (oldValue !== newValue) {\n // handle side effects\n }\n break;\n case 'projection':\n // rel = alternate\n if (oldValue !== newValue) {\n // handle side effects\n }\n break;\n }\n }\n }\n constructor() {\n // Always call super first in constructor\n super();\n }\n connectedCallback() {\n this.#hasConnected = true; /* jshint ignore:line */\n if (\n this.getLayerEl().hasAttribute('data-moving') ||\n (this.parentExtent && this.parentExtent.hasAttribute('data-moving'))\n )\n return;\n switch (this.rel.toLowerCase()) {\n // for some cases, require a dependency check\n case 'tile':\n case 'image':\n case 'features':\n case 'query':\n this._initTemplateVars();\n this._createTemplatedLink();\n break;\n case 'style':\n case 'self':\n case 'style self':\n case 'self style':\n this._createSelfOrStyleLink();\n break;\n case 'zoomin':\n case 'zoomout':\n // this._createZoominOrZoomoutLink();\n break;\n case 'legend':\n //this._createLegendLink();\n break;\n case 'stylesheet':\n this._createStylesheetLink();\n break;\n case 'alternate':\n this._createAlternateLink(); // add media attribute\n break;\n case 'license':\n // this._createLicenseLink();\n break;\n }\n // create the type of templated leaflet layer appropriate to the rel value\n // image/map/features = templated(Image/Feature), tile=templatedTile,\n // this._tempatedTileLayer = M.templatedTile(pane: this.extentElement._leafletLayer._container)\n // add to viewer._map dependant on map-extent.checked, layer-.checked\n // what else?\n }\n disconnectedCallback() {\n switch (this.rel.toLowerCase()) {\n case 'stylesheet':\n if (this._stylesheetHost) {\n this.link.remove();\n }\n break;\n default:\n break;\n }\n }\n _createAlternateLink(mapml) {\n if (this.href && this.projection) this._alternate = true;\n }\n _createStylesheetLink() {\n // if the parent element is a map-link, the stylesheet is a link that should\n // be loaded as part of a templated layer processing i.e. on moveend\n // and the generated that implements this should be located\n // in the parent ._templatedLayer.container root node if\n // the _templatedLayer is an instance of M.TemplatedTileLayer or M.TemplatedFeaturesLayer\n //\n // if the parent node (or the host of the shadow root parent node) is layer-, the link should be created in the _layer\n // container\n this._stylesheetHost =\n this.getRootNode() instanceof ShadowRoot\n ? this.getRootNode().host\n : this.parentElement;\n if (this._stylesheetHost === undefined) return;\n\n this.link = document.createElement('link');\n this.link.mapLink = this;\n this.link.setAttribute('href', new URL(this.href, this.getBase()).href);\n copyAttributes(this, this.link);\n\n if (this._stylesheetHost._layer) {\n this._stylesheetHost._layer.appendStyleLink(this);\n } else if (this._stylesheetHost._templatedLayer) {\n this._stylesheetHost._templatedLayer.appendStyleLink(this);\n } else if (this._stylesheetHost._extentLayer) {\n this._stylesheetHost._extentLayer.appendStyleLink(this);\n }\n\n function copyAttributes(source, target) {\n return Array.from(source.attributes).forEach((attribute) => {\n if (attribute.nodeName !== 'href')\n target.setAttribute(attribute.nodeName, attribute.nodeValue);\n });\n }\n }\n\n async _createTemplatedLink() {\n // conditions check\n // the tms and type attributes are optional, may need to be checked in future\n this.parentExtent =\n this.parentNode.nodeName.toUpperCase() === 'MAP-EXTENT'\n ? this.parentNode\n : this.parentNode.host;\n if (!this.tref || !this.parentExtent) return;\n try {\n await this.parentExtent.whenReady();\n await this._templateVars.inputsReady;\n } catch (error) {\n console.log('Error while creating templated link: ' + error);\n return;\n }\n this.mapEl = this.getMapEl();\n // create the layer type appropriate to the rel value\n this.zIndex = Array.from(\n this.parentExtent.querySelectorAll(\n 'map-link[rel=image],map-link[rel=tile],map-link[rel=features]'\n )\n ).indexOf(this);\n if (this.rel === 'tile') {\n this._templatedLayer = M.templatedTileLayer(this._templateVars, {\n zoomBounds: this.getZoomBounds(),\n extentBounds: this.getBounds(),\n crs: M[this.parentExtent.units],\n errorTileUrl:\n 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==',\n zIndex: this.zIndex,\n pane: this.parentExtent._extentLayer.getContainer(),\n linkEl: this\n }).addTo(this.parentExtent._extentLayer);\n } else if (this.rel === 'image') {\n this._templatedLayer = M.templatedImageLayer(this._templateVars, {\n zoomBounds: this.getZoomBounds(),\n extentBounds: this.getBounds(),\n zIndex: this.zIndex,\n pane: this.parentExtent._extentLayer.getContainer(),\n linkEl: this\n }).addTo(this.parentExtent._extentLayer);\n } else if (this.rel === 'features') {\n // map-feature retrieved by link will be stored in shadowRoot owned by link\n this.attachShadow({ mode: 'open' });\n this._templatedLayer = M.templatedFeaturesLayer(this._templateVars, {\n zoomBounds: this.getZoomBounds(),\n extentBounds: this.getBounds(),\n zIndex: this.zIndex,\n pane: this.parentExtent._extentLayer.getContainer(),\n linkEl: this\n }).addTo(this.parentExtent._extentLayer);\n } else if (this.rel === 'query') {\n this.attachShadow({ mode: 'open' });\n L.extend(this._templateVars, this._setupQueryVars(this._templateVars));\n L.extend(this._templateVars, { extentBounds: this.getBounds() });\n }\n }\n _setupQueryVars(template) {\n // process the inputs associated to template and create an object named\n // query with member properties as follows:\n // {width: 'widthvarname',\n // height: 'heightvarname',\n // left: 'leftvarname',\n // right: 'rightvarname',\n // top: 'topvarname',\n // bottom: 'bottomvarname'\n // i: 'ivarname'\n // j: 'jvarname'}\n // x: 'xvarname' x being the tcrs x axis\n // y: 'yvarname' y being the tcrs y axis\n // z: 'zvarname' zoom\n // title: link title\n\n var queryVarNames = { query: {} },\n inputs = template.values;\n\n for (var i = 0; i < template.values.length; i++) {\n var type = inputs[i].getAttribute('type'),\n units = inputs[i].getAttribute('units'),\n axis = inputs[i].getAttribute('axis'),\n name = inputs[i].getAttribute('name'),\n position = inputs[i].getAttribute('position'),\n rel = inputs[i].getAttribute('rel'),\n select = inputs[i].tagName.toLowerCase() === 'map-select';\n if (type === 'width') {\n queryVarNames.query.width = name;\n } else if (type === 'height') {\n queryVarNames.query.height = name;\n } else if (type === 'location') {\n switch (axis) {\n case 'x':\n case 'y':\n case 'column':\n case 'row':\n queryVarNames.query[axis] = name;\n break;\n case 'longitude':\n case 'easting':\n if (position) {\n if (position.match(/.*?-left/i)) {\n if (rel === 'pixel') {\n queryVarNames.query.pixelleft = name;\n } else if (rel === 'tile') {\n queryVarNames.query.tileleft = name;\n } else {\n queryVarNames.query.mapleft = name;\n }\n } else if (position.match(/.*?-right/i)) {\n if (rel === 'pixel') {\n queryVarNames.query.pixelright = name;\n } else if (rel === 'tile') {\n queryVarNames.query.tileright = name;\n } else {\n queryVarNames.query.mapright = name;\n }\n }\n } else {\n queryVarNames.query[axis] = name;\n }\n break;\n case 'latitude':\n case 'northing':\n if (position) {\n if (position.match(/top-.*?/i)) {\n if (rel === 'pixel') {\n queryVarNames.query.pixeltop = name;\n } else if (rel === 'tile') {\n queryVarNames.query.tiletop = name;\n } else {\n queryVarNames.query.maptop = name;\n }\n } else if (position.match(/bottom-.*?/i)) {\n if (rel === 'pixel') {\n queryVarNames.query.pixelbottom = name;\n } else if (rel === 'tile') {\n queryVarNames.query.tilebottom = name;\n } else {\n queryVarNames.query.mapbottom = name;\n }\n }\n } else {\n queryVarNames.query[axis] = name;\n }\n break;\n case 'i':\n if (units === 'tile') {\n queryVarNames.query.tilei = name;\n } else {\n queryVarNames.query.mapi = name;\n }\n break;\n case 'j':\n if (units === 'tile') {\n queryVarNames.query.tilej = name;\n } else {\n queryVarNames.query.mapj = name;\n }\n break;\n default:\n // unsuportted axis value\n }\n } else if (type === 'zoom') {\n //\n queryVarNames.query.zoom = name;\n } else if (select) {\n /*jshint -W104 */\n const parsedselect = inputs[i].htmlselect;\n queryVarNames.query[name] = function () {\n return parsedselect.value;\n };\n } else {\n /*jshint -W104 */\n const input = inputs[i];\n queryVarNames.query[name] = function () {\n return input.getAttribute('value');\n };\n }\n }\n return queryVarNames;\n }\n _initTemplateVars() {\n // set up the URL template and associated inputs (which yield variable values when processed)\n var varNamesRe = new RegExp('(?:{)(.*?)(?:})', 'g'),\n zoomInput = this.parentElement.querySelector('map-input[type=\"zoom\" i]'),\n includesZoom = false,\n linkedZoomInput;\n\n var template = this.tref;\n if (template === M.BLANK_TT_TREF) {\n for (let i of this.parentElement.querySelectorAll('map-input')) {\n template += `{${i.getAttribute('name')}}`;\n }\n }\n this.zoomInput = zoomInput;\n\n var v,\n vcount = template.match(varNamesRe) || [],\n inputs = [],\n inputsReady = [];\n while ((v = varNamesRe.exec(template)) !== null) {\n let varName = v[1],\n inp = this.parentElement.querySelector(\n 'map-input[name=' + varName + '],map-select[name=' + varName + ']'\n );\n if (inp) {\n // this \"associates\" the input to this map-link\n inputs.push(inp);\n inputsReady.push(inp.whenReady());\n\n // I think this means that regardless of whether the tref includes\n // a reference to the zoom input, it gets associated to the link\n // and used (to specify the native zoom bounds??) for the templated(Tile|Image|Features)Layer\n if (\n inp.hasAttribute('type') &&\n inp.getAttribute('type').toLowerCase() === 'zoom'\n ) {\n linkedZoomInput = inp;\n includesZoom = true;\n }\n // moved a block to map-select to transcribe the map-select into an\n // actual html select for inclusion in the layer control.\n\n // TODO: if this is an input@type=location\n // get the TCRS min,max attribute values at the identified zoom level\n // save this information as properties of the mapExtent,\n // perhaps as a bounds object so that it can be easily used\n // later by the layer control to determine when to enable\n // disable the layer for drawing.\n } else {\n console.log(\n 'input with name=' +\n varName +\n ' not found for template variable of same name'\n );\n }\n }\n if (template && vcount.length === inputs.length) {\n if (!includesZoom && zoomInput) {\n inputs.push(zoomInput);\n linkedZoomInput = zoomInput;\n }\n let step = zoomInput ? zoomInput.getAttribute('step') : 1;\n if (!step || step === '0' || isNaN(step)) step = 1;\n // template has a matching input for every variable reference {varref}\n this._templateVars = {\n template: decodeURI(new URL(template, this.getBase())),\n linkEl: this,\n rel: this.rel,\n type: this.type,\n values: inputs,\n inputsReady: Promise.allSettled(inputsReady),\n zoom: linkedZoomInput,\n projection: this.parentElement.units,\n tms: this.tms,\n step: step\n };\n }\n }\n getZoomBounds() {\n return this._getZoomBounds(this._templateVars.zoom);\n }\n /**\n * TODO: review getBounds for sanity, also getFallbackBounds, perhaps integrate\n * there is no other kind of bounds but native....\n * each rectangle must be established and valid and converted to PCRS coordinates...\n // \"native\" bounds = input type=location min max || map-extent/map-meta name=extent min,max || layer-/map-meta name=extent min,max || layer projection min/max\n */\n getBounds() {\n let template = this._templateVars;\n let inputs = template.values,\n projection = this.parentElement.units,\n boundsUnit = {};\n boundsUnit.name = M.FALLBACK_CS;\n let bounds = M[projection].options.crs.tilematrix.bounds(0),\n locInputs = false,\n numberOfAxes = 0,\n horizontalAxis = false,\n verticalAxis = false;\n for (let i = 0; i < inputs.length; i++) {\n if (inputs[i].getAttribute('type') === 'location') {\n if (!inputs[i].getAttribute('max') || !inputs[i].getAttribute('min'))\n continue;\n let max = +inputs[i].getAttribute('max'),\n min = +inputs[i].getAttribute('min');\n switch (inputs[i].getAttribute('axis').toLowerCase()) {\n case 'x':\n case 'longitude':\n case 'column':\n case 'easting':\n boundsUnit.name = M.axisToCS(\n inputs[i].getAttribute('axis').toLowerCase()\n );\n bounds.min.x = min;\n bounds.max.x = max;\n boundsUnit.horizontalAxis = inputs[i]\n .getAttribute('axis')\n .toLowerCase();\n break;\n case 'y':\n case 'latitude':\n case 'row':\n case 'northing':\n boundsUnit.name = M.axisToCS(\n inputs[i].getAttribute('axis').toLowerCase()\n );\n bounds.min.y = min;\n bounds.max.y = max;\n boundsUnit.verticalAxis = inputs[i]\n .getAttribute('axis')\n .toLowerCase();\n break;\n default:\n break;\n }\n }\n }\n if (\n boundsUnit.horizontalAxis &&\n boundsUnit.verticalAxis &&\n ((boundsUnit.horizontalAxis === 'x' && boundsUnit.verticalAxis === 'y') ||\n (boundsUnit.horizontalAxis === 'longitude' &&\n boundsUnit.verticalAxis === 'latitude') ||\n (boundsUnit.horizontalAxis === 'column' &&\n boundsUnit.verticalAxis === 'row') ||\n (boundsUnit.horizontalAxis === 'easting' &&\n boundsUnit.verticalAxis === 'northing'))\n ) {\n locInputs = true;\n }\n if (locInputs) {\n let zoomValue = this._templateVars.zoom?.hasAttribute('value')\n ? +this._templateVars.zoom.getAttribute('value')\n : 0;\n bounds = M.boundsToPCRSBounds(\n bounds,\n zoomValue,\n projection,\n boundsUnit.name\n );\n } else if (!locInputs) {\n bounds = this.getFallbackBounds(projection);\n }\n return bounds;\n }\n getFallbackBounds(projection) {\n let bounds;\n\n let zoom = 0;\n let metaExtent = this.parentElement.getMeta('extent');\n if (metaExtent) {\n let content = M._metaContentToObject(metaExtent.getAttribute('content')),\n cs;\n\n zoom = content.zoom || zoom;\n\n let metaKeys = Object.keys(content);\n for (let i = 0; i < metaKeys.length; i++) {\n if (!metaKeys[i].includes('zoom')) {\n cs = M.axisToCS(metaKeys[i].split('-')[2]);\n break;\n }\n }\n let axes = M.csToAxes(cs);\n bounds = M.boundsToPCRSBounds(\n L.bounds(\n L.point(\n +content[`top-left-${axes[0]}`],\n +content[`top-left-${axes[1]}`]\n ),\n L.point(\n +content[`bottom-right-${axes[0]}`],\n +content[`bottom-right-${axes[1]}`]\n )\n ),\n zoom,\n projection,\n cs\n );\n } else {\n let crs = M[projection];\n bounds = crs.options.crs.pcrs.bounds;\n }\n return bounds;\n }\n getBase() {\n let layer = this.getRootNode().host;\n //\n let relativeURL =\n this.getRootNode().querySelector('map-base') &&\n this.getRootNode() instanceof ShadowRoot\n ? this.getRootNode().querySelector('map-base').getAttribute('href')\n : /* local content? */ !(this.getRootNode() instanceof ShadowRoot)\n ? /* use the baseURI algorithm which takes into account any */\n this.getRootNode().querySelector('map-base')?.getAttribute('href') ||\n this.baseURI\n : /* else use the resolved value */ new URL(\n layer.src,\n layer.baseURI\n ).href;\n\n // when remote content, use layer.src as base else use baseURI of map-link\n let baseURL =\n this.getRootNode() instanceof ShadowRoot\n ? new URL(layer.src, layer.baseURI).href\n : this.baseURI;\n return new URL(relativeURL, baseURL).href;\n }\n /**\n * Return BOTH min/max(Display)Zoom AND min/maxNativeZoom which\n * are options that can be passed to L.GridLayer...\n * https://leafletjs.com/reference.html#gridlayer-minzoom\n *\n * @param {Object} zoomInput - is an element reference to a map-input[type=zoom]\n * @returns {Object} - returns {minZoom: n,maxZoom: n,minNativeZoom: n,maxNativeZoom: n}\n */\n _getZoomBounds(zoomInput) {\n // native variables should ONLY come from map-input min/max attributes\n // BUT they should fall back to map-meta or projection values for min/max (display) zoom\n // display zoom variables should be EQUAL to native unless specified differently\n // via map-meta name=zoom\n // in particular minNativeZoom being > minZoom can be problematic because\n // you fetch tiles at larger scales (i.e. many many small tiles) and render\n // them at smaller scale (i.e. little postage stamps), which can freez your\n // browser and bury a tile cache in requests, getting you banned/blocked\n //\n // minZoom = map-meta name=zoom min || input type=zoom min || projection minZoom\n // minNativeZoom = input type=zoom min || minZoom\n // maxZoom = map-meta name=zoom max || input type=zoom max || projection maxZoom\n // maxNativeZoom = input type=zoom max || maxZoom\n\n let zoomBounds = {};\n // search document from here up, using closest source of zoom bounds info\n let meta = this.parentElement.getMeta('zoom');\n let metaMin = meta\n ? +M._metaContentToObject(meta.getAttribute('content'))?.min\n : null;\n zoomBounds.minZoom =\n metaMin || (zoomInput ? +zoomInput.getAttribute('min') : 0);\n zoomBounds.minNativeZoom = zoomInput\n ? +zoomInput.getAttribute('min')\n : zoomBounds.minZoom;\n let metaMax = meta\n ? +M._metaContentToObject(meta.getAttribute('content'))?.max\n : null;\n zoomBounds.maxZoom =\n metaMax ||\n (zoomInput\n ? +zoomInput.getAttribute('max')\n : M[this.parentElement.units].options.resolutions.length - 1);\n zoomBounds.maxNativeZoom = zoomInput\n ? +zoomInput.getAttribute('max')\n : zoomBounds.maxZoom;\n\n return zoomBounds;\n }\n _validateDisabled() {\n let isVisible = false,\n map = this.getMapEl(),\n mapZoom = map.zoom,\n extent = map.extent,\n xmin = extent.topLeft.pcrs.horizontal,\n xmax = extent.bottomRight.pcrs.horizontal,\n ymin = extent.bottomRight.pcrs.vertical,\n ymax = extent.topLeft.pcrs.vertical,\n mapBounds = L.bounds(L.point(xmin, ymin), L.point(xmax, ymax));\n\n if (this._templatedLayer) {\n isVisible = this._templatedLayer.isVisible();\n } else if (this.rel === 'query') {\n const minZoom = this.extent.zoom.minZoom,\n maxZoom = this.extent.zoom.maxZoom,\n withinZoomBounds = (z) => {\n return minZoom <= z && z <= maxZoom;\n };\n\n if (this.getBounds().overlaps(mapBounds) && withinZoomBounds(mapZoom)) {\n isVisible = true;\n }\n }\n return isVisible;\n }\n _createSelfOrStyleLink() {\n let layerEl = this.getLayerEl();\n const changeStyle = function (e) {\n L.DomEvent.stop(e);\n layerEl.dispatchEvent(\n new CustomEvent('changestyle', {\n detail: {\n src: e.target.getAttribute('data-href'),\n preference: this.media['prefers-map-content']\n }\n })\n );\n };\n\n let styleOption = document.createElement('div'),\n styleOptionInput = styleOption.appendChild(\n document.createElement('input')\n );\n styleOptionInput.setAttribute('type', 'radio');\n styleOptionInput.setAttribute('id', 'rad-' + L.stamp(styleOptionInput));\n styleOptionInput.setAttribute(\n 'name',\n // grouping radio buttons based on parent layer's style \n 'styles-' + L.stamp(styleOption)\n );\n styleOptionInput.setAttribute('value', this.getAttribute('title'));\n styleOptionInput.setAttribute(\n 'data-href',\n new URL(this.href, this.getBase()).href\n );\n var styleOptionLabel = styleOption.appendChild(\n document.createElement('label')\n );\n styleOptionLabel.setAttribute('for', 'rad-' + L.stamp(styleOptionInput));\n styleOptionLabel.innerText = this.title;\n if (this.rel === 'style self' || this.rel === 'self style') {\n styleOptionInput.checked = true;\n }\n this._styleOption = styleOption;\n styleOptionInput.addEventListener('click', changeStyle.bind(this));\n }\n getLayerControlOption() {\n return this._styleOption;\n }\n\n // Resolve the templated URL with info from the sibling map-input's\n resolve() {\n if (this.tref) {\n let obj = {};\n const inputs = this.parentElement.querySelectorAll('map-input');\n if (this.rel === 'image') {\n // image/map\n for (let i = 0; i < inputs.length; i++) {\n const inp = inputs[i];\n obj[inp.name] = inp.value;\n }\n console.log(obj); // DEBUGGING\n return L.Util.template(this.tref, obj);\n } else if (this.rel === 'tile') {\n // TODO. Need to get tile coords from moveend\n // should be done/called from the TemplatedTilelayer.js file\n return obj;\n } else if (this.rel === 'query') {\n // TODO. Need to get the click coords from click event\n // should be done/called from the templatedlayer.js file\n } else if (this.rel === 'features') {\n // TODO.\n }\n }\n }\n whenReady() {\n return new Promise((resolve, reject) => {\n let interval, failureTimer, ready;\n switch (this.rel.toLowerCase()) {\n // for some cases, require a dependency check\n case 'tile':\n case 'image':\n case 'features':\n ready = '_templatedLayer';\n break;\n case 'style':\n case 'self':\n case 'style self':\n case 'self style':\n ready = '_styleOption';\n break;\n case 'query':\n ready = 'shadowRoot';\n break;\n case 'alternate':\n ready = '_alternate';\n break;\n case 'zoomin':\n case 'zoomout':\n case 'legend':\n case 'stylesheet':\n case 'license':\n resolve();\n break;\n default:\n resolve();\n break;\n }\n if (this[ready]) {\n resolve();\n }\n interval = setInterval(testForLinkReady, 300, this);\n failureTimer = setTimeout(linkNotDefined, 10000);\n function testForLinkReady(linkElement) {\n if (linkElement[ready]) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n resolve();\n } else if (!linkElement.isConnected) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('map-link was disconnected while waiting to be ready');\n }\n }\n function linkNotDefined() {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Timeout reached waiting for link to be ready');\n }\n });\n }\n}\n"],"names":["MapLink","HTMLElement","observedAttributes","#hasConnected","type","this","getAttribute","val","startsWith","setAttribute","rel","includes","href","hasAttribute","URL","getBase","resolve","hreflang","tref","M","BLANK_TT_TREF","media","_metaContentToObject","tms","projection","extent","_templateVars","Object","assign","_convertAndFormatPCRS","getBounds","parentExtent","units","zoom","getZoomBounds","zoomTo","let","map","getMapEl","_map","xmin","topLeft","pcrs","horizontal","xmax","bottomRight","ymin","vertical","ymax","bounds","L","point","center","options","crs","unproject","getCenter","maxZoom","minZoom","setView","getMaxZoom","animate","getClosest","getLayerEl","attributeChangedCallback","name","oldValue","newValue","_initTemplateVars","constructor","super","connectedCallback","toLowerCase","_createTemplatedLink","_createSelfOrStyleLink","_createStylesheetLink","_createAlternateLink","disconnectedCallback","_stylesheetHost","link","remove","mapml","_alternate","source","target","getRootNode","ShadowRoot","host","parentElement","undefined","document","createElement","mapLink","Array","from","attributes","forEach","attribute","nodeName","nodeValue","_layer","appendStyleLink","_templatedLayer","_extentLayer","parentNode","toUpperCase","whenReady","inputsReady","error","console","log","mapEl","zIndex","querySelectorAll","indexOf","templatedTileLayer","zoomBounds","extentBounds","errorTileUrl","pane","getContainer","linkEl","addTo","templatedImageLayer","attachShadow","mode","templatedFeaturesLayer","extend","_setupQueryVars","template","queryVarNames","query","inputs","values","i","length","axis","position","select","tagName","width","height","match","pixelleft","tileleft","mapleft","pixelright","tileright","mapright","pixeltop","tiletop","maptop","pixelbottom","tilebottom","mapbottom","tilei","mapi","tilej","mapj","parsedselect","htmlselect","value","input","linkedZoomInput","varNamesRe","RegExp","zoomInput","querySelector","includesZoom","v","vcount","exec","varName","inp","push","step","isNaN","decodeURI","Promise","allSettled","_getZoomBounds","zoomValue","boundsUnit","FALLBACK_CS","tilematrix","locInputs","max","min","axisToCS","x","horizontalAxis","y","verticalAxis","boundsToPCRSBounds","getFallbackBounds","metaExtent","getMeta","content","cs","metaKeys","keys","split","axes","csToAxes","layer","relativeURL","src","baseURI","baseURL","meta","metaMin","minNativeZoom","metaMax","resolutions","maxNativeZoom","_validateDisabled","isVisible","mapZoom","mapBounds","overlaps","z","layerEl","styleOption","styleOptionInput","appendChild","stamp","styleOptionLabel","innerText","title","checked","_styleOption","addEventListener","e","DomEvent","stop","dispatchEvent","CustomEvent","detail","preference","bind","getLayerControlOption","obj","Util","reject","interval","failureTimer","ready","setInterval","linkElement","clearInterval","clearTimeout","isConnected","setTimeout"],"mappings":";;MAEaA,gBAAgBC,YAC3BC,gCACE,MAAO,CACL,OACA,MAEA,Q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M7G,EAAS/H,KAAKmF,cAAcyB,iBAAiB,aACnD,GAAiB,UAAb5G,KAAKK,IAAiB,CAExB,IAAK0B,IAAIkG,EAAI,EAAGA,EAAIF,EAAOG,OAAQD,IAAK,CACtC,IAAMuC,EAAMzC,EAAOE,GACnB2G,EAAIpE,EAAI5G,MAAQ4G,EAAIZ,MAGtB,OADApD,QAAQC,IAAImI,GACL/L,EAAEgM,KAAKjH,SAAS5H,KAAKa,KAAM+N,GAC7B,GAAiB,SAAb5O,KAAKK,IAGd,OAAOuO,EACe,UAAb5O,KAAKK,KAGLL,KAAKK,KAKpBgG,YACE,OAAO,IAAIwE,QAAQ,CAAClK,EAASmO,KAC3B/M,IAAIgN,EAAUC,EAAcC,EAC5B,OAAQjP,KAAKK,IAAI8D,eAEf,IAAK,OACL,IAAK,QACL,IAAK,WACH8K,EAAQ,kBACR,MACF,IAAK,QACL,IAAK,OACL,IAAK,aACL,IAAK,aACHA,EAAQ,eACR,MACF,IAAK,QACHA,EAAQ,aACR,MACF,IAAK,YACHA,EAAQ,aACR,MAQF,QACEtO,IAGAX,KAAKiP,IACPtO,IAEFoO,EAAWG,YAEX,SAA0BC,GACpBA,EAAYF,IACdG,cAAcL,GACdM,aAAaL,GACbrO,KACUwO,EAAYG,cACtBF,cAAcL,GACdM,aAAaL,GACbF,EAAO,yDAV8B,IAAK9O,MAC9CgP,EAAeO,WAYf,WACEH,cAAcL,GACdM,aAAaL,GACbF,EAAO,iDAfiC,eAh5BnCnP"} \ No newline at end of file +{"version":3,"file":"map-link.js","sources":["../src/map-link.js"],"sourcesContent":["/* global M */\n\nexport class MapLink extends HTMLElement {\n static get observedAttributes() {\n return [\n 'type',\n 'rel',\n // 'title',\n 'media',\n 'href',\n 'hreflang',\n 'tref',\n 'tms',\n 'projection'\n ];\n }\n /* jshint ignore:start */\n #hasConnected;\n /* jshint ignore:end */\n get type() {\n return this.getAttribute('type') || 'image/*';\n }\n set type(val) {\n // improve this\n if (\n val === 'text/mapml' ||\n val.startsWith('image/' || val === 'application/pmtiles')\n ) {\n this.setAttribute('type', val);\n }\n }\n get rel() {\n // rel value has no default value\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel#:~:text=The%20rel%20attribute%20has%20no%20default%20value.\n return this.getAttribute('rel');\n }\n set rel(val) {\n // improve this\n if (\n [\n 'license',\n 'alternate',\n 'self',\n 'style',\n 'tile',\n 'image',\n 'features',\n 'zoomin',\n 'zoomout',\n 'legend',\n 'query',\n 'stylesheet'\n ].includes(val)\n ) {\n this.setAttribute('type', val);\n }\n }\n // get title() {\n // return this.getAttribute('title');\n // }\n // set title(val) {\n // if (val) {\n // this.setAttribute('title', val);\n // }\n // }\n get href() {\n if (this.hasAttribute('href')) {\n return new URL(this.getAttribute('href'), this.getBase()).href;\n } else if (this.hasAttribute('tref')) {\n return this.resolve();\n }\n }\n set href(val) {\n // improve this\n if (val) {\n this.setAttribute('href', val);\n }\n }\n get hreflang() {\n return this.getAttribute('hreflang');\n }\n set hreflang(val) {\n // improve this\n if (val) {\n this.setAttribute('hreflang', val);\n }\n }\n get tref() {\n if (!this.hasAttribute('tref')) {\n return M.BLANK_TT_TREF;\n }\n return this.getAttribute('tref');\n }\n set tref(val) {\n // improve this\n if (val) {\n this.setAttribute('tref', val);\n }\n }\n get media() {\n // return the content of media attribute as an object\n // maybe memoizing the object to avoid repeated formatting\n // the Util function may need to be renamed?\n return M._metaContentToObject(this.getAttribute('media'));\n }\n set media(val) {\n this.setAttribute('media', val);\n }\n get tms() {\n return this.hasAttribute('tms');\n }\n set tms(val) {\n // improve this\n if (val) {\n this.setAttribute('tms', '');\n }\n }\n get projection() {\n return this.getAttribute('projection');\n }\n set projection(val) {\n // improve this\n if (['OSMTILE', 'CBMTILE', 'WGS84', 'APSTILE'].includes(val)) {\n this.setAttribute('projection', val);\n }\n }\n get extent() {\n // calculate the bounds of content, return it.\n // _templateVars existence happens for both templated layers and query links\n return this._templateVars\n ? Object.assign(\n M._convertAndFormatPCRS(\n this.getBounds(),\n M[this.parentExtent.units],\n this.parentExtent.units\n ),\n { zoom: this.getZoomBounds() }\n )\n : null;\n }\n zoomTo() {\n let extent = this.extent;\n if (!extent) return;\n let map = this.getMapEl()._map,\n xmin = extent.topLeft.pcrs.horizontal,\n xmax = extent.bottomRight.pcrs.horizontal,\n ymin = extent.bottomRight.pcrs.vertical,\n ymax = extent.topLeft.pcrs.vertical,\n bounds = L.bounds(L.point(xmin, ymin), L.point(xmax, ymax)),\n center = map.options.crs.unproject(bounds.getCenter(true)),\n maxZoom = extent.zoom.maxZoom,\n minZoom = extent.zoom.minZoom;\n map.setView(center, M.getMaxZoom(bounds, map, minZoom, maxZoom), {\n animate: false\n });\n }\n getMapEl() {\n return M.getClosest(this, 'mapml-viewer,map[is=web-map]');\n }\n getLayerEl() {\n return M.getClosest(this, 'layer-');\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n //['type','rel','href','hreflang','tref','tms','projection'];\n // fold to lowercase\n if (this.#hasConnected /* jshint ignore:line */) {\n switch (name) {\n case 'type':\n // rel = tile, features, etc. TBD when it is used\n // ttype = !t.hasAttribute('type')\n // ? 'image/*'\n // : t.getAttribute('type').toLowerCase(),\n\n if (oldValue !== newValue) {\n // default value image/*\n // handle side effects\n }\n break;\n case 'rel':\n // mandatory attribute, no default value\n if (oldValue !== newValue) {\n // handle side effects\n if (newValue === 'query') {\n }\n }\n break;\n // case 'title':\n // if (oldValue !== newValue) {\n // // handle side effects\n // }\n // break;\n case 'href':\n // rel = license, legend, stylesheet, self, style, self style, style self, zoomin, zoomout\n if (oldValue !== newValue) {\n // handle side effects\n }\n break;\n case 'hreflang':\n // rel = *all*\n // https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#hreflang\n // idea is that we can have multiple map-links with different hreflang, and map-extent chooses a map-link that matches with user's lang. Not a priority. - create an use-case issue?\n if (oldValue !== newValue) {\n // handle side effects\n }\n break;\n case 'tref':\n // rel = tile, image, features, query\n if (oldValue !== newValue) {\n // create or reset the _templateVars property\n this._initTemplateVars();\n }\n break;\n case 'media':\n break;\n case 'tms':\n // rel = tile\n if (oldValue !== newValue) {\n // handle side effects\n }\n break;\n case 'projection':\n // rel = alternate\n if (oldValue !== newValue) {\n // handle side effects\n }\n break;\n }\n }\n }\n constructor() {\n // Always call super first in constructor\n super();\n }\n connectedCallback() {\n this.#hasConnected = true; /* jshint ignore:line */\n if (\n this.getLayerEl().hasAttribute('data-moving') ||\n (this.parentExtent && this.parentExtent.hasAttribute('data-moving'))\n )\n return;\n switch (this.rel.toLowerCase()) {\n // for some cases, require a dependency check\n case 'tile':\n case 'image':\n case 'features':\n case 'query':\n this._initTemplateVars();\n this._createTemplatedLink();\n break;\n case 'style':\n case 'self':\n case 'style self':\n case 'self style':\n this._createSelfOrStyleLink();\n break;\n case 'zoomin':\n case 'zoomout':\n // this._createZoominOrZoomoutLink();\n break;\n case 'legend':\n //this._createLegendLink();\n break;\n case 'stylesheet':\n // MIME type application/pmtiles+stylesheet is an invention of the requirement to get\n // closer to loading style rules as CSS does, via link / (map-link)\n // we could probably do something similar with map-style i.e. treat the\n // content of map-style as though it was a stylesheet tbd caveat CSP\n if (this.type === 'application/pmtiles+stylesheet') {\n const pmtilesStyles = new URL(this.href, this.getBase()).href;\n import(pmtilesStyles)\n .then((module) => {\n this._pmtilesRules = module.pmtilesRules;\n })\n .catch((reason) => {\n console.error(\n 'Error importing pmtiles symbolizer rules or theme: \\n' + reason\n );\n });\n } else {\n this._createStylesheetLink();\n }\n break;\n case 'alternate':\n this._createAlternateLink(); // add media attribute\n break;\n case 'license':\n // this._createLicenseLink();\n break;\n }\n // create the type of templated leaflet layer appropriate to the rel value\n // image/map/features = templated(Image/Feature), tile=templatedTile,\n // this._tempatedTileLayer = M.templatedTile(pane: this.extentElement._leafletLayer._container)\n // add to viewer._map dependant on map-extent.checked, layer-.checked\n // what else?\n }\n disconnectedCallback() {\n switch (this.rel.toLowerCase()) {\n case 'stylesheet':\n if (this._stylesheetHost) {\n this.link.remove();\n }\n break;\n default:\n break;\n }\n }\n _createAlternateLink(mapml) {\n if (this.href && this.projection) this._alternate = true;\n }\n _createStylesheetLink() {\n // if the parent element is a map-link, the stylesheet is a link that should\n // be loaded as part of a templated layer processing i.e. on moveend\n // and the generated that implements this should be located\n // in the parent ._templatedLayer.container root node if\n // the _templatedLayer is an instance of M.TemplatedTileLayer or M.TemplatedFeaturesLayer\n //\n // if the parent node (or the host of the shadow root parent node) is layer-, the link should be created in the _layer\n // container\n this._stylesheetHost =\n this.getRootNode() instanceof ShadowRoot\n ? this.getRootNode().host\n : this.parentElement;\n if (this._stylesheetHost === undefined) return;\n\n this.link = document.createElement('link');\n this.link.mapLink = this;\n this.link.setAttribute('href', new URL(this.href, this.getBase()).href);\n copyAttributes(this, this.link);\n\n if (this._stylesheetHost._layer) {\n this._stylesheetHost._layer.appendStyleLink(this);\n } else if (this._stylesheetHost._templatedLayer) {\n this._stylesheetHost._templatedLayer.appendStyleLink(this);\n } else if (this._stylesheetHost._extentLayer) {\n this._stylesheetHost._extentLayer.appendStyleLink(this);\n }\n\n function copyAttributes(source, target) {\n return Array.from(source.attributes).forEach((attribute) => {\n if (attribute.nodeName !== 'href')\n target.setAttribute(attribute.nodeName, attribute.nodeValue);\n });\n }\n }\n\n async _createTemplatedLink() {\n // conditions check\n // the tms and type attributes are optional, may need to be checked in future\n this.parentExtent =\n this.parentNode.nodeName.toUpperCase() === 'MAP-EXTENT'\n ? this.parentNode\n : this.parentNode.host;\n if (!this.tref || !this.parentExtent) return;\n try {\n await this.parentExtent.whenReady();\n await this._templateVars.inputsReady;\n } catch (error) {\n console.log('Error while creating templated link: ' + error);\n return;\n }\n this.mapEl = this.getMapEl();\n // create the layer type appropriate to the rel value\n this.zIndex = Array.from(\n this.parentExtent.querySelectorAll(\n 'map-link[rel=image],map-link[rel=tile],map-link[rel=features]'\n )\n ).indexOf(this);\n if (\n (this.rel === 'tile' && this.type === 'application/pmtiles') ||\n this.type === 'application/vnd.mapbox-vector-tile'\n ) {\n let relativeSelector =\n 'map-link[rel=\"stylesheet\"][type=\"application/pmtiles+stylesheet\"]';\n let rules = M.getClosest(\n this,\n 'map-extent:has(' +\n relativeSelector +\n '),layer-:has(' +\n relativeSelector +\n '),mapml-viewer:has(' +\n relativeSelector +\n ')'\n )?.querySelector(relativeSelector)._pmtilesRules;\n let options = {\n zoomBounds: this.getZoomBounds(),\n extentBounds: this.getBounds(),\n crs: M[this.parentExtent.units],\n zIndex: this.zIndex,\n pane: this.parentExtent._extentLayer.getContainer(),\n linkEl: this,\n pmtilesRules: rules\n };\n this._templatedLayer = M.templatedPMTilesLayer(\n this._templateVars,\n options\n ).addTo(this.parentExtent._extentLayer);\n } else if (this.rel === 'tile') {\n this._templatedLayer = M.templatedTileLayer(this._templateVars, {\n zoomBounds: this.getZoomBounds(),\n extentBounds: this.getBounds(),\n crs: M[this.parentExtent.units],\n errorTileUrl:\n 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==',\n zIndex: this.zIndex,\n pane: this.parentExtent._extentLayer.getContainer(),\n linkEl: this\n }).addTo(this.parentExtent._extentLayer);\n } else if (this.rel === 'image') {\n this._templatedLayer = M.templatedImageLayer(this._templateVars, {\n zoomBounds: this.getZoomBounds(),\n extentBounds: this.getBounds(),\n zIndex: this.zIndex,\n pane: this.parentExtent._extentLayer.getContainer(),\n linkEl: this\n }).addTo(this.parentExtent._extentLayer);\n } else if (this.rel === 'features') {\n // map-feature retrieved by link will be stored in shadowRoot owned by link\n this.attachShadow({ mode: 'open' });\n this._templatedLayer = M.templatedFeaturesLayer(this._templateVars, {\n zoomBounds: this.getZoomBounds(),\n extentBounds: this.getBounds(),\n zIndex: this.zIndex,\n pane: this.parentExtent._extentLayer.getContainer(),\n linkEl: this\n }).addTo(this.parentExtent._extentLayer);\n } else if (this.rel === 'query') {\n this.attachShadow({ mode: 'open' });\n L.extend(this._templateVars, this._setupQueryVars(this._templateVars));\n L.extend(this._templateVars, { extentBounds: this.getBounds() });\n }\n }\n _setupQueryVars(template) {\n // process the inputs associated to template and create an object named\n // query with member properties as follows:\n // {width: 'widthvarname',\n // height: 'heightvarname',\n // left: 'leftvarname',\n // right: 'rightvarname',\n // top: 'topvarname',\n // bottom: 'bottomvarname'\n // i: 'ivarname'\n // j: 'jvarname'}\n // x: 'xvarname' x being the tcrs x axis\n // y: 'yvarname' y being the tcrs y axis\n // z: 'zvarname' zoom\n // title: link title\n\n var queryVarNames = { query: {} },\n inputs = template.values;\n\n for (var i = 0; i < template.values.length; i++) {\n var type = inputs[i].getAttribute('type'),\n units = inputs[i].getAttribute('units'),\n axis = inputs[i].getAttribute('axis'),\n name = inputs[i].getAttribute('name'),\n position = inputs[i].getAttribute('position'),\n rel = inputs[i].getAttribute('rel'),\n select = inputs[i].tagName.toLowerCase() === 'map-select';\n if (type === 'width') {\n queryVarNames.query.width = name;\n } else if (type === 'height') {\n queryVarNames.query.height = name;\n } else if (type === 'location') {\n switch (axis) {\n case 'x':\n case 'y':\n case 'column':\n case 'row':\n queryVarNames.query[axis] = name;\n break;\n case 'longitude':\n case 'easting':\n if (position) {\n if (position.match(/.*?-left/i)) {\n if (rel === 'pixel') {\n queryVarNames.query.pixelleft = name;\n } else if (rel === 'tile') {\n queryVarNames.query.tileleft = name;\n } else {\n queryVarNames.query.mapleft = name;\n }\n } else if (position.match(/.*?-right/i)) {\n if (rel === 'pixel') {\n queryVarNames.query.pixelright = name;\n } else if (rel === 'tile') {\n queryVarNames.query.tileright = name;\n } else {\n queryVarNames.query.mapright = name;\n }\n }\n } else {\n queryVarNames.query[axis] = name;\n }\n break;\n case 'latitude':\n case 'northing':\n if (position) {\n if (position.match(/top-.*?/i)) {\n if (rel === 'pixel') {\n queryVarNames.query.pixeltop = name;\n } else if (rel === 'tile') {\n queryVarNames.query.tiletop = name;\n } else {\n queryVarNames.query.maptop = name;\n }\n } else if (position.match(/bottom-.*?/i)) {\n if (rel === 'pixel') {\n queryVarNames.query.pixelbottom = name;\n } else if (rel === 'tile') {\n queryVarNames.query.tilebottom = name;\n } else {\n queryVarNames.query.mapbottom = name;\n }\n }\n } else {\n queryVarNames.query[axis] = name;\n }\n break;\n case 'i':\n if (units === 'tile') {\n queryVarNames.query.tilei = name;\n } else {\n queryVarNames.query.mapi = name;\n }\n break;\n case 'j':\n if (units === 'tile') {\n queryVarNames.query.tilej = name;\n } else {\n queryVarNames.query.mapj = name;\n }\n break;\n default:\n // unsuportted axis value\n }\n } else if (type === 'zoom') {\n //\n queryVarNames.query.zoom = name;\n } else if (select) {\n /*jshint -W104 */\n const parsedselect = inputs[i].htmlselect;\n queryVarNames.query[name] = function () {\n return parsedselect.value;\n };\n } else {\n /*jshint -W104 */\n const input = inputs[i];\n queryVarNames.query[name] = function () {\n return input.getAttribute('value');\n };\n }\n }\n return queryVarNames;\n }\n _initTemplateVars() {\n // set up the URL template and associated inputs (which yield variable values when processed)\n var varNamesRe = new RegExp('(?:{)(.*?)(?:})', 'g'),\n zoomInput = this.parentElement.querySelector('map-input[type=\"zoom\" i]'),\n includesZoom = false,\n linkedZoomInput;\n\n var template = this.tref;\n if (template === M.BLANK_TT_TREF) {\n for (let i of this.parentElement.querySelectorAll('map-input')) {\n template += `{${i.getAttribute('name')}}`;\n }\n }\n this.zoomInput = zoomInput;\n\n var v,\n vcount = template.match(varNamesRe) || [],\n inputs = [],\n inputsReady = [];\n while ((v = varNamesRe.exec(template)) !== null) {\n let varName = v[1],\n inp = this.parentElement.querySelector(\n 'map-input[name=' + varName + '],map-select[name=' + varName + ']'\n );\n if (inp) {\n // this \"associates\" the input to this map-link\n inputs.push(inp);\n inputsReady.push(inp.whenReady());\n\n // I think this means that regardless of whether the tref includes\n // a reference to the zoom input, it gets associated to the link\n // and used (to specify the native zoom bounds??) for the templated(Tile|Image|Features)Layer\n if (\n inp.hasAttribute('type') &&\n inp.getAttribute('type').toLowerCase() === 'zoom'\n ) {\n linkedZoomInput = inp;\n includesZoom = true;\n }\n // moved a block to map-select to transcribe the map-select into an\n // actual html select for inclusion in the layer control.\n\n // TODO: if this is an input@type=location\n // get the TCRS min,max attribute values at the identified zoom level\n // save this information as properties of the mapExtent,\n // perhaps as a bounds object so that it can be easily used\n // later by the layer control to determine when to enable\n // disable the layer for drawing.\n } else {\n console.log(\n 'input with name=' +\n varName +\n ' not found for template variable of same name'\n );\n }\n }\n if (template && vcount.length === inputs.length) {\n if (!includesZoom && zoomInput) {\n inputs.push(zoomInput);\n linkedZoomInput = zoomInput;\n }\n let step = zoomInput ? zoomInput.getAttribute('step') : 1;\n if (!step || step === '0' || isNaN(step)) step = 1;\n // template has a matching input for every variable reference {varref}\n this._templateVars = {\n template: decodeURI(new URL(template, this.getBase())),\n linkEl: this,\n rel: this.rel,\n type: this.type,\n values: inputs,\n inputsReady: Promise.allSettled(inputsReady),\n zoom: linkedZoomInput,\n projection: this.parentElement.units,\n tms: this.tms,\n step: step\n };\n }\n }\n getZoomBounds() {\n return this._getZoomBounds(this._templateVars.zoom);\n }\n /**\n * TODO: review getBounds for sanity, also getFallbackBounds, perhaps integrate\n * there is no other kind of bounds but native....\n * each rectangle must be established and valid and converted to PCRS coordinates...\n // \"native\" bounds = input type=location min max || map-extent/map-meta name=extent min,max || layer-/map-meta name=extent min,max || layer projection min/max\n */\n getBounds() {\n let template = this._templateVars;\n let inputs = template.values,\n projection = this.parentElement.units,\n boundsUnit = {};\n boundsUnit.name = M.FALLBACK_CS;\n let bounds = M[projection].options.crs.tilematrix.bounds(0),\n locInputs = false,\n numberOfAxes = 0,\n horizontalAxis = false,\n verticalAxis = false;\n for (let i = 0; i < inputs.length; i++) {\n if (inputs[i].getAttribute('type') === 'location') {\n if (!inputs[i].getAttribute('max') || !inputs[i].getAttribute('min'))\n continue;\n let max = +inputs[i].getAttribute('max'),\n min = +inputs[i].getAttribute('min');\n switch (inputs[i].getAttribute('axis').toLowerCase()) {\n case 'x':\n case 'longitude':\n case 'column':\n case 'easting':\n boundsUnit.name = M.axisToCS(\n inputs[i].getAttribute('axis').toLowerCase()\n );\n bounds.min.x = min;\n bounds.max.x = max;\n boundsUnit.horizontalAxis = inputs[i]\n .getAttribute('axis')\n .toLowerCase();\n break;\n case 'y':\n case 'latitude':\n case 'row':\n case 'northing':\n boundsUnit.name = M.axisToCS(\n inputs[i].getAttribute('axis').toLowerCase()\n );\n bounds.min.y = min;\n bounds.max.y = max;\n boundsUnit.verticalAxis = inputs[i]\n .getAttribute('axis')\n .toLowerCase();\n break;\n default:\n break;\n }\n }\n }\n if (\n boundsUnit.horizontalAxis &&\n boundsUnit.verticalAxis &&\n ((boundsUnit.horizontalAxis === 'x' && boundsUnit.verticalAxis === 'y') ||\n (boundsUnit.horizontalAxis === 'longitude' &&\n boundsUnit.verticalAxis === 'latitude') ||\n (boundsUnit.horizontalAxis === 'column' &&\n boundsUnit.verticalAxis === 'row') ||\n (boundsUnit.horizontalAxis === 'easting' &&\n boundsUnit.verticalAxis === 'northing'))\n ) {\n locInputs = true;\n }\n if (locInputs) {\n let zoomValue = this._templateVars.zoom?.hasAttribute('value')\n ? +this._templateVars.zoom.getAttribute('value')\n : 0;\n bounds = M.boundsToPCRSBounds(\n bounds,\n zoomValue,\n projection,\n boundsUnit.name\n );\n } else if (!locInputs) {\n bounds = this.getFallbackBounds(projection);\n }\n return bounds;\n }\n getFallbackBounds(projection) {\n let bounds;\n\n let zoom = 0;\n let metaExtent = this.parentElement.getMeta('extent');\n if (metaExtent) {\n let content = M._metaContentToObject(metaExtent.getAttribute('content')),\n cs;\n\n zoom = content.zoom || zoom;\n\n let metaKeys = Object.keys(content);\n for (let i = 0; i < metaKeys.length; i++) {\n if (!metaKeys[i].includes('zoom')) {\n cs = M.axisToCS(metaKeys[i].split('-')[2]);\n break;\n }\n }\n let axes = M.csToAxes(cs);\n bounds = M.boundsToPCRSBounds(\n L.bounds(\n L.point(\n +content[`top-left-${axes[0]}`],\n +content[`top-left-${axes[1]}`]\n ),\n L.point(\n +content[`bottom-right-${axes[0]}`],\n +content[`bottom-right-${axes[1]}`]\n )\n ),\n zoom,\n projection,\n cs\n );\n } else {\n let crs = M[projection];\n bounds = crs.options.crs.pcrs.bounds;\n }\n return bounds;\n }\n getBase() {\n let layer = this.getRootNode().host;\n //\n let relativeURL =\n this.getRootNode().querySelector('map-base') &&\n this.getRootNode() instanceof ShadowRoot\n ? this.getRootNode().querySelector('map-base').getAttribute('href')\n : /* local content? */ !(this.getRootNode() instanceof ShadowRoot)\n ? /* use the baseURI algorithm which takes into account any */\n this.getRootNode().querySelector('map-base')?.getAttribute('href') ||\n this.baseURI\n : /* else use the resolved value */ new URL(\n layer.src,\n layer.baseURI\n ).href;\n\n // when remote content, use layer.src as base else use baseURI of map-link\n let baseURL =\n this.getRootNode() instanceof ShadowRoot\n ? new URL(layer.src, layer.baseURI).href\n : this.baseURI;\n return new URL(relativeURL, baseURL).href;\n }\n /**\n * Return BOTH min/max(Display)Zoom AND min/maxNativeZoom which\n * are options that can be passed to L.GridLayer...\n * https://leafletjs.com/reference.html#gridlayer-minzoom\n *\n * @param {Object} zoomInput - is an element reference to a map-input[type=zoom]\n * @returns {Object} - returns {minZoom: n,maxZoom: n,minNativeZoom: n,maxNativeZoom: n}\n */\n _getZoomBounds(zoomInput) {\n // native variables should ONLY come from map-input min/max attributes\n // BUT they should fall back to map-meta or projection values for min/max (display) zoom\n // display zoom variables should be EQUAL to native unless specified differently\n // via map-meta name=zoom\n // in particular minNativeZoom being > minZoom can be problematic because\n // you fetch tiles at larger scales (i.e. many many small tiles) and render\n // them at smaller scale (i.e. little postage stamps), which can freez your\n // browser and bury a tile cache in requests, getting you banned/blocked\n //\n // minZoom = map-meta name=zoom min || input type=zoom min || projection minZoom\n // minNativeZoom = input type=zoom min || minZoom\n // maxZoom = map-meta name=zoom max || input type=zoom max || projection maxZoom\n // maxNativeZoom = input type=zoom max || maxZoom\n\n let zoomBounds = {};\n // search document from here up, using closest source of zoom bounds info\n let meta = this.parentElement.getMeta('zoom');\n let metaMin = meta\n ? +M._metaContentToObject(meta.getAttribute('content'))?.min\n : null;\n zoomBounds.minZoom =\n metaMin || (zoomInput ? +zoomInput.getAttribute('min') : 0);\n zoomBounds.minNativeZoom = zoomInput\n ? +zoomInput.getAttribute('min')\n : zoomBounds.minZoom;\n let metaMax = meta\n ? +M._metaContentToObject(meta.getAttribute('content'))?.max\n : null;\n zoomBounds.maxZoom =\n metaMax ||\n (zoomInput\n ? +zoomInput.getAttribute('max')\n : M[this.parentElement.units].options.resolutions.length - 1);\n zoomBounds.maxNativeZoom = zoomInput\n ? +zoomInput.getAttribute('max')\n : zoomBounds.maxZoom;\n\n return zoomBounds;\n }\n _validateDisabled() {\n let isVisible = false,\n map = this.getMapEl(),\n mapZoom = map.zoom,\n extent = map.extent,\n xmin = extent.topLeft.pcrs.horizontal,\n xmax = extent.bottomRight.pcrs.horizontal,\n ymin = extent.bottomRight.pcrs.vertical,\n ymax = extent.topLeft.pcrs.vertical,\n mapBounds = L.bounds(L.point(xmin, ymin), L.point(xmax, ymax));\n\n if (this._templatedLayer) {\n isVisible = this._templatedLayer.isVisible();\n } else if (this.rel === 'query') {\n const minZoom = this.extent.zoom.minZoom,\n maxZoom = this.extent.zoom.maxZoom,\n withinZoomBounds = (z) => {\n return minZoom <= z && z <= maxZoom;\n };\n\n if (this.getBounds().overlaps(mapBounds) && withinZoomBounds(mapZoom)) {\n isVisible = true;\n }\n }\n return isVisible;\n }\n _createSelfOrStyleLink() {\n let layerEl = this.getLayerEl();\n const changeStyle = function (e) {\n L.DomEvent.stop(e);\n layerEl.dispatchEvent(\n new CustomEvent('changestyle', {\n detail: {\n src: e.target.getAttribute('data-href'),\n preference: this.media['prefers-map-content']\n }\n })\n );\n };\n\n let styleOption = document.createElement('div'),\n styleOptionInput = styleOption.appendChild(\n document.createElement('input')\n );\n styleOptionInput.setAttribute('type', 'radio');\n styleOptionInput.setAttribute('id', 'rad-' + L.stamp(styleOptionInput));\n styleOptionInput.setAttribute(\n 'name',\n // grouping radio buttons based on parent layer's style \n 'styles-' + L.stamp(styleOption)\n );\n styleOptionInput.setAttribute('value', this.getAttribute('title'));\n styleOptionInput.setAttribute(\n 'data-href',\n new URL(this.href, this.getBase()).href\n );\n var styleOptionLabel = styleOption.appendChild(\n document.createElement('label')\n );\n styleOptionLabel.setAttribute('for', 'rad-' + L.stamp(styleOptionInput));\n styleOptionLabel.innerText = this.title;\n if (this.rel === 'style self' || this.rel === 'self style') {\n styleOptionInput.checked = true;\n }\n this._styleOption = styleOption;\n styleOptionInput.addEventListener('click', changeStyle.bind(this));\n }\n getLayerControlOption() {\n return this._styleOption;\n }\n\n // Resolve the templated URL with info from the sibling map-input's\n resolve() {\n if (this.tref) {\n let obj = {};\n const inputs = this.parentElement.querySelectorAll('map-input');\n if (this.rel === 'image') {\n // image/map\n for (let i = 0; i < inputs.length; i++) {\n const inp = inputs[i];\n obj[inp.name] = inp.value;\n }\n console.log(obj); // DEBUGGING\n return L.Util.template(this.tref, obj);\n } else if (this.rel === 'tile') {\n // TODO. Need to get tile coords from moveend\n // should be done/called from the TemplatedTilelayer.js file\n return obj;\n } else if (this.rel === 'query') {\n // TODO. Need to get the click coords from click event\n // should be done/called from the templatedlayer.js file\n } else if (this.rel === 'features') {\n // TODO.\n }\n }\n }\n whenReady() {\n return new Promise((resolve, reject) => {\n let interval, failureTimer, ready;\n switch (this.rel.toLowerCase()) {\n // for some cases, require a dependency check\n case 'tile':\n case 'image':\n case 'features':\n ready = '_templatedLayer';\n break;\n case 'style':\n case 'self':\n case 'style self':\n case 'self style':\n ready = '_styleOption';\n break;\n case 'query':\n ready = 'shadowRoot';\n break;\n case 'alternate':\n ready = '_alternate';\n break;\n case 'stylesheet':\n if (this.type === 'application/pmtiles+stylesheet') {\n ready = _pmtilesRules;\n } else {\n resolve();\n }\n break;\n case 'zoomin':\n case 'zoomout':\n case 'legend':\n case 'license':\n resolve();\n break;\n default:\n resolve();\n break;\n }\n if (this[ready]) {\n resolve();\n }\n interval = setInterval(testForLinkReady, 300, this);\n failureTimer = setTimeout(linkNotDefined, 10000);\n function testForLinkReady(linkElement) {\n if (linkElement[ready]) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n resolve();\n } else if (!linkElement.isConnected) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('map-link was disconnected while waiting to be ready');\n }\n }\n function linkNotDefined() {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Timeout reached waiting for link to be ready');\n }\n });\n }\n}\n"],"names":["MapLink","HTMLElement","observedAttributes","#hasConnected","type","this","getAttribute","val","startsWith","setAttribute","rel","includes","href","hasAttribute","URL","getBase","resolve","hreflang","tref","M","BLANK_TT_TREF","media","_metaContentToObject","tms","projection","extent","_templateVars","Object","assign","_convertAndFormatPCRS","getBounds","parentExtent","units","zoom","getZoomBounds","zoomTo","let","map","getMapEl","_map","xmin","topLeft","pcrs","horizontal","xmax","bottomRight","ymin","vertical","ymax","bounds","L","point","center","options","crs","unproject","getCenter","maxZoom","minZoom","setView","getMaxZoom","animate","getClosest","getLayerEl","attributeChangedCallback","name","oldValue","newValue","_initTemplateVars","constructor","super","connectedCallback","toLowerCase","_createTemplatedLink","_createSelfOrStyleLink","pmtilesStyles","import","then","_pmtilesRules","module","pmtilesRules","catch","console","error","reason","_createStylesheetLink","_createAlternateLink","disconnectedCallback","_stylesheetHost","link","remove","mapml","_alternate","source","target","getRootNode","ShadowRoot","host","parentElement","undefined","document","createElement","mapLink","Array","from","attributes","forEach","attribute","nodeName","nodeValue","_layer","appendStyleLink","_templatedLayer","_extentLayer","parentNode","toUpperCase","whenReady","inputsReady","log","mapEl","zIndex","querySelectorAll","indexOf","relativeSelector","rules","querySelector","zoomBounds","extentBounds","pane","getContainer","linkEl","templatedPMTilesLayer","addTo","templatedTileLayer","errorTileUrl","templatedImageLayer","attachShadow","mode","templatedFeaturesLayer","extend","_setupQueryVars","template","queryVarNames","query","inputs","values","i","length","axis","position","select","tagName","width","height","match","pixelleft","tileleft","mapleft","pixelright","tileright","mapright","pixeltop","tiletop","maptop","pixelbottom","tilebottom","mapbottom","tilei","mapi","tilej","mapj","parsedselect","htmlselect","value","input","linkedZoomInput","varNamesRe","RegExp","zoomInput","includesZoom","v","vcount","exec","varName","inp","push","step","isNaN","decodeURI","Promise","allSettled","_getZoomBounds","zoomValue","boundsUnit","FALLBACK_CS","tilematrix","locInputs","max","min","axisToCS","x","horizontalAxis","y","verticalAxis","boundsToPCRSBounds","getFallbackBounds","metaExtent","getMeta","content","cs","metaKeys","keys","split","axes","csToAxes","layer","relativeURL","src","baseURI","baseURL","meta","metaMin","minNativeZoom","metaMax","resolutions","maxNativeZoom","_validateDisabled","isVisible","mapZoom","mapBounds","overlaps","z","layerEl","styleOption","styleOptionInput","appendChild","stamp","styleOptionLabel","innerText","title","checked","_styleOption","addEventListener","e","DomEvent","stop","dispatchEvent","CustomEvent","detail","preference","bind","getLayerControlOption","obj","Util","reject","interval","failureTimer","ready","setInterval","linkElement","clearInterval","clearTimeout","isConnected","setTimeout"],"mappings":";;MAEaA,gBAAgBC,YAC3BC,gCACE,MAAO,CACL,OACA,MAEA,QACA,OACA,WACA,OACA,MACA,cAIJC,cAEAC,WACE,OAAOC,KAAKC,aAAa,SAAW,UAEtCF,SAASG,GAGG,eAARA,IACAA,EAAIC,WAAW,WAEfH,KAAKI,aAAa,OAAQF,GAG9BG,UAGE,OAAOL,KAAKC,aAAa,OAE3BI,QAAQH,GAGJ,CACE,UACA,YACA,OACA,QACA,OACA,QACA,WACA,SACA,UACA,SACA,QACA,cACAI,SAASJ,IAEXF,KAAKI,aAAa,OAAQF,GAW9BK,WACE,OAAIP,KAAKQ,aAAa,QACb,IAAIC,IAAIT,KAAKC,aAAa,QAASD,KAAKU,WAAWH,KACjDP,KAAKQ,aAAa,QACpBR,KAAKW,eADP,EAITJ,SAASL,GAEHA,GACFF,KAAKI,aAAa,OAAQF,GAG9BU,eACE,OAAOZ,KAAKC,aAAa,YAE3BW,aAAaV,GAEPA,GACFF,KAAKI,aAAa,WAAYF,GAGlCW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,WAAYpP,KAAKgB,MAAM,4BA+BwBqO,KAAKrP,OAE9DsP,wBACE,OAAOtP,KAAK4O,aAIdjO,UACE,GAAIX,KAAKa,KAAM,CACbkB,IAAIwN,EAAM,GACV,IAAM5G,EAAS3I,KAAK6F,cAAcuB,iBAAiB,aACnD,GAAiB,UAAbpH,KAAKK,IAAiB,CAExB,IAAK0B,IAAI8G,EAAI,EAAGA,EAAIF,EAAOG,OAAQD,IAAK,CACtC,IAAMsC,EAAMxC,EAAOE,GACnB0G,EAAIpE,EAAIvH,MAAQuH,EAAIX,MAGtB,OADA3F,QAAQoC,IAAIsI,GACL1M,EAAE2M,KAAKhH,SAASxI,KAAKa,KAAM0O,GAC7B,GAAiB,SAAbvP,KAAKK,IAGd,OAAOkP,EACe,UAAbvP,KAAKK,KAGLL,KAAKK,KAKpB0G,YACE,OAAO,IAAIyE,QAAQ,CAAC7K,EAAS8O,KAC3B1N,IAAI2N,EAAUC,EAAcC,EAC5B,OAAQ5P,KAAKK,IAAI8D,eAEf,IAAK,OACL,IAAK,QACL,IAAK,WACHyL,EAAQ,kBACR,MACF,IAAK,QACL,IAAK,OACL,IAAK,aACL,IAAK,aACHA,EAAQ,eACR,MACF,IAAK,QACHA,EAAQ,aACR,MACF,IAAK,YACHA,EAAQ,aACR,MACF,IAAK,aACe,mCAAd5P,KAAKD,KACP6P,EAAQnL,cAER9D,IAEF,MAOF,QACEA,IAGAX,KAAK4P,IACPjP,IAEF+O,EAAWG,YAEX,SAA0BC,GACpBA,EAAYF,IACdG,cAAcL,GACdM,aAAaL,GACbhP,KACUmP,EAAYG,cACtBF,cAAcL,GACdM,aAAaL,GACbF,EAAO,yDAV8B,IAAKzP,MAC9C2P,EAAeO,WAYf,WACEH,cAAcL,GACdM,aAAaL,GACbF,EAAO,iDAfiC,eAv8BnC9P"} \ No newline at end of file diff --git a/src/dist/map-select.js b/src/dist/map-select.js index dbedc78..a858d8e 100644 --- a/src/dist/map-select.js +++ b/src/dist/map-select.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 22-08-2024 */ +/*! @maps4html/mapml 28-08-2024 */ class MapSelect extends HTMLElement{static get observedAttributes(){return["name","id"]}get name(){return this.getAttribute("name")}set name(e){this.setAttribute("name",e)}get id(){return this.getAttribute("id")}set id(e){this.setAttribute("id",e)}attributeChangedCallback(e,t,r){e}constructor(){super()}connectedCallback(){this._extentEl=this.parentElement,this._createLayerControlForSelect()}disconnectedCallback(){}_createLayerControlForSelect(){this.htmlselect=this.transcribe();var e=L.DomUtil.create("details","mapml-layer-item-details mapml-control-layers"),t=L.DomUtil.create("summary"),r=L.DomUtil.create("label");r.innerText=this.getAttribute("name"),r.setAttribute("for",this.getAttribute("id")),t.appendChild(r),e.appendChild(t),e.appendChild(this.htmlselect),this.selectdetails=e;e=function(){this.parentElement._extentLayer.redraw()}.bind(this);this.htmlselect.addEventListener("change",e)}transcribe(){var r=document.createElement("select"),t=this.getAttributeNames();for(let e=0;e{let i,a;this.selectdetails?t():(i=setInterval(function(e){e.selectdetails?(clearInterval(i),clearTimeout(a),t()):e.isConnected||(clearInterval(i),clearTimeout(a),r("map-select was disconnected while waiting to be ready"))},300,this),a=setTimeout(function(){clearInterval(i),clearTimeout(a),r("Timeout reached waiting for map-select to be ready")},1e4))})}}export{MapSelect}; //# sourceMappingURL=map-select.js.map \ No newline at end of file diff --git a/src/dist/map-style.js b/src/dist/map-style.js index 33e8224..9d9b061 100644 --- a/src/dist/map-style.js +++ b/src/dist/map-style.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 22-08-2024 */ +/*! @maps4html/mapml 28-08-2024 */ class MapStyle extends HTMLElement{static get observedAttributes(){}attributeChangedCallback(t,e,s){}constructor(){super()}connectedCallback(){var t,e;this._stylesheetHost=this.getRootNode()instanceof ShadowRoot?this.getRootNode().host:this.parentElement,void 0!==this._stylesheetHost&&(this.styleElement=document.createElement("style"),(this.styleElement.mapStyle=this).styleElement.textContent=this.textContent,e=(t=this).styleElement,Array.from(t.attributes).forEach(t=>{e.setAttribute(t.nodeName,t.nodeValue)}),this._stylesheetHost._layer?this._stylesheetHost._layer.appendStyleElement(this):this._stylesheetHost._templatedLayer?this._stylesheetHost._templatedLayer.appendStyleElement(this):this._stylesheetHost._extentLayer&&this._stylesheetHost._extentLayer.appendStyleElement(this),this._observer=new MutationObserver(()=>{this.styleElement.textContent=this.textContent}),this._observer.observe(this,{childList:!0,subtree:!0,characterData:!0}))}disconnectedCallback(){this._stylesheetHost&&this.styleElement.remove()}}export{MapStyle}; //# sourceMappingURL=map-style.js.map \ No newline at end of file diff --git a/src/dist/mapml-viewer.js b/src/dist/mapml-viewer.js index bcbd38b..e4f4162 100644 --- a/src/dist/mapml-viewer.js +++ b/src/dist/mapml-viewer.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 22-08-2024 */ +/*! @maps4html/mapml 28-08-2024 */ import"./leaflet.js";import"./mapml.js";import{MapLayer}from"./layer.js";import{MapCaption}from"./map-caption.js";import{MapFeature}from"./map-feature.js";import{MapExtent}from"./map-extent.js";import{MapInput}from"./map-input.js";import{MapSelect}from"./map-select.js";import{MapLink}from"./map-link.js";import{MapStyle}from"./map-style.js";class MapViewer extends HTMLElement{static get observedAttributes(){return["lat","lon","zoom","projection","width","height","controls","static","controlslist"]}get controls(){return this.hasAttribute("controls")}set controls(t){Boolean(t)?this.setAttribute("controls",""):this.removeAttribute("controls")}get controlsList(){return this._controlsList}set controlsList(t){this._controlsList.value=t,this.setAttribute("controlslist",t)}get width(){return+window.getComputedStyle(this).width.replace("px","")}set width(t){this.setAttribute("width",t)}get height(){return+window.getComputedStyle(this).height.replace("px","")}set height(t){this.setAttribute("height",t)}get lat(){return+(this.hasAttribute("lat")?this.getAttribute("lat"):0)}set lat(t){t&&this.setAttribute("lat",t)}get lon(){return+(this.hasAttribute("lon")?this.getAttribute("lon"):0)}set lon(t){t&&this.setAttribute("lon",t)}get projection(){return this.hasAttribute("projection")?this.getAttribute("projection"):"OSMTILE"}set projection(t){t&&this.whenProjectionDefined(t).then(()=>{this.setAttribute("projection",t)}).catch(()=>{throw new Error("Undefined projection:"+t)})}get zoom(){return+(this.hasAttribute("zoom")?this.getAttribute("zoom"):0)}set zoom(t){t=parseInt(t,10);!isNaN(t)&&0<=t&&t<=25&&this.setAttribute("zoom",t)}get layers(){return this.getElementsByTagName("layer-")}get extent(){let t=this._map,e=M.pixelToPCRSBounds(t.getPixelBounds(),t.getZoom(),t.options.projection),o=M._convertAndFormatPCRS(e,t.options.crs,this.projection),i=1/0,n=-1/0;for(let t=0;tn&&(n=this.layers[t].extent.zoom.maxZoom));return o.zoom={minZoom:i!==1/0?i:t.getMinZoom(),maxZoom:n!==-1/0?n:t.getMaxZoom()},o}get static(){return this.hasAttribute("static")}set static(t){Boolean(t)?this.setAttribute("static",""):this.removeAttribute("static")}constructor(){super(),this._source=this.outerHTML,this._history=[],this._historyIndex=-1,this._traversalCall=!1}connectedCallback(){this.whenProjectionDefined(this.projection).then(()=>{this._initShadowRoot(),this._controlsList=new M.DOMTokenList(this.getAttribute("controlslist"),this,"controlslist",["noreload","nofullscreen","nozoom","nolayer","noscale","geolocation"]);var t=window.getComputedStyle(this),e=t.width,t=t.height,e=this.hasAttribute("width")?this.getAttribute("width"):parseInt(e.replace("px","")),t=this.hasAttribute("height")?this.getAttribute("height"):parseInt(t.replace("px",""));this._changeWidth(e),this._changeHeight(t),this._createMap(),this.setAttribute("role","application"),this._toggleStatic();let o=this.querySelector("map-caption");null!==o&&setTimeout(()=>{this.getAttribute("aria-label")===o.innerHTML&&(this.mapCaptionObserver=new MutationObserver(t=>{this.querySelector("map-caption")!==o&&this.removeAttribute("aria-label")}),this.mapCaptionObserver.observe(this,{childList:!0}))},0)}).catch(()=>{throw new Error("Projection not defined")})}_initShadowRoot(){this.shadowRoot||this.attachShadow({mode:"open"});let t=document.createElement("template");t.innerHTML=``;let e=this.shadowRoot;this._container=document.createElement("div");this._container.insertAdjacentHTML("beforeend","");let o=document.createElement("style");o.innerHTML=':host {all: initial;contain: layout size;display: inline-block;height: 150px;width: 300px;border-width: 2px;border-style: inset;}:host([frameborder="0"]) {border-width: 0;}:host([hidden]) {display: none!important;}:host .leaflet-control-container {visibility: hidden!important;}';let i=document.createElement("style");i.innerHTML="mapml-viewer > * {display: none!important;}",this.appendChild(i),this._container.setAttribute("role","region"),this._container.setAttribute("aria-label","Interactive map"),e.appendChild(o),e.appendChild(t.content.cloneNode(!0)),e.appendChild(this._container)}_createMap(){this._map||(this._map=L.map(this._container,{center:new L.LatLng(this.lat,this.lon),minZoom:0,maxZoom:M[this.projection].options.resolutions.length-1,projection:this.projection,query:!0,contextMenu:!0,announceMovement:M.options.announceMovement,featureIndex:!0,mapEl:this,crs:M[this.projection],zoom:this.zoom,zoomControl:!1}),this._addToHistory(),this._createControls(),this._toggleControls(),this._crosshair=M.crosshair().addTo(this._map),M.options.featureIndexOverlayOption&&(this._featureIndexOverlay=M.featureIndexOverlay().addTo(this._map)),this._setUpEvents())}disconnectedCallback(){for(this._removeEvents();this.shadowRoot.firstChild;)this.shadowRoot.removeChild(this.shadowRoot.firstChild);delete this._map,this._deleteControls()}adoptedCallback(){}attributeChangedCallback(t,e,s){switch(t){case"controlslist":this._controlsList&&(!1===this._controlsList.valueSet&&(this._controlsList.value=s),this._toggleControls());break;case"controls":null!==e&&null===s?this._hideControls():null===e&&null!==s&&this._showControls();break;case"height":e!==s&&this._changeHeight(s);break;case"width":e!==s&&this._changeWidth(s);break;case"static":this._toggleStatic();break;case"projection":if(s&&this._map&&this._map.options.projection!==s){const o=(()=>{let t=this.lat,e=this.lon,o=this.zoom;this._map.options.crs=M[s],this._map.options.projection=s;let i=[];this._map.announceMovement.disable();for(var n of this.querySelectorAll("layer-")){n.removeAttribute("disabled");let t=this.removeChild(n);this.appendChild(t),i.push(t.whenReady())}return Promise.allSettled(i).then(()=>{this.zoomTo(t,e,o),M.options.announceMovement&&this._map.announceMovement.enable(),setTimeout(()=>{this.dispatchEvent(new CustomEvent("map-projectionchange"))},0)})}).bind(this);o().then(()=>{if(this._map&&this._map.options.projection!==e&&this._resetHistory(),this._debug)for(let t=0;t<2;t++)this.toggleDebug()})}}}_createControls(){let t=this._map.getSize().y,e=0;this._layerControl=M.layerControl(null,{collapsed:!0,mapEl:this}).addTo(this._map),this._map.on("movestart",this._layerControl.collapse,this._layerControl);let o=M.options.announceScale;"metric"===o&&(o={metric:!0,imperial:!1}),"imperial"===o&&(o={metric:!1,imperial:!0}),this._scaleBar||(this._scaleBar=M.scaleBar(o).addTo(this._map)),!this._zoomControl&&e+93<=t&&(e+=93,this._zoomControl=L.control.zoom().addTo(this._map)),!this._reloadButton&&e+49<=t&&(e+=49,this._reloadButton=M.reloadButton().addTo(this._map)),!this._fullScreenControl&&e+49<=t&&(e+=49,this._fullScreenControl=M.fullscreenButton().addTo(this._map)),this._geolocationButton||(this._geolocationButton=M.geolocationButton().addTo(this._map))}_toggleControls(){!1===this.controls?(this._hideControls(),this._map.contextMenu.toggleContextMenuItem("Controls","disabled")):(this._showControls(),this._map.contextMenu.toggleContextMenuItem("Controls","enabled"))}_hideControls(){this._setControlsVisibility("fullscreen",!0),this._setControlsVisibility("layercontrol",!0),this._setControlsVisibility("reload",!0),this._setControlsVisibility("zoom",!0),this._setControlsVisibility("geolocation",!0),this._setControlsVisibility("scale",!0)}_showControls(){this._setControlsVisibility("fullscreen",!1),this._setControlsVisibility("layercontrol",!1),this._setControlsVisibility("reload",!1),this._setControlsVisibility("zoom",!1),this._setControlsVisibility("geolocation",!0),this._setControlsVisibility("scale",!1),this._controlsList&&this._controlsList.forEach(t=>{switch(t.toLowerCase()){case"nofullscreen":this._setControlsVisibility("fullscreen",!0);break;case"nolayer":this._setControlsVisibility("layercontrol",!0);break;case"noreload":this._setControlsVisibility("reload",!0);break;case"nozoom":this._setControlsVisibility("zoom",!0);break;case"geolocation":this._setControlsVisibility("geolocation",!1);break;case"noscale":this._setControlsVisibility("scale",!0)}}),this._layerControl&&0===this._layerControl._layers.length&&this._layerControl._container.setAttribute("hidden","")}_deleteControls(){delete this._layerControl,delete this._zoomControl,delete this._reloadButton,delete this._fullScreenControl,delete this._geolocationButton,delete this._scaleBar}_setControlsVisibility(t,e){let o;switch(t){case"zoom":this._zoomControl&&(o=this._zoomControl._container);break;case"reload":this._reloadButton&&(o=this._reloadButton._container);break;case"fullscreen":this._fullScreenControl&&(o=this._fullScreenControl._container);break;case"layercontrol":this._layerControl&&(o=this._layerControl._container);break;case"geolocation":this._geolocationButton&&(o=this._geolocationButton._container);break;case"scale":this._scaleBar&&(o=this._scaleBar._container)}o&&(e?([...o.children].forEach(t=>{t.setAttribute("hidden","")}),o.setAttribute("hidden","")):([...o.children].forEach(t=>{t.removeAttribute("hidden")}),o.removeAttribute("hidden")))}_toggleStatic(){var t=this.hasAttribute("static");this._map&&(t?(this._map.dragging.disable(),this._map.touchZoom.disable(),this._map.doubleClickZoom.disable(),this._map.scrollWheelZoom.disable(),this._map.boxZoom.disable(),this._map.keyboard.disable(),this._zoomControl.disable()):(this._map.dragging.enable(),this._map.touchZoom.enable(),this._map.doubleClickZoom.enable(),this._map.scrollWheelZoom.enable(),this._map.boxZoom.enable(),this._map.keyboard.enable(),this._zoomControl.enable()))}_dropHandler(t){t.preventDefault();t=t.dataTransfer.getData("text");M._pasteLayer(this,t)}_dragoverHandler(t){t.preventDefault(),t.dataTransfer.dropEffect="copy"}_removeEvents(){this._map&&(this._map.off(),this.removeEventListener("drop",this._dropHandler,!1),this.removeEventListener("dragover",this._dragoverHandler,!1))}_setUpEvents(){this.addEventListener("drop",this._dropHandler,!1),this.addEventListener("dragover",this._dragoverHandler,!1),this.addEventListener("change",function(t){"LAYER-"===t.target.tagName&&this.dispatchEvent(new CustomEvent("layerchange",{details:{target:this,originalEvent:t}}))},!1);let t=this.getRootNode()instanceof ShadowRoot?this.getRootNode().host:this.parentElement;t.addEventListener("keyup",function(t){9===t.keyCode&&"MAPML-VIEWER"===document.activeElement.nodeName&&document.activeElement.dispatchEvent(new CustomEvent("mapfocused",{detail:{target:this}}))}),this.addEventListener("keydown",function(t){86===t.keyCode&&t.ctrlKey?navigator.clipboard.readText().then(t=>{M._pasteLayer(this,t)}):32===t.keyCode&&"INPUT"!==this.shadowRoot.activeElement.nodeName&&(t.preventDefault(),this._map.fire("keypress",{originalEvent:t}))}),t.addEventListener("mousedown",function(t){"MAPML-VIEWER"===document.activeElement.nodeName&&document.activeElement.dispatchEvent(new CustomEvent("mapfocused",{detail:{target:this}}))}),this._map.on("locationfound",function(t){this.dispatchEvent(new CustomEvent("maplocationfound",{detail:{latlng:t.latlng,accuracy:t.accuracy}}))},this),this._map.on("locationerror",function(t){this.dispatchEvent(new CustomEvent("locationerror",{detail:{error:t.message}}))},this),this._map.on("load",function(){this.dispatchEvent(new CustomEvent("load",{detail:{target:this}}))},this),this._map.on("preclick",function(t){this.dispatchEvent(new CustomEvent("preclick",{detail:{lat:t.latlng.lat,lon:t.latlng.lng,x:t.containerPoint.x,y:t.containerPoint.y}}))},this),this._map.on("click",function(t){this.dispatchEvent(new CustomEvent("click",{detail:{lat:t.latlng.lat,lon:t.latlng.lng,x:t.containerPoint.x,y:t.containerPoint.y}}))},this),this._map.on("dblclick",function(t){this.dispatchEvent(new CustomEvent("dblclick",{detail:{lat:t.latlng.lat,lon:t.latlng.lng,x:t.containerPoint.x,y:t.containerPoint.y}}))},this),this._map.on("mousemove",function(t){this.dispatchEvent(new CustomEvent("mousemove",{detail:{lat:t.latlng.lat,lon:t.latlng.lng,x:t.containerPoint.x,y:t.containerPoint.y}}))},this),this._map.on("mouseover",function(t){this.dispatchEvent(new CustomEvent("mouseover",{detail:{lat:t.latlng.lat,lon:t.latlng.lng,x:t.containerPoint.x,y:t.containerPoint.y}}))},this),this._map.on("mouseout",function(t){this.dispatchEvent(new CustomEvent("mouseout",{detail:{lat:t.latlng.lat,lon:t.latlng.lng,x:t.containerPoint.x,y:t.containerPoint.y}}))},this),this._map.on("mousedown",function(t){this.dispatchEvent(new CustomEvent("mousedown",{detail:{lat:t.latlng.lat,lon:t.latlng.lng,x:t.containerPoint.x,y:t.containerPoint.y}}))},this),this._map.on("mouseup",function(t){this.dispatchEvent(new CustomEvent("mouseup",{detail:{lat:t.latlng.lat,lon:t.latlng.lng,x:t.containerPoint.x,y:t.containerPoint.y}}))},this),this._map.on("contextmenu",function(t){this.dispatchEvent(new CustomEvent("contextmenu",{detail:{lat:t.latlng.lat,lon:t.latlng.lng,x:t.containerPoint.x,y:t.containerPoint.y}}))},this),this._map.on("movestart",function(){this.dispatchEvent(new CustomEvent("movestart",{detail:{target:this}}))},this),this._map.on("move",function(){this.dispatchEvent(new CustomEvent("move",{detail:{target:this}}))},this),this._map.on("moveend",function(){this._updateMapCenter(),this._addToHistory(),this.dispatchEvent(new CustomEvent("map-moveend",{detail:{target:this}}))},this),this._map.on("zoomstart",function(){this.dispatchEvent(new CustomEvent("zoomstart",{detail:{target:this}}))},this),this._map.on("zoom",function(){this.dispatchEvent(new CustomEvent("zoom",{detail:{target:this}}))},this),this._map.on("zoomend",function(){this._updateMapCenter(),this.dispatchEvent(new CustomEvent("zoomend",{detail:{target:this}}))},this);const e=(t=>{this.whenLayersReady().then(()=>{t&&t.layer._layerEl&&(this._map.setMaxZoom(this.extent.zoom.maxZoom),this._map.setMinZoom(this.extent.zoom.minZoom))})}).bind(this);this.whenLayersReady().then(()=>{this._map.setMaxZoom(this.extent.zoom.maxZoom),this._map.setMinZoom(this.extent.zoom.minZoom),this._map.on("layeradd layerremove",e,this)}),this.addEventListener("fullscreenchange",function(t){null===document.fullscreenElement?this._map.contextMenu.setViewFullScreenInnerHTML("view"):this._map.contextMenu.setViewFullScreenInnerHTML("exit")}),this.addEventListener("keydown",function(t){"MAPML-VIEWER"===document.activeElement.nodeName&&(t.ctrlKey&&82===t.keyCode?(t.preventDefault(),this.reload()):t.altKey&&39===t.keyCode?(t.preventDefault(),this.forward()):t.altKey&&37===t.keyCode&&(t.preventDefault(),this.back()))})}locate(t){this._geolocationButton&&this._geolocationButton.stop(),t?(t.zoomTo&&(t.setView=t.zoomTo,delete t.zoomTo),this._map.locate(t)):this._map.locate({setView:!0,maxZoom:16})}toggleDebug(){this._debug?(this._debug.remove(),this._debug=void 0):this._debug=M.debugOverlay().addTo(this._map)}_changeWidth(t){this._container&&(this._container.style.width=t+"px",this.shadowRoot.styleSheets[0].cssRules[0].style.width=t+"px"),this._map&&this._map.invalidateSize(!1)}_changeHeight(t){this._container&&(this._container.style.height=t+"px",this.shadowRoot.styleSheets[0].cssRules[0].style.height=t+"px"),this._map&&this._map.invalidateSize(!1)}zoomTo(t,e,o){o=Number.isInteger(+o)?+o:this.zoom;e=new L.LatLng(+t,+e);this._map.setView(e,o),this.zoom=o,this.lat=e.lat,this.lon=e.lng}_updateMapCenter(){this.lat=this._map.getCenter().lat,this.lon=this._map.getCenter().lng,this.zoom=this._map.getZoom()}_resetHistory(){this._history=[],this._historyIndex=-1,this._traversalCall=!1,this._addToHistory()}_addToHistory(){var t;0Math.round(M[e.projection].options.bounds.getSize().x/M[e.projection].options.resolutions[t])},vertical:{name:"y",min:0,max:t=>Math.round(M[e.projection].options.bounds.getSize().y/M[e.projection].options.resolutions[t])},bounds:t=>L.bounds([M[e.projection].options.crs.tcrs.horizontal.min,M[e.projection].options.crs.tcrs.vertical.min],[M[e.projection].options.crs.tcrs.horizontal.max(t),M[e.projection].options.crs.tcrs.vertical.max(t)])},pcrs:{horizontal:{name:"easting",get min(){return M[e.projection].options.bounds.min.x},get max(){return M[e.projection].options.bounds.max.x}},vertical:{name:"northing",get min(){return M[e.projection].options.bounds.min.y},get max(){return M[e.projection].options.bounds.max.y}},get bounds(){return M[e.projection].options.bounds}},gcrs:{horizontal:{name:"longitude",get min(){return M[e.projection].unproject(M.OSMTILE.options.bounds.min).lng},get max(){return M[e.projection].unproject(M.OSMTILE.options.bounds.max).lng}},vertical:{name:"latitude",get min(){return M[e.projection].unproject(M.OSMTILE.options.bounds.min).lat},get max(){return M[e.projection].unproject(M.OSMTILE.options.bounds.max).lat}},get bounds(){return L.latLngBounds([M[e.projection].options.crs.gcrs.vertical.min,M[e.projection].options.crs.gcrs.horizontal.min],[M[e.projection].options.crs.gcrs.vertical.max,M[e.projection].options.crs.gcrs.horizontal.max])}},map:{horizontal:{name:"i",min:0,max:t=>t.getSize().x},vertical:{name:"j",min:0,max:t=>t.getSize().y},bounds:t=>L.bounds(L.point([0,0]),t.getSize())},tile:{horizontal:{name:"i",min:0,max:t},vertical:{name:"j",min:0,max:t},get bounds(){return L.bounds([M[e.projection].options.crs.tile.horizontal.min,M[e.projection].options.crs.tile.vertical.min],[M[e.projection].options.crs.tile.horizontal.max,M[e.projection].options.crs.tile.vertical.max])}},tilematrix:{horizontal:{name:"column",min:0,max:t=>Math.round(M[e.projection].options.crs.tcrs.horizontal.max(t)/M[e.projection].options.crs.tile.bounds.getSize().x)},vertical:{name:"row",min:0,max:t=>Math.round(M[e.projection].options.crs.tcrs.vertical.max(t)/M[e.projection].options.crs.tile.bounds.getSize().y)},bounds:t=>L.bounds([M[e.projection].options.crs.tilematrix.horizontal.min,M[e.projection].options.crs.tilematrix.vertical.min],[M[e.projection].options.crs.tilematrix.horizontal.max(t),M[e.projection].options.crs.tilematrix.vertical.max(t)])}}}),M[e.projection.toUpperCase()]=M[e.projection],e.projection}whenReady(){return new Promise((e,t)=>{let o,i;this._map?e():(o=setInterval(function(t){t._map&&(clearInterval(o),clearTimeout(i),e())},200,this),i=setTimeout(function(){clearInterval(o),clearTimeout(i),t("Timeout reached waiting for map to be ready")},5e3))})}whenLayersReady(){let t=[];for(var e of[...this.layers])t.push(e.whenReady());return Promise.allSettled(t)}whenProjectionDefined(n){return new Promise((e,t)=>{let o,i;M[n]?e():(o=setInterval(function(t){M[t]&&(clearInterval(o),clearTimeout(i),e())},200,n),i=setTimeout(function(){clearInterval(o),clearTimeout(i),t("Timeout reached waiting for projection to be defined")},5e3))})}geojson2mapml(t,e={}){void 0===e.projection&&(e.projection=this.projection);e=M.geojson2mapml(t,e);return this.appendChild(e),e}}window.customElements.define("mapml-viewer",MapViewer),window.customElements.define("layer-",MapLayer),window.customElements.define("map-caption",MapCaption),window.customElements.define("map-feature",MapFeature),window.customElements.define("map-extent",MapExtent),window.customElements.define("map-input",MapInput),window.customElements.define("map-select",MapSelect),window.customElements.define("map-link",MapLink),window.customElements.define("map-style",MapStyle);export{MapViewer}; //# sourceMappingURL=mapml-viewer.js.map \ No newline at end of file diff --git a/src/dist/mapml.js b/src/dist/mapml.js index 0ceabfc..05320b6 100644 --- a/src/dist/mapml.js +++ b/src/dist/mapml.js @@ -1,17 +1,24 @@ -/*! @maps4html/mapml 22-08-2024 */ +/*! @maps4html/mapml 28-08-2024 */ -!function(){"use strict";function t(t){return new m(t)}function e(t,e){return new c(t,e)}function o(t,e){return new p(t,e)}function i(t,e){return new h(t,e)}function n(t){return new d(t)}function a(t,e){return new _(t,e)}function s(t,e){return new y(t,e)}function r(t,e,o,i,n,a){return new f(t,e,o,i,n,a)}function l(t,e,o){return t||e?new g(t,e,o):null}function u(){return new b}var m=L.GridLayer.extend({initialize:function(t){L.setOptions(this,t),this.zoomBounds=this._getZoomBounds(t.tileContainer,t.maxZoomBound),L.extend(this.options,this.zoomBounds),this._groups=this._groupTiles(this.options.tileContainer.getElementsByTagName("map-tile")),this._bounds=this._getLayerBounds(this._groups,this.options.projection),this.layerBounds=this._bounds[Object.keys(this._bounds)[0]];for(var e of Object.keys(this._bounds))this.layerBounds.extend(this._bounds[e].min),this.layerBounds.extend(this._bounds[e].max)},onAdd:function(t){this._map=t,L.GridLayer.prototype.onAdd.call(this,this._map),this._handleMoveEnd()},getEvents:function(){let t=L.GridLayer.prototype.getEvents.call(this,this._map);return this._parentOnMoveEnd=t.moveend,t.moveend=this._handleMoveEnd,t.move=()=>{},t},isVisible:function(){var t=this._map.getZoom();let e=t;return e=e>this.options.maxNativeZoom?this.options.maxNativeZoom:e,e=e=this.zoomBounds.minZoom&&this._bounds[e]&&this._bounds[e].overlaps(M.pixelToPCRSBounds(this._map.getPixelBounds(),this._map.getZoom(),this._map.options.projection))},_handleMoveEnd:function(t){this.isVisible()&&this._parentOnMoveEnd()},_isValidTile(t){return this._groups[this._tileCoordsToKey(t)]},createTile:function(t){let o=this._groups[this._tileCoordsToKey(t)]||[],i=document.createElement("map-tile"),n=this.getTileSize();i.setAttribute("col",t.x),i.setAttribute("row",t.y),i.setAttribute("zoom",t.z);for(let e=0;ee.options.zIndex?1:0}},initialize:function(t,e){for(var o in L.setOptions(this,e),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,t)this._addLayer(t[o],o,!0)},onAdd:function(){return this._initLayout(),L.DomEvent.on(this._container.getElementsByTagName("a")[0],"keydown",this._focusFirstLayer,this._container),L.DomEvent.on(this._container,"contextmenu",this._preventDefaultContextMenu,this),this._update(),this._layers.length<1&&!this._map._showControls?this._container.setAttribute("hidden",""):this._map._showControls=!0,this._container},onRemove:function(t){L.DomEvent.off(this._container.getElementsByTagName("a")[0],"keydown",this._focusFirstLayer,this._container)},addOrUpdateOverlay:function(t,e){for(var o=!1,i=0;ie.focus(),0)},_update:function(){if(!this._container)return this;L.DomUtil.empty(this._baseLayersList),L.DomUtil.empty(this._overlaysList),this._layerControlInputs=[];var t,e,o,i,n=0;for(this.options.sortLayers&&this._layers.sort((t,e)=>this.options.sortFunction(t.layer,e.layer,t.name,e.name)),o=0;o=e.minZoom);return i&&this._layers&&o&&o.overlaps(M.pixelToPCRSBounds(n.getPixelBounds(),t,n.options.projection))}},onAdd:function(t){this._map=t,L.FeatureGroup.prototype.onAdd.call(this,t),this._staticFeature&&this._validateRendering(),this._queryFeatures&&t.on("featurepagination",this.showPaginationFeature,this)},addLayer:function(t){var e;return L.FeatureGroup.prototype.addLayer.call(this,t),this.options.layerBounds||(this.layerBounds=this.layerBounds?this.layerBounds.extend(t.layerBounds):L.bounds(t.layerBounds.min,t.layerBounds.max),this.zoomBounds?(t.zoomBounds.minZoomthis.zoomBounds.maxZoom&&(this.zoomBounds.maxZoom=t.zoomBounds.maxZoom),t.zoomBounds.minNativeZoomthis.zoomBounds.maxNativeZoom&&(this.zoomBounds.maxNativeZoom=t.zoomBounds.maxNativeZoom)):this.zoomBounds=t.zoomBounds),this._staticFeature&&((e=t.options.mapmlFeature.zoom)in this._features?this._features[e].push(t):this._features[e]=[t],this._validateRendering()),this},addRendering:function(t){L.FeatureGroup.prototype.addLayer.call(this,t)},onRemove:function(t){this._queryFeatures&&(t.off("featurepagination",this.showPaginationFeature,this),delete this._queryFeatures,L.DomUtil.remove(this._container)),L.FeatureGroup.prototype.onRemove.call(this,t),this._map.featureIndex.cleanIndex()},removeLayer:function(o){if(L.FeatureGroup.prototype.removeLayer.call(this,o),!this.options.layerBounds){delete this.layerBounds,delete this.options._leafletLayer.bounds,delete this.zoomBounds,delete this.options._leafletLayer.zoomBounds,delete this._layers[o._leaflet_id],this._removeFromFeaturesList(o);let t,e;var i;for(i of Object.keys(this._layers)){var n=this._layers[i];t?t.extend(n.layerBounds):t=L.bounds(n.layerBounds.min,n.layerBounds.max),e?(n.zoomBounds.minZoome.maxZoom&&(e.maxZoom=n.zoomBounds.maxZoom),n.zoomBounds.minNativeZoome.maxNativeZoom&&(e.maxNativeZoom=n.zoomBounds.maxNativeZoom)):(e={},e.minZoom=n.zoomBounds.minZoom,e.maxZoom=n.zoomBounds.maxZoom,e.minNativeZoom=n.zoomBounds.minNativeZoom,e.maxNativeZoom=n.zoomBounds.maxNativeZoom)}t?this.layerBounds=t:delete this.layerBounds,e?this.zoomBounds=e:(delete this.zoomBounds,delete this.options.zoomBounds)}return this},removeRendering:function(t){L.FeatureGroup.prototype.removeLayer.call(this,t)},_removeFromFeaturesList:function(t){for(var e in this._features)for(let t=0;t=this.zoomBounds.minZoom&&this.extentBounds.overlaps(o)},_initContainer:function(){this._container||(this._container=L.DomUtil.create("div","leaflet-layer",this.options.pane),L.DomUtil.addClass(this._container,"mapml-templated-tile-container"),this._updateZIndex())},_handleMoveEnd:function(t){this.isVisible()&&this._parentOnMoveEnd()},createTile:function(e){let o=document.createElement("DIV"),i=this.getTileSize();if(L.DomUtil.addClass(o,"mapml-tile-group"),L.DomUtil.addClass(o,"leaflet-tile"),this._template.linkEl.dispatchEvent(new CustomEvent("tileloadstart",{detail:{x:e.x,y:e.y,zoom:e.z,appendTile:t=>{o.appendChild(t)}}})),this._template.type.startsWith("image/")){let t=L.TileLayer.prototype.createTile.call(this,e,function(){});t.width=i.x,t.height=i.y,o.appendChild(t)}else this._url.includes(M.BLANK_TT_TREF)||this._fetchTile(e,o);return o},_mapmlTileReady:function(t){L.DomUtil.addClass(t,"leaflet-tile-loaded")},getPane:function(){return this.options.pane},_fetchTile:function(e,o){var t=this.getTileUrl(e);t&&fetch(t,{redirect:"follow"}).then(function(t){return 200<=t.status&&t.status<300?Promise.resolve(t):(console.log("Looks like there was a problem. Status Code: "+t.status),Promise.reject(t))}).then(function(t){return t.text()}).then(t=>{return(new DOMParser).parseFromString(t,"application/xml")}).then(t=>{this._createFeatures(t,e,o),this._mapmlTileReady(o)}).catch(t=>{console.log("Error Creating Tile")})},_parseStylesheetAsHTML:function(t,e,o){if(o instanceof Element&&t&&t.querySelector("map-link[rel=stylesheet],map-style")){if(e instanceof Element)e=e.getAttribute("href")?e.getAttribute("href"):document.URL;else if(!e||""===e||e instanceof Object)return;for(var i,n,a=[],s=t.querySelectorAll("map-link[rel=stylesheet],map-style"),r=0;r{"href"!==t.nodeName&&e.setAttribute(t.nodeName,t.nodeValue)})}},_createFeatures:function(t,e,o){var i;t.querySelector("map-link[rel=stylesheet],map-style")&&(i=t.querySelector("map-base")&&t.querySelector("map-base").hasAttribute("href")?new URL(t.querySelector("map-base").getAttribute("href")).href:t.URL,this._parseStylesheetAsHTML(t,i,o));let n=L.SVG.create("svg"),a=L.SVG.create("g"),s=this._map.options.crs.options.crs.tile.bounds.max.x,r=e.x*s,l=e.y*s,u=M.featureLayer(null,{projection:this._map.options.projection,tiles:!0,layerBounds:this.extentBounds,zoomBounds:this.zoomBounds,interactive:!1,mapEl:this._linkEl.getMapEl()});var m=M.getNativeVariables(t),c=t.querySelectorAll("map-feature:has(> map-geometry)");for(let t=0;t=this._template.tilematrix.bounds.length||!this._template.tilematrix.bounds[t.z].contains(t))return"";var e,o={},i=this._template.linkEl,n=i.zoomInput;for(e in o[this._template.tilematrix.col.name]=t.x,o[this._template.tilematrix.row.name]=t.y,n&&i.hasAttribute("tref")&&i.getAttribute("tref").includes(`{${n.getAttribute("name")}}`)&&(o[this._template.zoom.name]=this._getZoomForUrl()),o[this._template.pcrs.easting.left]=this._tileMatrixToPCRSPosition(t,"top-left").x,o[this._template.pcrs.easting.right]=this._tileMatrixToPCRSPosition(t,"top-right").x,o[this._template.pcrs.northing.top]=this._tileMatrixToPCRSPosition(t,"top-left").y,o[this._template.pcrs.northing.bottom]=this._tileMatrixToPCRSPosition(t,"bottom-left").y,this._template.tile)["row","col","zoom","left","right","top","bottom"].indexOf(e)<0&&(o[e]=this._template.tile[e]);return this._map&&!this._map.options.crs.infinite&&(t=this._globalTileRange.max.y-t.y,this.options.tms&&(o[this._template.tilematrix.row.name]=t)),o.r=this.options.detectRetina&&L.Browser.retina&&0this.options.maxNativeZoom&&(this._template.step=this.options.maxNativeZoom),t!==e?t=e:t%this._template.step!=0&&(t=Math.floor(t/this._template.step)*this._template.step),t}}),d=L.LayerGroup.extend({initialize:function(t){L.LayerGroup.prototype.initialize.call(this,null,t),this._container=L.DomUtil.create("div","leaflet-layer"),this._extentEl=this.options.extentEl,this.changeOpacity(this.options.opacity),L.DomUtil.addClass(this._container,"mapml-extentlayer-container")},getEvents:function(){return{zoomstart:this._onZoomStart}},_onZoomStart:function(){this.closePopup()},getContainer:function(){return this._container},onAdd:function(t){L.LayerGroup.prototype.onAdd.call(this,t);let e=this.options.extentEl.parentLayer._layer._container;e.appendChild(this._container)},redraw:function(){this.eachLayer(function(t){t.redraw()})},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},_updateZIndex:function(){this._container&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._container.style.zIndex=this.options.zIndex)},onRemove:function(){L.LayerGroup.prototype.onRemove.call(this,this._map),L.DomUtil.remove(this._container)},_previousFeature:function(t){0<=this._count+-1&&(this._count--,this._map.fire("featurepagination",{i:this._count,popup:this}))},_nextFeature:function(t){this._count+1=this.zoomBounds.minZoom&&this.extentBounds.overlaps(o)},getEvents:function(){return{moveend:this._onMoveEnd}},onAdd:function(e){this._map=e,this.options.pane.appendChild(this._container);var t=this.options.opacity||1,o=this._container;this._features?this._features.eachLayer(t=>t.addTo(e)):(this._features=M.featureLayer(null,{renderer:M.featureRenderer(),pane:o,layerBounds:this.extentBounds,zoomBounds:this.zoomBounds,opacity:t,projection:e.options.projection,mapEl:this._linkEl.getMapEl(),onEachFeature:function(t,e){var o=document.createElement("div");o.classList.add("mapml-popup-content"),o.insertAdjacentHTML("afterbegin",t.innerHTML),e.bindPopup(o,{autoClose:!1,minWidth:108})}}),L.extend(this._features.options,{_leafletLayer:this._features}),this._features._layerEl=this._linkEl.getLayerEl()),this._onMoveEnd()},onRemove:function(){this._features&&this._features.eachLayer(t=>t.remove()),L.DomUtil.remove(this._container)},appendStyleLink:function(e){if(e.link){let t=this._getStylePositionAndNode();t.node.insertAdjacentElement(t.position,e.link)}},_getStylePositionAndNode:function(){return this._container.lastChild&&("SVG"===this._container.lastChild.nodeName.toUpperCase()||this._container.lastChild.classList.contains("mapml-vector-container"))?{position:"beforebegin",node:this._container.lastChild}:this._container.lastChild?{position:"afterend",node:this._container.lastChild}:{position:"afterbegin",node:this._container}},appendStyleElement:function(e){if(e.styleElement){let t=this._getStylePositionAndNode();t.node.insertAdjacentElement(t.position,e.styleElement)}},redraw:function(){this._onMoveEnd()},_removeCSS:function(){var o=this._container.querySelectorAll("link[rel=stylesheet],style");for(let e=0;e *, map-body > *");for(let t=0;t{for(let t=0;t=this.zoomBounds.minZoom&&this.extentBounds.overlaps(o)},_clearLayer:function(){var e=this._container.querySelectorAll("img");for(let t=0;t map-meta[name=extent][content]")?M.getBoundsFromMeta(this._layerEl.shadowRoot):this._layerEl.querySelector(":scope > map-meta[name=extent][content]")?M.getBoundsFromMeta(this._layerEl):void 0,r=this._layerEl.src&&this._layerEl.shadowRoot.querySelector(":host > map-meta[name=zoom][content]")?M.getZoomBoundsFromMeta(this._layerEl.shadowRoot):this._layerEl.querySelector(":scope > map-meta[name=zoom][content]")?M.getZoomBoundsFromMeta(this._layerEl):void 0;const l=(this._layerEl.src?this._layerEl.shadowRoot:this._layerEl).querySelectorAll("map-extent");["_staticTileLayer","_mapmlvectors","_extentLayer"].forEach(t=>{let e,o,i,n;if(r&&(e=r.maxZoom,o=r.minZoom,n=r.maxNativeZoom||-1/0,i=r.minNativeZoom||1/0),"_extentLayer"===t&&l.length)for(let t=0;t'+e+"");L.setOptions(n,{attribution:e});var e=a.querySelector("map-link[rel=legend]");e&&(n._legendUrl=e.getAttribute("href"));n._map&&n._map.hasLayer(n)&&n._map.attributionControl.addAttribution(n.getAttribution())}(),a.querySelector("map-title")?(n._title=a.querySelector("map-title").textContent.trim(),n._titleIsReadOnly=!0):a instanceof Element&&a.hasAttribute("label")&&(n._title=a.getAttribute("label").trim()),M[n.options.projection]&&function(){if(a.querySelector("map-tile")){var t=document.createElement("map-tiles"),e=a.querySelector("map-meta[name=zoom][content]")||a.querySelector("map-input[type=zoom][value]");t.setAttribute("zoom",e&&e.getAttribute("content")||e&&e.getAttribute("value")||"0");for(var o=a.getElementsByTagName("map-tile"),i=0;i{L.DomEvent.stop(t),s.featureIndex._sortIndex(),s.closePopup(),s._container.focus()},n);let r=L.DomUtil.create("button","mapml-popup-button",t);r.type="button",r.title="Previous Feature",r.innerHTML="",L.DomEvent.on(r,"click",e._previousFeature,n);let l=L.DomUtil.create("p","mapml-feature-count",t),u=this._totalFeatureCount||1;l.innerText=n._count+1+"/"+u;let m=L.DomUtil.create("button","mapml-popup-button",t);m.type="button",m.title="Next Feature",m.innerHTML="",L.DomEvent.on(m,"click",e._nextFeature,n);let c=L.DomUtil.create("button","mapml-popup-button",t);c.type="button",c.title="Focus Controls",c.innerHTML="",L.DomEvent.on(c,"click",t=>{s.featureIndex._sortIndex(),s.featureIndex.currentIndex=s.featureIndex.inBoundFeatures.length-1,s.featureIndex.inBoundFeatures[0]?.path.setAttribute("tabindex",-1),s.featureIndex.inBoundFeatures[s.featureIndex.currentIndex]?.path.setAttribute("tabindex",0),L.DomEvent.stop(t),s.closePopup(),s._controlContainer.querySelector("A:not([hidden])").focus()},n);var p=L.DomUtil.create("hr","mapml-popup-divider");function h(t){let e=t.originalEvent.path||t.originalEvent.composedPath();var o=9===t.originalEvent.keyCode,i=t.originalEvent.shiftKey;(e[0].classList.contains("leaflet-popup-close-button")&&o&&!i||27===t.originalEvent.keyCode||e[0].classList.contains("leaflet-popup-close-button")&&13===t.originalEvent.keyCode||e[0].classList.contains("mapml-popup-content")&&o&&i||e[0]===n._content.querySelector("a")&&o&&i)&&setTimeout(()=>{s.closePopup(n),a.focus(),L.DomEvent.stop(t)},0)}function d(t){let e=t.originalEvent.path||t.originalEvent.composedPath();var o=9===t.originalEvent.keyCode,i=t.originalEvent.shiftKey;13===t.originalEvent.keyCode&&e[0].classList.contains("leaflet-popup-close-button")||27===t.originalEvent.keyCode?(L.DomEvent.stopPropagation(t),s.closePopup(n),s._container.focus(),27!==t.originalEvent.keyCode&&(s._popupClosed=!0)):o&&e[0].classList.contains("leaflet-popup-close-button")?s.closePopup(n):e[0].classList.contains("mapml-popup-content")&&o&&i?(s.closePopup(n),setTimeout(()=>{L.DomEvent.stop(t),s._container.focus()},0)):e[0]===n._content.querySelector("a")&&o&&i&&(s.closePopup(n),setTimeout(()=>{L.DomEvent.stop(t),s.getContainer.focus()},0))}function _(o){let i=this._content,n=o?o.currFeature:this._source._groupLayer._featureEl;if(i.querySelector("a.mapml-zoom-link")&&i.querySelector("a.mapml-zoom-link").remove(),n.querySelector("map-geometry")){var a=n.extent.topLeft.gcrs,o=n.extent.bottomRight.gcrs,o=L.latLngBounds(L.latLng(a.horizontal,a.vertical),L.latLng(o.horizontal,o.vertical)).getCenter(!0);let t=document.createElement("a");t.href=`#${n.getZoomToZoom()},${o.lng},`+o.lat,t.innerHTML=""+M.options.locale.popupZoom,t.className="mapml-zoom-link",t.onclick=t.onkeydown=function(t){(t instanceof MouseEvent||13===t.keyCode)&&(t.preventDefault(),n.zoomTo(),s.closePopup(),s.getContainer().focus())};let e=i.querySelector(".mapml-zoom-link");e&&e.remove(),i.insertBefore(t,i.querySelector("hr.mapml-popup-divider"))}}n._navigationBar=t,n._content.appendChild(p),n._content.appendChild(t),o.focus(),a&&!M.options.featureIndexOverlayOption?(a.setAttribute("aria-expanded","true"),s.on("keydown",h)):s.on("keydown",d),s.on("popupclose",function t(e){e.popup===n&&(s.off("keydown",h),s.off("keydown",d),s.off("popupopen",_),s.off("popupclose",t),a&&a.setAttribute("aria-expanded","false"))})}}),b=L.Layer.extend({onAdd:function(t){var e=t.getSize();(400{},t},isVisible:function(){var t=this._map.getZoom();let e=t;return e=e>this.options.maxNativeZoom?this.options.maxNativeZoom:e,e=e=this.zoomBounds.minZoom&&this._bounds[e]&&this._bounds[e].overlaps(M.pixelToPCRSBounds(this._map.getPixelBounds(),this._map.getZoom(),this._map.options.projection))},_handleMoveEnd:function(t){this.isVisible()&&this._parentOnMoveEnd()},_isValidTile(t){return this._groups[this._tileCoordsToKey(t)]},createTile:function(t){let i=this._groups[this._tileCoordsToKey(t)]||[],o=document.createElement("map-tile"),n=this.getTileSize();o.setAttribute("col",t.x),o.setAttribute("row",t.y),o.setAttribute("zoom",t.z);for(let e=0;ee.options.zIndex?1:0}},initialize:function(t,e){for(var i in L.setOptions(this,e),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,t)this._addLayer(t[i],i,!0)},onAdd:function(){return this._initLayout(),L.DomEvent.on(this._container.getElementsByTagName("a")[0],"keydown",this._focusFirstLayer,this._container),L.DomEvent.on(this._container,"contextmenu",this._preventDefaultContextMenu,this),this._update(),this._layers.length<1&&!this._map._showControls?this._container.setAttribute("hidden",""):this._map._showControls=!0,this._container},onRemove:function(t){L.DomEvent.off(this._container.getElementsByTagName("a")[0],"keydown",this._focusFirstLayer,this._container)},addOrUpdateOverlay:function(t,e){for(var i=!1,o=0;oe.focus(),0)},_update:function(){if(!this._container)return this;L.DomUtil.empty(this._baseLayersList),L.DomUtil.empty(this._overlaysList),this._layerControlInputs=[];var t,e,i,o,n=0;for(this.options.sortLayers&&this._layers.sort((t,e)=>this.options.sortFunction(t.layer,e.layer,t.name,e.name)),i=0;i=e.minZoom);return o&&this._layers&&i&&i.overlaps(M.pixelToPCRSBounds(n.getPixelBounds(),t,n.options.projection))}},onAdd:function(t){this._map=t,L.FeatureGroup.prototype.onAdd.call(this,t),this._staticFeature&&this._validateRendering(),this._queryFeatures&&t.on("featurepagination",this.showPaginationFeature,this)},addLayer:function(t){var e;return L.FeatureGroup.prototype.addLayer.call(this,t),this.options.layerBounds||(this.layerBounds=this.layerBounds?this.layerBounds.extend(t.layerBounds):L.bounds(t.layerBounds.min,t.layerBounds.max),this.zoomBounds?(t.zoomBounds.minZoomthis.zoomBounds.maxZoom&&(this.zoomBounds.maxZoom=t.zoomBounds.maxZoom),t.zoomBounds.minNativeZoomthis.zoomBounds.maxNativeZoom&&(this.zoomBounds.maxNativeZoom=t.zoomBounds.maxNativeZoom)):this.zoomBounds=t.zoomBounds),this._staticFeature&&((e=t.options.mapmlFeature.zoom)in this._features?this._features[e].push(t):this._features[e]=[t],this._validateRendering()),this},addRendering:function(t){L.FeatureGroup.prototype.addLayer.call(this,t)},onRemove:function(t){this._queryFeatures&&(t.off("featurepagination",this.showPaginationFeature,this),delete this._queryFeatures,L.DomUtil.remove(this._container)),L.FeatureGroup.prototype.onRemove.call(this,t),this._map.featureIndex.cleanIndex()},removeLayer:function(i){if(L.FeatureGroup.prototype.removeLayer.call(this,i),!this.options.layerBounds){delete this.layerBounds,delete this.options._leafletLayer.bounds,delete this.zoomBounds,delete this.options._leafletLayer.zoomBounds,delete this._layers[i._leaflet_id],this._removeFromFeaturesList(i);let t,e;var o;for(o of Object.keys(this._layers)){var n=this._layers[o];t?t.extend(n.layerBounds):t=L.bounds(n.layerBounds.min,n.layerBounds.max),e?(n.zoomBounds.minZoome.maxZoom&&(e.maxZoom=n.zoomBounds.maxZoom),n.zoomBounds.minNativeZoome.maxNativeZoom&&(e.maxNativeZoom=n.zoomBounds.maxNativeZoom)):(e={},e.minZoom=n.zoomBounds.minZoom,e.maxZoom=n.zoomBounds.maxZoom,e.minNativeZoom=n.zoomBounds.minNativeZoom,e.maxNativeZoom=n.zoomBounds.maxNativeZoom)}t?this.layerBounds=t:delete this.layerBounds,e?this.zoomBounds=e:(delete this.zoomBounds,delete this.options.zoomBounds)}return this},removeRendering:function(t){L.FeatureGroup.prototype.removeLayer.call(this,t)},_removeFromFeaturesList:function(t){for(var e in this._features)for(let t=0;t=this.zoomBounds.minZoom&&this.extentBounds.overlaps(i)},_initContainer:function(){this._container||(this._container=L.DomUtil.create("div","leaflet-layer",this.options.pane),L.DomUtil.addClass(this._container,"mapml-templated-tile-container"),this._updateZIndex())},_handleMoveEnd:function(t){this.isVisible()&&this._parentOnMoveEnd()},createTile:function(e){let i=document.createElement("DIV"),o=this.getTileSize();if(L.DomUtil.addClass(i,"mapml-tile-group"),L.DomUtil.addClass(i,"leaflet-tile"),this._template.linkEl.dispatchEvent(new CustomEvent("tileloadstart",{detail:{x:e.x,y:e.y,zoom:e.z,appendTile:t=>{i.appendChild(t)}}})),this._template.type.startsWith("image/")){let t=L.TileLayer.prototype.createTile.call(this,e,function(){});t.width=o.x,t.height=o.y,i.appendChild(t)}else this._url.includes(M.BLANK_TT_TREF)||this._fetchTile(e,i);return i},_mapmlTileReady:function(t){L.DomUtil.addClass(t,"leaflet-tile-loaded")},getPane:function(){return this.options.pane},_fetchTile:function(e,i){var t=this.getTileUrl(e);t&&fetch(t,{redirect:"follow"}).then(function(t){return 200<=t.status&&t.status<300?Promise.resolve(t):(console.log("Looks like there was a problem. Status Code: "+t.status),Promise.reject(t))}).then(function(t){return t.text()}).then(t=>{return(new DOMParser).parseFromString(t,"application/xml")}).then(t=>{this._createFeatures(t,e,i),this._mapmlTileReady(i)}).catch(t=>{console.log("Error Creating Tile")})},_parseStylesheetAsHTML:function(t,e,i){if(i instanceof Element&&t&&t.querySelector("map-link[rel=stylesheet],map-style")){if(e instanceof Element)e=e.getAttribute("href")?e.getAttribute("href"):document.URL;else if(!e||""===e||e instanceof Object)return;for(var o,n,a=[],r=t.querySelectorAll("map-link[rel=stylesheet],map-style"),s=0;s{"href"!==t.nodeName&&e.setAttribute(t.nodeName,t.nodeValue)})}},_createFeatures:function(t,e,i){var o;t.querySelector("map-link[rel=stylesheet],map-style")&&(o=t.querySelector("map-base")&&t.querySelector("map-base").hasAttribute("href")?new URL(t.querySelector("map-base").getAttribute("href")).href:t.URL,this._parseStylesheetAsHTML(t,o,i));let n=L.SVG.create("svg"),a=L.SVG.create("g"),r=this._map.options.crs.options.crs.tile.bounds.max.x,s=e.x*r,l=e.y*r,h=M.featureLayer(null,{projection:this._map.options.projection,tiles:!0,layerBounds:this.extentBounds,zoomBounds:this.zoomBounds,interactive:!1,mapEl:this._linkEl.getMapEl()});var c=M.getNativeVariables(t),u=t.querySelectorAll("map-feature:has(> map-geometry)");for(let t=0;t=this._template.tilematrix.bounds.length||!this._template.tilematrix.bounds[t.z].contains(t))return"";var e,i={},o=this._template.linkEl,n=o.zoomInput;for(e in i[this._template.tilematrix.col.name]=t.x,i[this._template.tilematrix.row.name]=t.y,n&&o.hasAttribute("tref")&&o.getAttribute("tref").includes(`{${n.getAttribute("name")}}`)&&(i[this._template.zoom.name]=this._getZoomForUrl()),i[this._template.pcrs.easting.left]=this._tileMatrixToPCRSPosition(t,"top-left").x,i[this._template.pcrs.easting.right]=this._tileMatrixToPCRSPosition(t,"top-right").x,i[this._template.pcrs.northing.top]=this._tileMatrixToPCRSPosition(t,"top-left").y,i[this._template.pcrs.northing.bottom]=this._tileMatrixToPCRSPosition(t,"bottom-left").y,this._template.tile)["row","col","zoom","left","right","top","bottom"].indexOf(e)<0&&(i[e]=this._template.tile[e]);return this._map&&!this._map.options.crs.infinite&&(t=this._globalTileRange.max.y-t.y,this.options.tms&&(i[this._template.tilematrix.row.name]=t)),i.r=this.options.detectRetina&&L.Browser.retina&&0this.options.maxNativeZoom&&(this._template.step=this.options.maxNativeZoom),t!==e?t=e:t%this._template.step!=0&&(t=Math.floor(t/this._template.step)*this._template.step),t}}),u=L.LayerGroup.extend({initialize:function(t){L.LayerGroup.prototype.initialize.call(this,null,t),this._container=L.DomUtil.create("div","leaflet-layer"),this._extentEl=this.options.extentEl,this.changeOpacity(this.options.opacity),L.DomUtil.addClass(this._container,"mapml-extentlayer-container")},getEvents:function(){return{zoomstart:this._onZoomStart}},_onZoomStart:function(){this.closePopup()},getContainer:function(){return this._container},onAdd:function(t){L.LayerGroup.prototype.onAdd.call(this,t);let e=this.options.extentEl.parentLayer._layer._container;e.appendChild(this._container)},redraw:function(){this.eachLayer(function(t){t.redraw()})},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},_updateZIndex:function(){this._container&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._container.style.zIndex=this.options.zIndex)},onRemove:function(){L.LayerGroup.prototype.onRemove.call(this,this._map),L.DomUtil.remove(this._container)},_previousFeature:function(t){0<=this._count+-1&&(this._count--,this._map.fire("featurepagination",{i:this._count,popup:this}))},_nextFeature:function(t){this._count+1=this.zoomBounds.minZoom&&this.extentBounds.overlaps(i)},getEvents:function(){return{moveend:this._onMoveEnd}},onAdd:function(e){this._map=e,this.options.pane.appendChild(this._container);var t=this.options.opacity||1,i=this._container;this._features?this._features.eachLayer(t=>t.addTo(e)):(this._features=M.featureLayer(null,{renderer:M.featureRenderer(),pane:i,layerBounds:this.extentBounds,zoomBounds:this.zoomBounds,opacity:t,projection:e.options.projection,mapEl:this._linkEl.getMapEl(),onEachFeature:function(t,e){var i=document.createElement("div");i.classList.add("mapml-popup-content"),i.insertAdjacentHTML("afterbegin",t.innerHTML),e.bindPopup(i,{autoClose:!1,minWidth:108})}}),L.extend(this._features.options,{_leafletLayer:this._features}),this._features._layerEl=this._linkEl.getLayerEl()),this._onMoveEnd()},onRemove:function(){this._features&&this._features.eachLayer(t=>t.remove()),L.DomUtil.remove(this._container)},appendStyleLink:function(e){if(e.link){let t=this._getStylePositionAndNode();t.node.insertAdjacentElement(t.position,e.link)}},_getStylePositionAndNode:function(){return this._container.lastChild&&("SVG"===this._container.lastChild.nodeName.toUpperCase()||this._container.lastChild.classList.contains("mapml-vector-container"))?{position:"beforebegin",node:this._container.lastChild}:this._container.lastChild?{position:"afterend",node:this._container.lastChild}:{position:"afterbegin",node:this._container}},appendStyleElement:function(e){if(e.styleElement){let t=this._getStylePositionAndNode();t.node.insertAdjacentElement(t.position,e.styleElement)}},redraw:function(){this._onMoveEnd()},_removeCSS:function(){var i=this._container.querySelectorAll("link[rel=stylesheet],style");for(let e=0;e *, map-body > *");for(let t=0;t{for(let t=0;t=this.zoomBounds.minZoom&&this.extentBounds.overlaps(i)},_clearLayer:function(){var e=this._container.querySelectorAll("img");for(let t=0;t>>0)%2341}(e)];if(!e)throw new y(t);return"#"+e}(t):t,i=v.exec(e);if(i){const a=Array.from(i).slice(1);return[...a.slice(0,3).map(t=>parseInt(x(t,2),16)),parseInt(x(a[3]||"f",2),16)/255]}var o=w.exec(e);if(o){const r=Array.from(o).slice(1);return[...r.slice(0,3).map(t=>parseInt(t,16)),parseInt(r[3]||"ff",16)/255]}var n=S.exec(e);if(n){const s=Array.from(n).slice(1);return[...s.slice(0,3).map(t=>parseInt(t,10)),parseFloat(s[3]||"1")]}i=T.exec(e);if(i){var[o,n,e,i]=Array.from(i).slice(1).map(parseFloat);if(p(0,100,n)!==n)throw new y(t);if(p(0,100,e)!==e)throw new y(t);return[...z(o,n,e),Number.isNaN(i)?1:i]}throw new y(t)}const g=t=>parseInt(t.replace(/_/g,""),36),b="1q29ehhb 1n09sgk7 1kl1ekf_ _yl4zsno 16z9eiv3 1p29lhp8 _bd9zg04 17u0____ _iw9zhe5 _to73___ _r45e31e _7l6g016 _jh8ouiv _zn3qba8 1jy4zshs 11u87k0u 1ro9yvyo 1aj3xael 1gz9zjz0 _3w8l4xo 1bf1ekf_ _ke3v___ _4rrkb__ 13j776yz _646mbhl _nrjr4__ _le6mbhl 1n37ehkb _m75f91n _qj3bzfz 1939yygw 11i5z6x8 _1k5f8xs 1509441m 15t5lwgf _ae2th1n _tg1ugcv 1lp1ugcv 16e14up_ _h55rw7n _ny9yavn _7a11xb_ 1ih442g9 _pv442g9 1mv16xof 14e6y7tu 1oo9zkds 17d1cisi _4v9y70f _y98m8kc 1019pq0v 12o9zda8 _348j4f4 1et50i2o _8epa8__ _ts6senj 1o350i2o 1mi9eiuo 1259yrp0 1ln80gnw _632xcoy 1cn9zldc _f29edu4 1n490c8q _9f9ziet 1b94vk74 _m49zkct 1kz6s73a 1eu9dtog _q58s1rz 1dy9sjiq __u89jo3 _aj5nkwg _ld89jo3 13h9z6wx _qa9z2ii _l119xgq _bs5arju 1hj4nwk9 1qt4nwk9 1ge6wau6 14j9zlcw 11p1edc_ _ms1zcxe _439shk6 _jt9y70f _754zsow 1la40eju _oq5p___ _x279qkz 1fa5r3rv _yd2d9ip _424tcku _8y1di2_ _zi2uabw _yy7rn9h 12yz980_ __39ljp6 1b59zg0x _n39zfzp 1fy9zest _b33k___ _hp9wq92 1il50hz4 _io472ub _lj9z3eo 19z9ykg0 _8t8iu3a 12b9bl4a 1ak5yw0o _896v4ku _tb8k8lv _s59zi6t _c09ze0p 1lg80oqn 1id9z8wb _238nba5 1kq6wgdi _154zssg _tn3zk49 _da9y6tc 1sg7cv4f _r12jvtt 1gq5fmkz 1cs9rvci _lp9jn1c _xw1tdnb 13f9zje6 16f6973h _vo7ir40 _bt5arjf _rc45e4t _hr4e100 10v4e100 _hc9zke2 _w91egv_ _sj2r1kk 13c87yx8 _vqpds__ _ni8ggk8 _tj9yqfb 1ia2j4r4 _7x9b10u 1fc9ld4j 1eq9zldr _5j9lhpx _ez9zl6o _md61fzm".split(" ").reduce((t,e)=>{var i=g(e.substring(0,3)),o=g(e.substring(3)).toString(16);let n="";for(let t=0;t<6-o.length;t++)n+="0";return t[i]=""+n+o,t},{});const x=(t,e)=>Array.from(Array(e)).map(()=>t).join(""),v=new RegExp(`^#${x("([a-f0-9])",3)}([a-f0-9])?$`,"i"),w=new RegExp(`^#${x("([a-f0-9]{2})",3)}([a-f0-9]{2})?$`,"i"),S=new RegExp(`^rgba?\\(\\s*(\\d+)\\s*${x(",\\s*(\\d+)\\s*",2)}(?:,\\s*([\\d.]+))?\\s*\\)$`,"i"),T=/^hsla?\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)$/i,E=/^[a-z]+$/i,k=t=>Math.round(255*t),z=(t,e,i)=>{let o=i/100;if(0===e)return[o,o,o].map(k);i=(t%360+360)%360/60,t=(1-Math.abs(2*o-1))*(e/100),e=t*(1-Math.abs(i%2-1));let n=0,a=0,r=0;0<=i&&i<1?(n=t,a=e):1<=i&&i<2?(n=e,a=t):2<=i&&i<3?(a=t,r=e):3<=i&&i<4?(a=e,r=t):4<=i&&i<5?(n=e,r=t):5<=i&&i<6&&(n=t,r=e);t=o-t/2;const s=n+t,l=a+t,h=r+t;return[s,l,h].map(k)};function A(t,e,i){var o=(t,e)=>3===e?t:t/255,[n,a,r,s]=_(t).map(o),[l,h,c,t]=_(e).map(o),e=t-s,o=2*i-1,o=(1+(o*e==-1?o:o+e/(1+o*e)))/2,e=1-o;return h=255*(a*e+h*o),c=255*(r*e+c*o),i=t*i+s*(1-i),`rgba(${p(0,255,255*(n*e+l*o)).toFixed()}, ${p(0,255,h).toFixed()}, ${p(0,255,c).toFixed()}, ${parseFloat(p(0,1,i).toFixed(3))})`}class I{constructor(t,e,i,o,n){this.properties={},this.extent=i,this.type=0,this.id=void 0,this._pbf=t,this._geometry=-1,this._keys=o,this._values=n,t.readFields(P,this,e)}loadGeometry(){const t=this._pbf;t.pos=this._geometry;var e,i=t.readVarint()+t.pos;const o=[];let n,a=1,r=0,s=0,l=0;for(;t.pos>3),r--,1===a||2===a)s+=t.readSVarint(),l+=t.readSVarint(),1===a&&(n&&o.push(n),n=[]),n&&n.push(new C(s,l));else{if(7!==a)throw new Error("unknown command "+a);n&&n.push(n[0].clone())}return n&&o.push(n),o}bbox(){const t=this._pbf;t.pos=this._geometry;var e,i=t.readVarint()+t.pos;let o=1,n=0,a=0,r=0,s=1/0,l=-1/0,h=1/0,c=-1/0;for(;t.pos>3),n--,1===o||2===o)a+=t.readSVarint(),r+=t.readSVarint(),al&&(l=a),rc&&(c=r);else if(7!==o)throw new Error("unknown command "+o);return[s,h,l,c]}toGeoJSON(t,e,i){const o=this.extent*Math.pow(2,i),n=this.extent*t,a=this.extent*e,r=this.loadGeometry();function s(t){return[360*(t.x+n)/o-180,360/Math.PI*Math.atan(Math.exp((1-2*(t.y+a)/o)*Math.PI))-90]}function l(t){return t.map(s)}let h;if(1===this.type){const m=[];for(const d of r)m.push(d[0]);var c=l(m);h=1===m.length?{type:"Point",coordinates:c[0]}:{type:"MultiPoint",coordinates:c}}else if(2===this.type){c=r.map(l);h=1===c.length?{type:"LineString",coordinates:c[0]}:{type:"MultiLineString",coordinates:c}}else{if(3!==this.type)throw new Error("unknown feature type");{const p=[];for(const f of function(e){var i=e.length;if(i<=1)return[e];const o=[];let n,a;for(let t=0;t=this._features.length)throw new Error("feature index out of bounds");this._pbf.pos=this._features[t];t=this._pbf.readVarint()+this._pbf.pos;return new I(this._pbf,t,this.extent,this._keys,this._values)}}function F(t,e,i){15===t?e.version=i.readVarint():1===t?e.name=i.readString():5===t?e.extent=i.readVarint():2===t?e._features.push(i.pos):3===t?e._keys.push(i.readString()):4===t&&e._values.push(function(t){let e=null;var i=t.readVarint()+t.pos;for(;t.pos>3;e=1==o?t.readString():2==o?t.readFloat():3==o?t.readDouble():4==o?t.readVarint64():5==o?t.readVarint():6==o?t.readSVarint():7==o?t.readBoolean():null}return e}(i))}class R{constructor(t,e){this.layers=t.readFields(D,{},e)}}function D(t,e,i){3!==t||(i=new B(i,i.readVarint()+i.pos)).length&&(e[i.name]=i)}const O=4294967296,N=1/O,q="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8");class j{constructor(t=new Uint8Array(16)){this.buf=ArrayBuffer.isView(t)?t:new Uint8Array(t),this.dataView=new DataView(this.buf.buffer),this.pos=0,this.type=0,this.length=this.buf.length}readFields(t,e,i=this.length){for(;this.pos>3,a=this.pos;this.type=7&o,t(n,e,this),this.pos===a&&this.skip(o)}return e}readMessage(t,e){return this.readFields(t,e,this.readVarint()+this.pos)}readFixed32(){var t=this.dataView.getUint32(this.pos,!0);return this.pos+=4,t}readSFixed32(){var t=this.dataView.getInt32(this.pos,!0);return this.pos+=4,t}readFixed64(){var t=this.dataView.getUint32(this.pos,!0)+this.dataView.getUint32(this.pos+4,!0)*O;return this.pos+=8,t}readSFixed64(){var t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*O;return this.pos+=8,t}readFloat(){var t=this.dataView.getFloat32(this.pos,!0);return this.pos+=4,t}readDouble(){var t=this.dataView.getFloat64(this.pos,!0);return this.pos+=8,t}readVarint(t){var e=this.buf;let i,o;return o=e[this.pos++],i=127&o,o<128?i:(o=e[this.pos++],i|=(127&o)<<7,o<128?i:(o=e[this.pos++],i|=(127&o)<<14,o<128?i:(o=e[this.pos++],i|=(127&o)<<21,o<128?i:(o=e[this.pos],i|=(15&o)<<28,function(t,e,i){var o=i.buf;let n,a;if(a=o[i.pos++],n=(112&a)>>4,a<128)return U(t,n,e);if(a=o[i.pos++],n|=(127&a)<<3,a<128)return U(t,n,e);if(a=o[i.pos++],n|=(127&a)<<10,a<128)return U(t,n,e);if(a=o[i.pos++],n|=(127&a)<<17,a<128)return U(t,n,e);if(a=o[i.pos++],n|=(127&a)<<24,a<128)return U(t,n,e);if(a=o[i.pos++],n|=(1&a)<<31,a<128)return U(t,n,e);throw new Error("Expected varint not more than 10 bytes")}(i,t,this)))))}readVarint64(){return this.readVarint(!0)}readSVarint(){var t=this.readVarint();return t%2==1?(t+1)/-2:t/2}readBoolean(){return Boolean(this.readVarint())}readString(){var t=this.readVarint()+this.pos,e=this.pos;return 12<=(this.pos=t)-e&&q?q.decode(this.buf.subarray(e,t)):function(a,t,r){let s="",l=t;for(;lr)break;let i,o,n;1===e?h<128&&(t=h):2===e?(i=a[l+1],128==(192&i)&&(t=(31&h)<<6|63&i,t<=127&&(t=null))):3===e?(i=a[l+1],o=a[l+2],128==(192&i)&&128==(192&o)&&(t=(15&h)<<12|(63&i)<<6|63&o,(t<=2047||55296<=t&&t<=57343)&&(t=null))):4===e&&(i=a[l+1],o=a[l+2],n=a[l+3],128==(192&i)&&128==(192&o)&&128==(192&n)&&(t=(15&h)<<18|(63&i)<<12|(63&o)<<6|63&n,(t<=65535||1114112<=t)&&(t=null))),null===t?(t=65533,e=1):65535>>10&1023|55296),t=56320|1023&t),s+=String.fromCharCode(t),l+=e}return s}(this.buf,e,t)}readBytes(){var t=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,t);return this.pos=t,e}readPackedVarint(t=[],e){for(var i=this.readPackedEnd();this.pos>>=7,e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos++]=127&t|128,t>>>=7,e.buf[e.pos]=127&t}(i,(o,e)),function(t,e){var i=(7&t)<<4;e.buf[e.pos++]|=i|((t>>>=3)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t|((t>>>=7)?128:0),t&&(e.buf[e.pos++]=127&t)))))}(o,e)}(t,this):(this.realloc(4),this.buf[this.pos++]=127&t|(127>>=7)|(127>>=7)|(127>>7&127))))}writeSVarint(t){this.writeVarint(t<0?2*-t-1:2*t)}writeBoolean(t){this.writeVarint(+t)}writeString(t){t=String(t),this.realloc(4*t.length),this.pos++;var e=this.pos;this.pos=function(o,n,a){for(let t=0,e,i;t>6|192:(e<65536?o[a++]=e>>12|224:(o[a++]=e>>18|240,o[a++]=e>>12&63|128),o[a++]=e>>6&63|128),o[a++]=63&e|128)}return a}(this.buf,t,this.pos);t=this.pos-e;128<=t&&Z(e,t,this),this.pos=e-1,this.writeVarint(t),this.pos+=t}writeFloat(t){this.realloc(4),this.dataView.setFloat32(this.pos,t,!0),this.pos+=4}writeDouble(t){this.realloc(8),this.dataView.setFloat64(this.pos,t,!0),this.pos+=8}writeBytes(e){var i=e.length;this.writeVarint(i),this.realloc(i);for(let t=0;t>>0):4294967296*(e>>>0)+(t>>>0)}function Z(e,t,i){var o=t<=16383?1:t<=2097151?2:t<=268435455?3:Math.floor(Math.log(t)/(7*Math.LN2));i.realloc(o);for(let t=i.pos-1;t>=e;t--)i.buf[t+o]=i.buf[t]}function H(e,i){for(let t=0;tnew Promise((e,i)=>{var o=t=>{try{a(s.next(t))}catch(t){i(t)}},n=t=>{try{a(s.throw(t))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,n);a((s=s.apply(t,r)).next())}),it=Uint8Array,ot=Uint16Array,nt=Int32Array,at=new it([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),rt=new it([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),st=new it([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),lt=Q(at,2),ht=lt.b;lt.r[ht[28]=258]=28;var ct,ut=Q(rt,0).b,mt=new ot(32768);for(ft=0;ft<32768;++ft)mt[ft]=((65280&(ct=(61680&(ct=(52428&(ct=(43690&ft)>>1|(21845&ft)<<1))>>2|(13107&ct)<<2))>>4|(3855&ct)<<4))>>8|(255&ct)<<8)>>1;var dt=function(t,e,i){for(var o=t.length,n=0,a=new ot(e);n>l]=h}else for(s=new ot(o),n=0;n>15-t[n]);return s},pt=new it(288);for(ft=0;ft<144;++ft)pt[ft]=8;for(ft=144;ft<256;++ft)pt[ft]=9;for(ft=256;ft<280;++ft)pt[ft]=7;for(ft=280;ft<288;++ft)pt[ft]=8;var ft,yt=new it(32);for(ft=0;ft<32;++ft)yt[ft]=5;function _t(t,e,i,o){var n=t.length,a=o?o.length:0;if(!n||e.f&&!e.l)return i||new it(0);var r=!i||2!=e.i,s=e.i;function l(t){var e=i.length;e>4)<16)L[M++]=T;else{var k=0,z=0;for(16==T?(z=3+Mt(t,c,3),c+=2,k=L[M-1]):17==T?(z=3+Mt(t,c,7),c+=3):18==T&&(z=11+Mt(t,c,127),c+=7);z--;)L[M++]=k}}var b=L.subarray(0,g),A=L.subarray(g),p=wt(b),f=wt(A),m=dt(b,p,1),d=dt(A,f,1)}else kt(1);if(y>4;if(y<(c+=15&k)){s&&kt(0);break}if(k||kt(2),F<256)i[u++]=F;else{if(256==F){B=c,m=null;break}var R=F-254;264>4;D||kt(3),c+=15&D;var O,A=ut[F];if(3>3&1)+(e>>4&1);0>>0}function xt(t,e){return(8!=(15&t[0])||7>4||(t[0]<<8|t[1])%31)&&kt(6,"invalid zlib data"),(t[1]>>5&1)==+!e&&kt(6,"invalid zlib data: "+(32&t[1]?"need":"unexpected")+" dictionary"),2+(t[1]>>3&4)}var vt=dt(pt,9,1),Lt=dt(yt,5,1),wt=function(t){for(var e=t[0],i=1;ie&&(e=t[i]);return e},Mt=function(t,e,i){var o=e/8|0;return(t[o]|t[1+o]<<8)>>(7&e)&i},Ct=function(t,e){var i=e/8|0;return(t[i]|t[1+i]<<8|t[2+i]<<16)>>(7&e)},St=function(t){return(t+7)/8|0},Tt=function(t,e,i){(null==i||i>t.length)&&(i=t.length);var o=new it(i-(e=null==e||e<0?0:e));return o.set(t.subarray(e,i)),o},Et=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],kt=function(t,e,i){e=new Error(e||Et[t]);if(e.code=t,Error.captureStackTrace&&Error.captureStackTrace(e,kt),!i)throw e;return e},zt=new it(0);function At(t,e){return 31==t[0]&&139==t[1]&&8==t[2]?(o=e,(n=gt(i=t))+8>i.length&&kt(6,"invalid gzip data"),_t(i.subarray(n,-8),{i:2},o&&o.out||new it(bt(i)),o&&o.dictionary)):8!=(15&t[0])||7>4||(t[0]<<8|t[1])%31?_t(t,{i:2},(o=e)&&o.out,o&&o.dictionary):(e=e,_t(t.subarray(xt(t,e&&e.dictionary),-4),{i:2},e&&e.out,e&&e.dictionary));var i,o,n}var It="undefined"!=typeof TextDecoder&&new TextDecoder;try{It.decode(zt,{stream:!0})}catch(t){}var Pt=(t,e)=>t*tt(2,e),Bt=(t,e)=>Math.floor(t/tt(2,e)),Ft=(t,e)=>Pt(t.getUint16(e+1,!0),8)+t.getUint8(e),Rt=(t,e)=>Pt(t.getUint32(e+2,!0),16)+t.getUint16(e,!0),Dt=(t,e,i,o)=>{t=Ot(t,e,i,o);return t?{z:e,x:i,y:o,offset:t[0],length:t[1],isDir:!1}:null},Ot=(t,e,i,o)=>{let n=0,a=t.byteLength/17-1;for(;n<=a;){var r=a+n>>1,s=((t,e,i,o,n)=>{if(t!==o.getUint8(n))return t-o.getUint8(n);t=Ft(o,n+1);if(e!==t)return e-t;n=Ft(o,n+4);return i!==n?i-n:0})(e,i,o,t,17*r);if(0t.isDir&&!e.isDir?1:!t.isDir&&e.isDir?-1:t.z!==e.z?t.z-e.z:t.x!==e.x?t.x-e.x:t.y-e.y,qt=(t,e)=>{var i=t.getUint8(17*e);return{z:127&i,x:Ft(t,17*e+1),y:Ft(t,17*e+4),offset:Rt(t,17*e+7),length:t.getUint32(17*e+13,!0),isDir:i>>7==1}},jt=t=>{const e=[];var i=new DataView(t);for(let t=0;t{i.sort(Nt);var t=new ArrayBuffer(17*i.length);const o=new Uint8Array(t);for(let e=0;e>8&255,o[17*e+3]=n.x>>16&255,o[17*e+4]=255&n.y,o[17*e+5]=n.y>>8&255,o[17*e+6]=n.y>>16&255,o[17*e+7]=255&n.offset,o[17*e+8]=255&Bt(n.offset,8),o[17*e+9]=255&Bt(n.offset,16),o[17*e+10]=255&Bt(n.offset,24),o[17*e+11]=255&Bt(n.offset,32),o[17*e+12]=255&Bt(n.offset,48),o[17*e+13]=255&n.length,o[17*e+14]=n.length>>8&255,o[17*e+15]=n.length>>16&255,o[17*e+16]=n.length>>24&255}return t};var Zt={getHeader:function(_){return et(this,null,function*(){var t=yield _.getBytes(0,512e3);const e=new DataView(t.data);var i,o=e.getUint32(4,!0),n=e.getUint16(8,!0);const a=new TextDecoder("utf-8"),r=JSON.parse(a.decode(new DataView(t.data,10,o)));let s=0;"gzip"===r.compression&&(s=2);let l=0;"minzoom"in r&&(l=+r.minzoom);let h=0;"maxzoom"in r&&(h=+r.maxzoom);let c=0,u=0,m=0,d=-180,p=-85,f=180,y=85;return r.bounds&&(i=r.bounds.split(","),d=+i[0],p=+i[1],f=+i[2],y=+i[3]),r.center&&(i=r.center.split(","),c=+i[0],u=+i[1],m=+i[2]),{specVersion:e.getUint16(2,!0),rootDirectoryOffset:10+o,rootDirectoryLength:17*n,jsonMetadataOffset:10,jsonMetadataLength:o,leafDirectoryOffset:0,leafDirectoryLength:void 0,tileDataOffset:0,tileDataLength:void 0,numAddressedTiles:0,numTileEntries:0,numTileContents:0,clustered:!1,internalCompression:1,tileCompression:s,tileType:1,minZoom:l,maxZoom:h,minLon:d,minLat:p,maxLon:f,maxLat:y,centerZoom:m,centerLon:c,centerLat:u,etag:t.etag}})},getZxy:function(n,a,r,s,l,h,c){return et(this,null,function*(){let t=yield r.getArrayBuffer(a,n.rootDirectoryOffset,n.rootDirectoryLength,n);1===n.specVersion&&(t=jt(t));var e=Dt(new DataView(t),s,l,h);if(e){let t=(yield a.getBytes(e.offset,e.length,c)).data;const i=new DataView(t);return 31===i.getUint8(0)&&139===i.getUint8(1)&&(t=At(new Uint8Array(t))),{data:t}}e=((t,e)=>{if(t.byteLength<17)return null;var i=t.byteLength/17,t=qt(t,i-1);if(t.isDir){i=t.z,t=e.z-i;return{z:i,x:Math.trunc(e.x/(1<{t=Ot(t,128|e,i,o);return t?{z:e,x:i,y:o,offset:t[0],length:t[1],isDir:!0}:null})(new DataView(t),e.z,e.x,e.y);if(e){let t=yield r.getArrayBuffer(a,e.offset,e.length,n);1===n.specVersion&&(t=jt(t));e=Dt(new DataView(t),s,l,h);if(e){let t=(yield a.getBytes(e.offset,e.length,c)).data;const o=new DataView(t);return 31===o.getUint8(0)&&139===o.getUint8(1)&&(t=At(new Uint8Array(t))),{data:t}}}}})}};function Ht(t,e){return 4294967296*(e>>>0)+(t>>>0)}function Yt(t){var e=t.buf,i=e[t.pos++];let o=127&i;return i<128?o:(i=e[t.pos++],o|=(127&i)<<7,i<128?o:(i=e[t.pos++],o|=(127&i)<<14,i<128?o:(i=e[t.pos++],o|=(127&i)<<21,i<128?o:(i=e[t.pos],o|=(15&i)<<28,function(t,e){var i=e.buf,o=i[e.pos++];let n=(112&o)>>4;if(o<128)return Ht(t,n);if(o=i[e.pos++],n|=(127&o)<<3,o<128)return Ht(t,n);if(o=i[e.pos++],n|=(127&o)<<10,o<128)return Ht(t,n);if(o=i[e.pos++],n|=(127&o)<<17,o<128)return Ht(t,n);if(o=i[e.pos++],n|=(127&o)<<24,o<128)return Ht(t,n);if(o=i[e.pos++],n|=(1&o)<<31,o<128)return Ht(t,n);throw new Error("Expected varint not more than 10 bytes")}(o,t)))))}var Vt=[0,1,5,21,85,341,1365,5461,21845,87381,349525,1398101,5592405,22369621,89478485,357913941,1431655765,5726623061,22906492245,91625968981,366503875925,1466015503701,5864062014805,23456248059221,93824992236885,375299968947541,0x5555555555555];function Gt(i,o){return et(this,null,function*(){if(1===o||0===o)return i;if(2!==o)throw Error("Compression method not supported");{if(void 0===globalThis.DecompressionStream)return At(new Uint8Array(i));const e=new Response(i).body;if(!e)throw Error("Failed to read response stream");var t=e.pipeThrough(new globalThis.DecompressionStream("gzip"));return new Response(t).arrayBuffer()}})}var Xt=class{constructor(t,e=new Headers){this.url=t,this.customHeaders=e,this.mustReload=!1}getKey(){return this.url}setHeaders(t){this.customHeaders=t}getBytes(l,h,c,u){return et(this,null,function*(){let t,e;e=c||(t=new AbortController,t.signal);const i=new Headers(this.customHeaders);i.set("range",`bytes=${l}-`+(l+h-1));let o;this.mustReload&&(o="reload");let n=yield fetch(this.url,{signal:e,cache:o,headers:i});if(0===l&&416===n.status){const s=n.headers.get("Content-Range");if(!s||!s.startsWith("bytes */"))throw Error("Missing content-length on 416 response");var a=+s.substr(8);n=yield fetch(this.url,{signal:e,cache:"reload",headers:{range:"bytes=0-"+(a-1)}})}let r=n.headers.get("Etag");if(null!=r&&r.startsWith("W/")&&(r=null),416===n.status||u&&r&&r!==u)throw this.mustReload=!0,new Kt(`Server returned non-matching ETag ${u} after one retry. Check browser extensions and servers for issues that may affect correct ETag headers.`);if(300<=n.status)throw Error("Bad response code: "+n.status);a=n.headers.get("Content-Length");if(200===n.status&&(!a||h<+a))throw t&&t.abort(),Error("Server returned no content-length header or content-length exceeding request. Check that your storage backend supports HTTP Byte Serving.");return{data:yield n.arrayBuffer(),etag:r||void 0,cacheControl:n.headers.get("Cache-Control")||void 0,expires:n.headers.get("Expires")||void 0}})}};function $t(t,e){var i=t.getUint32(e+4,!0),e=t.getUint32(e+0,!0);return i*tt(2,32)+e}function Wt(t){var e={buf:new Uint8Array(t),pos:0},i=Yt(e);const o=[];let n=0;for(let t=0;t{Jt(o,this.decompress).then(t=>{t[1]&&this.cache.set(t[1][0],{lastUsed:this.counter++,data:Promise.resolve(t[1][2])}),e(t[0]),this.prune()}).catch(t=>{i(t)})});return this.cache.set(t,{lastUsed:this.counter++,data:i}),i})}getDirectory(o,n,a,r){return et(this,null,function*(){var t=`${o.getKey()}|${r.etag||""}|${n}|`+a;const e=this.cache.get(t);if(e)return e.lastUsed=this.counter++,yield e.data;var i=new Promise((e,i)=>{!function(e,i,o,n,a){return et(this,null,function*(){var t=yield e.getBytes(o,n,void 0,a.etag),t=Wt(yield i(t.data,a.internalCompression));if(0===t.length)throw new Error("Empty directory is invalid");return t})}(o,this.decompress,n,a,r).then(t=>{e(t),this.prune()}).catch(t=>{i(t)})});return this.cache.set(t,{lastUsed:this.counter++,data:i}),i})}getArrayBuffer(n,a,r,s){return et(this,null,function*(){const o=`${n.getKey()}|${s.etag||""}|${a}|`+r,t=this.cache.get(o);if(t)return t.lastUsed=this.counter++,yield t.data;var e=new Promise((e,i)=>{n.getBytes(a,r,void 0,s.etag).then(t=>{e(t.data),this.cache.has(o),this.prune()}).catch(t=>{i(t)})});return this.cache.set(o,{lastUsed:this.counter++,data:e}),e})}prune(){if(this.cache.size>=this.maxCacheEntries){let i=1/0,o=void 0;this.cache.forEach((t,e)=>{t.lastUsed{this.getHeader(n).then(t=>{e(),this.invalidations.delete(o)}).catch(t=>{i(t)})});this.invalidations.set(o,t)})}},te=class{constructor(t,e,i){this.source="string"==typeof t?new Xt(t):t,this.decompress=i||Gt,this.cache=e||new Qt}getHeader(){return et(this,null,function*(){return yield this.cache.getHeader(this.source)})}getZxyAttempt(t,e,i,s){return et(this,null,function*(){var o=function(t,e,i){if(26tt(2,t)-1||i>tt(2,t)-1)throw Error("tile x/y outside zoom level bounds");var o,n=Vt[t],t=tt(2,t);let a=0;var r,s,l,h=[e,i];let c=t/2;for(;0n.maxZoom)){let e=n.rootDirectoryOffset,i=n.rootDirectoryLength;for(let t=0;t<=3;t++){var a=function(t,e){let i=0,o=t.length-1;for(;i<=o;){var n=o+i>>1,a=e-t[n].tileId;if(0this._maxEntries;)this._split(o,e),e--;this._adjustParentBBoxes(i,o,e)}_split(t,e){const i=t[e];var o=i.children.length,n=this._minEntries;this._chooseSplitAxis(i,n,o);o=this._chooseSplitIndex(i,n,o);const a=pe(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,ae(i,this.toBBox),ae(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(i,a)}_splitRoot(t,e){this.data=pe([t,e]),this.data.height=t.height+1,this.data.leaf=!1,ae(this.data,this.toBBox)}_chooseSplitIndex(e,i,o){let n,a=1/0,r=1/0;for(let t=i;t<=o-i;t++){var s=re(e,0,t,this.toBBox),l=re(e,t,o,this.toBBox),h=(c=s,u=l,d=h=m=void 0,m=Math.max(c.minX,u.minX),h=Math.max(c.minY,u.minY),d=Math.min(c.maxX,u.maxX),u=Math.min(c.maxY,u.maxY),Math.max(0,d-m)*Math.max(0,u-h)),l=ce(s)+ce(l);h=i;t--){var h=e.children[t];se(r,e.leaf?n(h):h),s+=ue(r)}return s}_adjustParentBBoxes(e,i,o){for(let t=o;0<=t;t--)se(i[t],e)}_condense(i){for(let t=i.length-1,e;0<=t;t--)0===i[t].children.length?0=t.minX&&e.maxY>=t.minY}function pe(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function fe(t,e,i,o,n){const a=[e,i];for(;a.length;){var r;(i=a.pop())-(e=a.pop())<=o||(ee(t,r=e+Math.ceil((i-e)/o/2)*o,e,i,n),a.push(e,r,r,i))}}var ye=Object.defineProperty,_e=Math.pow,ge=(t,e)=>ye(t,"name",{value:e,configurable:!0}),be=(t,r,s)=>new Promise((e,i)=>{var o=t=>{try{a(s.next(t))}catch(t){i(t)}},n=t=>{try{a(s.throw(t))}catch(t){i(t)}},a=t=>t.done?e(t.value):Promise.resolve(t.value).then(o,n);a((s=s.apply(t,r)).next())}),xe=class{constructor(t,e){this.str=null!=t?t:e,this.perFeature="function"==typeof this.str&&2===this.str.length}get(t,e){return"function"==typeof this.str?this.str(t,e):this.str}};ge(xe,"StringAttr");var ve=xe,Le=class{constructor(t,e=1){this.value=null!=t?t:e,this.perFeature="function"==typeof this.value&&2===this.value.length}get(t,e){return"function"==typeof this.value?this.value(t,e):this.value}};ge(Le,"NumberAttr");var we=Le,Me=class{constructor(t){var e;this.labelProps=null!=(e=null==t?void 0:t.labelProps)?e:["name"],this.textTransform=null==t?void 0:t.textTransform}get(t,e){let i,o;o="function"==typeof this.labelProps?this.labelProps(t,e):this.labelProps;for(var n of o)if(Object.prototype.hasOwnProperty.call(e.props,n)&&"string"==typeof e.props[n]){i=e.props[n];break}let a;return a="function"==typeof this.textTransform?this.textTransform(t,e):this.textTransform,i&&"uppercase"===a?i=i.toUpperCase():i&&"lowercase"===a?i=i.toLowerCase():i&&"capitalize"===a&&(i=i.toLowerCase().split(" ").map(t=>t[0].toUpperCase()+t.slice(1)).join(" ")),i}};ge(Me,"TextAttr");var Ce=Me,Se=class{constructor(t){var e;null!=t&&t.font?this.font=t.font:(this.family=null!=(e=null==t?void 0:t.fontFamily)?e:"sans-serif",this.size=null!=(e=null==t?void 0:t.fontSize)?e:12,this.weight=null==t?void 0:t.fontWeight,this.style=null==t?void 0:t.fontStyle)}get(t,e){if(this.font)return"function"==typeof this.font?this.font(t,e):this.font;let i="";this.style&&(i="function"==typeof this.style?this.style(t,e)+" ":this.style+" ");let o="";this.weight&&(o="function"==typeof this.weight?this.weight(t,e)+" ":this.weight+" ");let n;n="function"==typeof this.size?this.size(t,e):this.size;let a;return a="function"==typeof this.family?this.family(t,e):this.family,""+i+o+n+"px "+a}};ge(Se,"FontAttr");var Te=Se,Ee=class{constructor(t,e=[]){this.value=null!=t?t:e,this.perFeature="function"==typeof this.value&&2===this.value.length}get(t,e){return"function"==typeof this.value?this.value(t,e):this.value}};ge(Ee,"ArrayAttr");var ke=Ee,ze=ge((t,e,i)=>{let o=[],n,a,r,s=0,l,h=0,c=0,u=0,m,d,p,f,y=0,_=0;if(t.length<2)return[];if(2===t.length)return h=Math.sqrt(_e(t[1].x-t[0].x,2)+_e(t[1].y-t[0].y,2)),[{length:h,beginIndex:0,beginDistance:0,endIndex:2,endDistance:h}];for(c=Math.sqrt(_e(t[1].x-t[0].x,2)+_e(t[1].y-t[0].y,2)),s=1,l=t.length-1;si)&&(o.push({length:h-_,beginDistance:_,beginIndex:y,endIndex:s+1,endDistance:h}),y=s,_=h),c=u;return 0=o+a){let e=new C(s[l.beginIndex].x,s[l.beginIndex].y),t=s[l.endIndex-1],i=new C((t.x-e.x)/l.length,(t.y-e.y)/l.length);for(let t=a;t{t.pos=e;let o=t.readVarint()+t.pos,n=1,a=0,r=0,s=0,l=1/0,h=-1/0,c=1/0,u=-1/0,m=[],d=[];for(;t.pos>3),a--,1===n||2===n)r+=t.readSVarint()*i,s+=t.readSVarint()*i,rh&&(h=r),su&&(u=s),1===n&&(0t.z===e.z||(t.controller.abort(),!1)));var t=new AbortController;this.zoomaborts.push({z:e.z,controller:t});t=t.signal,t=yield this.p.getZxy(e.z,e.x,e.y,t);return t?De(t.data,i):new Map})}};ge(Oe,"PmtilesSource");var Ne=Oe,qe=class{constructor(t,e){this.url=t,this.zoomaborts=[],this.shouldCancelZooms=e}get(i,n){return be(this,null,function*(){this.shouldCancelZooms&&(this.zoomaborts=this.zoomaborts.filter(t=>t.z===i.z||(t.controller.abort(),!1)));let t=this.url.replace("{z}",i.z.toString()).replace("{x}",i.x.toString()).replace("{y}",i.y.toString()),e=new AbortController;this.zoomaborts.push({z:i.z,controller:e});let o=e.signal;return new Promise((e,i)=>{fetch(t,{signal:o}).then(t=>t.arrayBuffer()).then(t=>{t=De(t,n);e(t)}).catch(t=>{i(t)})})})}};ge(qe,"ZxySource");var je=qe,Ue=6378137,Ze=85.0511287798,He=Ue*Math.PI,Ye=ge(t=>{var e=Math.PI/180,i=Math.max(Math.min(Ze,t[0]),-Ze),i=Math.sin(i*e);return new C(Ue*t[1]*e,Ue*Math.log((1+i)/(1-i))/2)},"project");function Ve(t){return t*t}function Ge(t,e){return Ve(t.x-e.x)+Ve(t.y-e.y)}function Xe(t,e,i){var o=Ge(e,i);if(0===o)return Ge(t,e);o=((t.x-e.x)*(i.x-e.x)+(t.y-e.y)*(i.y-e.y))/o,o=Math.max(0,Math.min(1,o));return Ge(t,new C(e.x+o*(i.x-e.x),e.y+o*(i.y-e.y)))}function $e(i,o){let n=!1;for(let t=0,e=o.length-1;ti.y!=l>i.y&&i.x<(s-a)*(i.y-r)/(l-r)+a&&(n=!n)}return n}function We(e){let i=0;for(let t=0;t{let t=this.cache.get(a);if(t)t.used=performance.now(),o(t.data);else{let t=this.inflight.get(a);t?t.push({resolve:o,reject:n}):(this.inflight.set(a,[]),this.source.get(e,this.tileSize).then(t=>{this.cache.set(a,{used:performance.now(),data:t});var e=this.inflight.get(a);if(e)for(var i of e)i.resolve(t);if(this.inflight.delete(a),o(t),64<=this.cache.size){let i=1/0,o;this.cache.forEach((t,e)=>{t.used{var e=this.inflight.get(a);if(e)for(var i of e)i.reject(t);this.inflight.delete(a),n(t)}))}})})}queryFeatures(t,e,i,o){let n=Ye([e,t]),a=new C((n.x+He)/(2*He),1-(n.y+He)/(2*He));1{let o=document.createElement("canvas"),n=o.getContext("2d");return o.width=t,o.height=e,null!==n&&i(o,n),o},"createPattern"),ai=class{constructor(t){this.pattern=t.pattern,this.fill=new ve(t.fill,"black"),this.opacity=new we(t.opacity,1),this.stroke=new ve(t.stroke,"black"),this.width=new we(t.width,0),this.perFeature=null!=(t=this.fill.perFeature||this.opacity.perFeature||this.stroke.perFeature||this.width.perFeature||t.perFeature)&&t,this.doStroke=!1}before(t,e){var i;this.perFeature||(t.globalAlpha=this.opacity.get(e),t.fillStyle=this.fill.get(e),t.strokeStyle=this.stroke.get(e),0<(i=this.width.get(e))&&(this.doStroke=!0),t.lineWidth=i),!this.pattern||(i=t.createPattern(this.pattern,"repeat"))&&(t.fillStyle=i)}draw(e,t,i,o){let n=!1;var a,r;this.perFeature&&(e.globalAlpha=this.opacity.get(i,o),e.fillStyle=this.fill.get(i,o),(a=this.width.get(i,o))&&(n=!0,e.strokeStyle=this.stroke.get(i,o),e.lineWidth=a));let s=ge(()=>{e.fill(),(n||this.doStroke)&&e.stroke()},"drawPath");e.beginPath();for(r of t)for(let t=0;t{t-=e;return 0<=t&&t{if(o.length<1)return 0;if(t<=o[0][0])return o[0][1];if(t>=o[o.length-1][0])return o[o.length-1][1];var e=li(t,o);return hi(ci(t,e,i,o),o[e][1],o[e+1][1])}}function mi(t,o){return e=>{if(o.length<1)return 0;let i=t;for(let t=0;t=o[t][0]&&(i=o[t][1]);return i}}function di(t){return ui(1,t)}ge(si,"arr"),ge(li,"getStopIndex"),ge(hi,"interpolate"),ge(ci,"computeInterpolationFactor"),ge(ui,"exp"),ge(mi,"step"),ge(di,"linear");var pi=class{constructor(t){var e;this.color=new ve(t.color,"black"),this.width=new we(t.width),this.opacity=new we(t.opacity),this.dash=t.dash?new ke(t.dash):null,this.dashColor=new ve(t.dashColor,"black"),this.dashWidth=new we(t.dashWidth,1),this.lineCap=new ve(t.lineCap,"butt"),this.lineJoin=new ve(t.lineJoin,"miter"),this.skip=!1,this.perFeature=!!(null!=(e=this.dash)&&e.perFeature||this.color.perFeature||this.opacity.perFeature||this.width.perFeature||this.lineCap.perFeature||this.lineJoin.perFeature||t.perFeature)}before(t,e){this.perFeature||(t.strokeStyle=this.color.get(e),t.lineWidth=this.width.get(e),t.globalAlpha=this.opacity.get(e),t.lineCap=this.lineCap.get(e),t.lineJoin=this.lineJoin.get(e))}draw(e,i,o,n){if(!this.skip){let t=ge(()=>{this.perFeature&&(e.globalAlpha=this.opacity.get(o,n),e.lineCap=this.lineCap.get(o,n),e.lineJoin=this.lineJoin.get(o,n)),this.dash?(e.save(),this.perFeature?(e.lineWidth=this.dashWidth.get(o,n),e.strokeStyle=this.dashColor.get(o,n),e.setLineDash(this.dash.get(o,n))):e.setLineDash(this.dash.get(o))):(e.save(),this.perFeature&&(e.lineWidth=this.width.get(o,n),e.strokeStyle=this.color.get(o,n))),e.stroke(),e.restore()},"strokePath");e.beginPath();for(var a of i)for(let t=0;t{t.globalAlpha=1,t.drawImage(this.sheet.canvas,n.x,n.y,n.w,n.h,-n.w/2/this.dpr,-n.h/2/this.dpr,n.w/2,n.h/2)},"draw")}]}};ge(yi,"IconSymbolizer");var _i=yi,gi=class{constructor(t){this.radius=new we(t.radius,3),this.fill=new ve(t.fill,"black"),this.stroke=new ve(t.stroke,"white"),this.width=new we(t.width,0),this.opacity=new we(t.opacity)}draw(t,e,i,o){t.globalAlpha=this.opacity.get(i,o);var n=this.radius.get(i,o),a=this.width.get(i,o);0{this.draw(t,[[new C(0,0)]],e.zoom,i)},"draw")}]}};ge(gi,"CircleSymbolizer");var bi=gi,xi=class{constructor(t){this.font=new Te(t),this.text=new Ce(t),this.fill=new ve(t.fill,"black"),this.background=new ve(t.background,"white"),this.padding=new we(t.padding,0)}place(l,h,c){let u=this.text.get(l.zoom,c);if(u){let e=this.font.get(l.zoom,c);l.scratch.font=e;let t=l.scratch.measureText(u),i=t.width,o=t.actualBoundingBoxAscent,n=t.actualBoundingBoxDescent;h[0];let a=new C(h[0][0].x,h[0][0].y),r=this.padding.get(l.zoom,c),s={minX:a.x-i/2-r,minY:a.y-o-r,maxX:a.x+i/2+r,maxY:a.y+n+r};return[{anchor:a,bboxes:[s],draw:ge(t=>{t.globalAlpha=1,t.fillStyle=this.background.get(l.zoom,c),t.fillRect(-i/2-r,-o-r,i+2*r,o+n+2*r),t.fillStyle=this.fill.get(l.zoom,c),t.font=e,t.fillText(u,-i/2,0)},"draw")}]}}};ge(xi,"ShieldSymbolizer");var vi=xi,Li=class{constructor(t){this.list=t}place(r,s,l){var h=this.list[0].place(r,s,l);if(h){let e=h[0],t=e.anchor,i=e.bboxes[0],o=i.maxY-i.minY,n=[{draw:e.draw,translate:{x:0,y:0}}],a=[[new C(s[0][0].x,s[0][0].y+o)]];for(let t=1;t{for(var e of n)t.save(),t.translate(e.translate.x,e.translate.y),e.draw(t),t.restore()},"draw")}]}}};ge(Li,"FlexSymbolizer");var wi=Li,Mi=ge((t,e)=>({minX:Math.min(t.minX,e.minX),minY:Math.min(t.minY,e.minY),maxX:Math.max(t.maxX,e.maxX),maxY:Math.max(t.maxY,e.maxY)}),"mergeBbox"),Ci=class{constructor(t){this.list=t}place(n,a,r){let t=this.list[0];if(t){var s=t.place(n,a,r);if(s){let e=s[0],t=e.anchor,i=e.bboxes[0],o=[e.draw];for(let t=1;t{for(var e of o)e(t)},"draw")}]}}}};ge(Ci,"GroupSymbolizer");var Si=Ci,Ti=class{constructor(t){this.symbolizer=t}place(t,a,r){a=a[0][0],r=this.symbolizer.place(t,[[new C(0,0)]],r);if(r&&0!==r.length){let e=r[0],i=e.bboxes[0],o=i.maxX-i.minX,n=i.maxY-i.minY,t={minX:a.x-o/2,maxX:a.x+o/2,minY:a.y-n/2,maxY:a.y+n/2};return[{anchor:a,bboxes:[t],draw:ge(t=>{t.translate(-o/2,n/2-i.maxY),e.draw(t,{justify:2})},"draw")}]}}};ge(Ti,"CenteredSymbolizer");var Ei=Ti,ki=class{constructor(t,e){this.padding=new we(t,0),this.symbolizer=e}place(t,e,i){e=this.symbolizer.place(t,e,i);if(e&&0!==e.length){var o,n=this.padding.get(t.zoom,i);for(o of e)for(var a of o.bboxes)a.minX-=n,a.minY-=n,a.maxX+=n,a.maxY+=n;return e}}};ge(ki,"Padding");var zi=ki,Ai=class{constructor(t){this.font=new Te(t),this.text=new Ce(t),this.fill=new ve(t.fill,"black"),this.stroke=new ve(t.stroke,"black"),this.width=new we(t.width,0),this.lineHeight=new we(t.lineHeight,1),this.letterSpacing=new we(t.letterSpacing,0),this.maxLineCodeUnits=new we(t.maxLineChars,15),this.justify=t.justify}place(m,d,p){var f=this.text.get(m.zoom,p);if(f){let e=this.font.get(m.zoom,p);m.scratch.font=e;let l=this.letterSpacing.get(m.zoom,p),h=Pe(f,this.maxLineCodeUnits.get(m.zoom,p)),t="",i=0;for(var y of h)y.length>i&&(i=y.length,t=y);let o=m.scratch.measureText(t),c=o.width+l*(i-1),n=o.actualBoundingBoxAscent,a=o.actualBoundingBoxDescent,u=(n+a)*this.lineHeight.get(m.zoom,p),r=new C(d[0][0].x,d[0][0].y),s={minX:r.x,minY:r.y-n,maxX:r.x+c,maxY:r.y+a+(h.length-1)*u};return[{anchor:r,bboxes:[s],draw:ge((i,t)=>{i.globalAlpha=1,i.font=e,i.fillStyle=this.fill.get(m.zoom,p);let o=this.width.get(m.zoom,p),n=0;for(var a of h){let e=0;if(2===this.justify||t&&2===t.justify?e=(c-i.measureText(a).width)/2:(3===this.justify||t&&3===t.justify)&&(e=c-i.measureText(a).width),o)if(i.lineWidth=2*o,i.strokeStyle=this.stroke.get(m.zoom,p),0({})}place(b,t,x){if(1===x.geomType){let _=t[0][0],g=this.symbolizer.place(b,[[new C(0,0)]],x);if(g&&0!==g.length){let e=g[0],i=e.bboxes[0],t=this.offsetX,o=this.offsetY,n=this.justify,a=this.placements,{offsetX:r,offsetY:s,justify:l,placements:h}=this.ddValues(b.zoom,x)||{};r&&(t=new we(r,0)),s&&(o=new we(s,0)),l&&(n=l),h&&(a=h);let c=t.get(b.zoom,x),u=o.get(b.zoom,x),m=ge((t,e)=>({minX:t.x+e.x+i.minX,minY:t.y+e.y+i.minY,maxX:t.x+e.x+i.maxX,maxY:t.y+e.y+i.maxY}),"getBbox"),d=new C(c,u),p,f=ge(t=>{t.translate(d.x,d.y),e.draw(t,{justify:p})},"draw"),y=ge((t,e)=>{e=m(t,e);if(!b.index.bboxCollides(e,b.order))return[{anchor:_,bboxes:[e],draw:f}]},"placeLabelInPoint");for(var v of a){var L=this.computeXaxisOffset(c,i,v),w=this.computeYaxisOffset(u,i,v);return p=this.computeJustify(n,v),d=new C(L,w),y(_,d)}}}}computeXaxisOffset(t,e,i){var o=e.maxX,e=o/2;return[1,5].includes(i)?t-e:[8,7,6].includes(i)?t-o:t}computeYaxisOffset(t,e,i){var o=Math.abs(e.minY),n=e.maxY,e=(e.minY+e.maxY)/2;return[3,7].includes(i)?t-e:[8,2,1].includes(i)?t-n:[6,4,5].includes(i)?t+o:t}computeJustify(t,e){return t||([1,5].includes(e)?2:[2,3,4].includes(e)?1:3)}};ge(Fi,"OffsetSymbolizer");var Ri=Fi,Di=class{constructor(t){this.symbolizer=new Ri(new Ii(t),t)}place(t,e,i){return this.symbolizer.place(t,e,i)}};ge(Di,"OffsetTextSymbolizer");var Oi=Di,lt=((Ao={})[Ao.Above=1]="Above",Ao[Ao.Center=2]="Center",Ao[Ao.Below=3]="Below",Ao),It=class{constructor(t){var e;this.font=new Te(t),this.text=new Ce(t),this.fill=new ve(t.fill,"black"),this.stroke=new ve(t.stroke,"black"),this.width=new we(t.width,0),this.offset=new we(t.offset,0),this.position=null!=(e=t.position)?e:1,this.maxLabelCodeUnits=new we(t.maxLabelChars,40),this.repeatDistance=new we(t.repeatDistance,250)}place(c,i,u){let m=this.text.get(c.zoom,u);if(m&&!(m.length>this.maxLabelCodeUnits.get(c.zoom,u))){var t=u.bbox;if(!(t.maxY-t.minY<20&&t.maxX-t.minX<20)){let a=this.font.get(c.zoom,u);c.scratch.font=a;let t=c.scratch.measureText(m),r=t.width,s=t.actualBoundingBoxAscent+t.actualBoundingBoxDescent,l=this.repeatDistance.get(c.zoom,u);4({minX:t.x-h/2,minY:t.y-h/2,maxX:t.x+h/2,maxY:t.y+h/2})),e=ge(t=>{t.globalAlpha=1,t.rotate(Math.atan2(n,o)),o<0&&(t.scale(-1,-1),t.translate(-r,0));let e=0;3===this.position?e+=s:2===this.position&&(e+=s/2),t.translate(0,e-this.offset.get(c.zoom,u)),t.font=a;var i=this.width.get(c.zoom,u);i&&(t.lineWidth=i,t.strokeStyle=this.stroke.get(c.zoom,u),t.strokeText(m,0,0)),t.fillStyle=this.fill.get(c.zoom,u),t.fillText(m,0,0)},"draw");i.push({anchor:d.start,bboxes:t,draw:e,deduplicationKey:m,deduplicationDistance:l})}return i}}}}};ge(It,"LineLabelSymbolizer");var Ni=It,qi=ge((t,e)=>{e=t[e];return"string"==typeof e?e:""},"getString"),ji=ge((t,e)=>{e=t[e];return"number"==typeof e?e:0},"getNumber"),Ui=ge(i=>[{dataLayer:"earth",symbolizer:new ri({fill:i.earth})},{dataLayer:"landuse",symbolizer:new ri({fill:ge((t,e)=>A(i.park_a,i.park_b,Math.min(Math.max(t/12,12),0)),"fill")}),filter:ge((t,e)=>{e=qi(e.props,"pmap:kind");return["allotments","village_green","playground"].includes(e)},"filter")},{dataLayer:"landuse",symbolizer:new ri({fill:i.park_b,opacity:.7}),filter:ge((t,e)=>{e=qi(e.props,"pmap:kind");return["national_park","park","cemetery","protected_area","nature_reserve","forest","golf_course"].includes(e)},"filter")},{dataLayer:"landuse",symbolizer:new ri({fill:i.hospital}),filter:ge((t,e)=>"hospital"===e.props["pmap:kind"],"filter")},{dataLayer:"landuse",symbolizer:new ri({fill:i.industrial}),filter:ge((t,e)=>"industrial"===e.props["pmap:kind"],"filter")},{dataLayer:"landuse",symbolizer:new ri({fill:i.school}),filter:ge((t,e)=>{e=qi(e.props,"pmap:kind");return["school","university","college"].includes(e)},"filter")},{dataLayer:"landuse",symbolizer:new ri({fill:i.beach}),filter:ge((t,e)=>"beach"===e.props["pmap:kind"],"filter")},{dataLayer:"landuse",symbolizer:new ri({fill:i.zoo}),filter:ge((t,e)=>"zoo"===e.props["pmap:kind"],"filter")},{dataLayer:"landuse",symbolizer:new ri({fill:i.zoo}),filter:ge((t,e)=>{e=qi(e.props,"pmap:kind");return["military","naval_base","airfield"].includes(e)},"filter")},{dataLayer:"natural",symbolizer:new ri({fill:ge((t,e)=>A(i.wood_a,i.wood_b,Math.min(Math.max(t/12,12),0)),"fill")}),filter:ge((t,e)=>{e=qi(e.props,"pmap:kind");return["wood","nature_reserve","forest"].includes(e)},"filter")},{dataLayer:"natural",symbolizer:new ri({fill:ge((t,e)=>A(i.scrub_a,i.scrub_b,Math.min(Math.max(t/12,12),0)),"fill")}),filter:ge((t,e)=>{e=qi(e.props,"pmap:kind");return["scrub","grassland","grass"].includes(e)},"filter")},{dataLayer:"natural",symbolizer:new ri({fill:i.scrub_b}),filter:ge((t,e)=>{e=qi(e.props,"pmap:kind");return["scrub","grassland","grass"].includes(e)},"filter")},{dataLayer:"natural",symbolizer:new ri({fill:i.glacier}),filter:ge((t,e)=>"glacier"===e.props["pmap:kind"],"filter")},{dataLayer:"natural",symbolizer:new ri({fill:i.sand}),filter:ge((t,e)=>"sand"===e.props["pmap:kind"],"filter")},{dataLayer:"landuse",symbolizer:new ri({fill:i.aerodrome}),filter:ge((t,e)=>"aerodrome"===e.props["pmap:kind"],"filter")},{dataLayer:"water",symbolizer:new ri({fill:i.water})},{dataLayer:"transit",symbolizer:new fi({color:i.runway,width:ge((t,e)=>ui(1.6,[[11,0],[13,4],[19,30]])(t),"width")}),filter:ge((t,e)=>"runway"===e.props["pmap:kind_detail"],"filter")},{dataLayer:"transit",symbolizer:new fi({color:i.runway,width:ge((t,e)=>ui(1.6,[[14,0],[14.5,1],[16,6]])(t),"width")}),filter:ge((t,e)=>"taxiway"===e.props["pmap:kind_detail"],"filter")},{dataLayer:"transit",symbolizer:new fi({color:i.pier,width:ge((t,e)=>ui(1.6,[[13,0],[13.5,0,5],[21,16]])(t),"width")}),filter:ge((t,e)=>"pier"===e.props["pmap:kind"],"filter")},{dataLayer:"physical_line",minzoom:14,symbolizer:new fi({color:i.water,width:ge((t,e)=>ui(1.6,[[9,0],[9.5,1],[18,12]])(t),"width")}),filter:ge((t,e)=>"river"===e.props["pmap:kind"],"filter")},{dataLayer:"physical_line",minzoom:14,symbolizer:new fi({color:i.water,width:.5}),filter:ge((t,e)=>"stream"===e.props["pmap:kind"],"filter")},{dataLayer:"landuse",symbolizer:new ri({fill:i.pedestrian}),filter:ge((t,e)=>"pedestrian"===e.props["pmap:kind"],"filter")},{dataLayer:"landuse",symbolizer:new ri({fill:i.pier}),filter:ge((t,e)=>"pier"===e.props["pmap:kind"],"filter")},{dataLayer:"buildings",symbolizer:new ri({fill:i.buildings,opacity:.5})},{dataLayer:"roads",symbolizer:new fi({color:i.major,width:ge((t,e)=>ui(1.6,[[14,0],[20,7]])(t),"width")}),filter:ge((t,e)=>{e=qi(e.props,"pmap:kind");return["other","path"].includes(e)},"filter")},{dataLayer:"roads",symbolizer:new fi({color:i.major,width:ge((t,e)=>ui(1.6,[[13,0],[18,8]])(t),"width")}),filter:ge((t,e)=>"minor_road"===e.props["pmap:kind"],"filter")},{dataLayer:"roads",symbolizer:new fi({color:i.major,width:ge((t,e)=>ui(1.6,[[7,0],[12,1.2],[15,3],[18,13]])(t),"width")}),filter:ge((t,e)=>"medium_road"===e.props["pmap:kind"],"filter")},{dataLayer:"roads",symbolizer:new fi({color:i.major,width:ge((t,e)=>ui(1.6,[[6,0],[12,1.6],[15,3],[18,13]])(t),"width")}),filter:ge((t,e)=>"major_road"===e.props["pmap:kind"],"filter")},{dataLayer:"roads",symbolizer:new fi({color:i.major,width:ge((t,e)=>ui(1.6,[[3,0],[6,1.1],[12,1.6],[15,5],[18,15]])(t),"width")}),filter:ge((t,e)=>"highway"===e.props["pmap:kind"],"filter")},{dataLayer:"boundaries",symbolizer:new fi({dash:[3,2],color:i.boundaries,width:1}),filter:ge((t,e)=>{e=e.props["pmap:min_admin_level"];return"number"==typeof e&&e<=2},"filter")},{dataLayer:"transit",symbolizer:new fi({dash:[.3,.75],color:i.railway,dashWidth:ge((t,e)=>ui(1.6,[[4,0],[7,.15],[19,9]])(t),"dashWidth"),opacity:.5}),filter:ge((t,e)=>"rail"===e.props["pmap:kind"],"filter")},{dataLayer:"boundaries",symbolizer:new fi({dash:[3,2],color:i.boundaries,width:.5}),filter:ge((t,e)=>{e=e.props["pmap:min_admin_level"];return"number"==typeof e&&2{let i=["name"];return[{dataLayer:"roads",symbolizer:new Ni({labelProps:i,fill:t.roads_label_minor,font:"400 12px sans-serif",width:2,stroke:t.roads_label_minor_halo}),minzoom:16,filter:ge((t,e)=>{e=qi(e.props,"pmap:kind");return["minor_road","other","path"].includes(e)},"filter")},{dataLayer:"roads",symbolizer:new Ni({labelProps:i,fill:t.roads_label_major,font:"400 12px sans-serif",width:2,stroke:t.roads_label_major_halo}),minzoom:12,filter:ge((t,e)=>{e=qi(e.props,"pmap:kind");return["highway","major_road","medium_road"].includes(e)},"filter")},{dataLayer:"roads",symbolizer:new Ni({labelProps:i,fill:t.roads_label_major,font:"400 12px sans-serif",width:2,stroke:t.roads_label_major_halo}),minzoom:12,filter:ge((t,e)=>{e=qi(e.props,"pmap:kind");return["highway","major_road","medium_road"].includes(e)},"filter")},{dataLayer:"physical_point",symbolizer:new Bi({labelProps:i,fill:t.ocean_label,lineHeight:1.5,letterSpacing:1,font:ge((t,e)=>`400 ${di([[3,10],[10,12]])(t)}px sans-serif`,"font"),textTransform:"uppercase"}),filter:ge((t,e)=>{e=qi(e.props,"pmap:kind");return["ocean","bay","strait","fjord"].includes(e)},"filter")},{dataLayer:"physical_point",symbolizer:new Bi({labelProps:i,fill:t.ocean_label,lineHeight:1.5,letterSpacing:1,font:ge((t,e)=>`400 ${di([[3,0],[6,12],[10,12]])(t)}px sans-serif`,"font")}),filter:ge((t,e)=>{e=qi(e.props,"pmap:kind");return["sea","lake","water"].includes(e)},"filter")},{dataLayer:"places",symbolizer:new Bi({labelProps:ge((t,e)=>t<6?["name:short"]:i,"labelProps"),fill:t.state_label,stroke:t.state_label_halo,width:1,lineHeight:1.5,font:ge((t,e)=>t<6?"400 16px sans-serif":"400 12px sans-serif","font"),textTransform:"uppercase"}),filter:ge((t,e)=>"region"===e.props["pmap:kind"],"filter")},{dataLayer:"places",symbolizer:new Bi({labelProps:i,fill:t.country_label,lineHeight:1.5,font:ge((t,e)=>"600 12px sans-serif","font"),textTransform:"uppercase"}),filter:ge((t,e)=>"country"===e.props["pmap:kind"],"filter")},{dataLayer:"places",minzoom:9,symbolizer:new Bi({labelProps:i,fill:t.city_label,lineHeight:1.5,font:ge((t,e)=>{if(!e)return"400 12px sans-serif";let i=e.props["pmap:min_zoom"],o=400;i&&i<=5&&(o=600);let n=12,a=e.props["pmap:population_rank"];return a&&9{return ji(t,"pmap:population_rank")-ji(e,"pmap:population_rank")},"sort"),filter:ge((t,e)=>"locality"===e.props["pmap:kind"],"filter")},{dataLayer:"places",maxzoom:8,symbolizer:new Si([new bi({radius:2,fill:t.city_circle,stroke:t.city_circle_stroke,width:1.5}),new Oi({labelProps:i,fill:t.city_label,stroke:t.city_label_halo,width:1,offsetX:6,offsetY:4.5,font:ge((t,e)=>"400 12px sans-serif","font")})]),filter:ge((t,e)=>"locality"===e.props["pmap:kind"],"filter")}]},"labelRules"),Hi={light:{background:"#cccccc",earth:"#e0e0e0",park_a:"#cfddd5",park_b:"#9cd3b4",hospital:"#e4dad9",industrial:"#d1dde1",school:"#e4ded7",wood_a:"#d0ded0",wood_b:"#a0d9a0",pedestrian:"#e3e0d4",scrub_a:"#cedcd7",scrub_b:"#99d2bb",glacier:"#e7e7e7",sand:"#e2e0d7",beach:"#e8e4d0",aerodrome:"#dadbdf",runway:"#e9e9ed",water:"#80deea",pier:"#e0e0e0",zoo:"#c6dcdc",military:"#dcdcdc",tunnel_other_casing:"#e0e0e0",tunnel_minor_casing:"#e0e0e0",tunnel_link_casing:"#e0e0e0",tunnel_medium_casing:"#e0e0e0",tunnel_major_casing:"#e0e0e0",tunnel_highway_casing:"#e0e0e0",tunnel_other:"#d5d5d5",tunnel_minor:"#d5d5d5",tunnel_link:"#d5d5d5",tunnel_medium:"#d5d5d5",tunnel_major:"#d5d5d5",tunnel_highway:"#d5d5d5",transit_pier:"#e0e0e0",buildings:"#cccccc",minor_service_casing:"#e0e0e0",minor_casing:"#e0e0e0",link_casing:"#e0e0e0",medium_casing:"#e0e0e0",major_casing_late:"#e0e0e0",highway_casing_late:"#e0e0e0",other:"#ebebeb",minor_service:"#ebebeb",minor_a:"#ebebeb",minor_b:"#ffffff",link:"#ffffff",medium:"#f5f5f5",major_casing_early:"#e0e0e0",major:"#ffffff",highway_casing_early:"#e0e0e0",highway:"#ffffff",railway:"#a7b1b3",boundaries:"#adadad",waterway_label:"#ffffff",bridges_other_casing:"#e0e0e0",bridges_minor_casing:"#e0e0e0",bridges_link_casing:"#e0e0e0",bridges_medium_casing:"#e0e0e0",bridges_major_casing:"#e0e0e0",bridges_highway_casing:"#e0e0e0",bridges_other:"#ebebeb",bridges_minor:"#ffffff",bridges_link:"#ffffff",bridges_medium:"#f0eded",bridges_major:"#f5f5f5",bridges_highway:"#ffffff",roads_label_minor:"#91888b",roads_label_minor_halo:"#ffffff",roads_label_major:"#938a8d",roads_label_major_halo:"#ffffff",ocean_label:"#ffffff",peak_label:"#7e9aa0",subplace_label:"#8f8f8f",subplace_label_halo:"#e0e0e0",city_circle:"#ffffff",city_circle_stroke:"#a3a3a3",city_label:"#5c5c5c",city_label_halo:"#e0e0e0",state_label:"#b3b3b3",state_label_halo:"#e0e0e0",country_label:"#a3a3a3"},dark:{background:"#34373d",earth:"#1f1f1f",park_a:"#232325",park_b:"#232325",hospital:"#252424",industrial:"#222222",school:"#262323",wood_a:"#202121",wood_b:"#202121",pedestrian:"#1e1e1e",scrub_a:"#222323",scrub_b:"#222323",glacier:"#1c1c1c",sand:"#212123",beach:"#28282a",aerodrome:"#1e1e1e",runway:"#333333",water:"#34373d",pier:"#222222",zoo:"#222323",military:"#242323",tunnel_other_casing:"#141414",tunnel_minor_casing:"#141414",tunnel_link_casing:"#141414",tunnel_medium_casing:"#141414",tunnel_major_casing:"#141414",tunnel_highway_casing:"#141414",tunnel_other:"#292929",tunnel_minor:"#292929",tunnel_link:"#292929",tunnel_medium:"#292929",tunnel_major:"#292929",tunnel_highway:"#292929",transit_pier:"#333333",buildings:"#111111",minor_service_casing:"#1f1f1f",minor_casing:"#1f1f1f",link_casing:"#1f1f1f",medium_casing:"#1f1f1f",major_casing_late:"#1f1f1f",highway_casing_late:"#1f1f1f",other:"#333333",minor_service:"#333333",minor_a:"#3d3d3d",minor_b:"#333333",link:"#3d3d3d",medium:"#3d3d3d",major_casing_early:"#1f1f1f",major:"#3d3d3d",highway_casing_early:"#1f1f1f",highway:"#474747",railway:"#000000",boundaries:"#5b6374",waterway_label:"#717784",bridges_other_casing:"#2b2b2b",bridges_minor_casing:"#1f1f1f",bridges_link_casing:"#1f1f1f",bridges_medium_casing:"#1f1f1f",bridges_major_casing:"#1f1f1f",bridges_highway_casing:"#1f1f1f",bridges_other:"#333333",bridges_minor:"#333333",bridges_link:"#3d3d3d",bridges_medium:"#3d3d3d",bridges_major:"#3d3d3d",bridges_highway:"#474747",roads_label_minor:"#525252",roads_label_minor_halo:"#1f1f1f",roads_label_major:"#666666",roads_label_major_halo:"#1f1f1f",ocean_label:"#717784",peak_label:"#898080",subplace_label:"#525252",subplace_label_halo:"#1f1f1f",city_circle:"#000000",city_circle_stroke:"#7a7a7a",city_label:"#7a7a7a",city_label_halo:"#212121",state_label:"#3d3d3d",state_label_halo:"#1f1f1f",country_label:"#5c5c5c"},white:{background:"#ffffff",earth:"#ffffff",park_a:"#fcfcfc",park_b:"#fcfcfc",hospital:"#f8f8f8",industrial:"#fcfcfc",school:"#f8f8f8",wood_a:"#fafafa",wood_b:"#fafafa",pedestrian:"#fdfdfd",scrub_a:"#fafafa",scrub_b:"#fafafa",glacier:"#fcfcfc",sand:"#fafafa",beach:"#f6f6f6",aerodrome:"#fdfdfd",runway:"#efefef",water:"#dcdcdc",pier:"#f5f5f5",zoo:"#f7f7f7",military:"#fcfcfc",tunnel_other_casing:"#d6d6d6",tunnel_minor_casing:"#fcfcfc",tunnel_link_casing:"#fcfcfc",tunnel_medium_casing:"#fcfcfc",tunnel_major_casing:"#fcfcfc",tunnel_highway_casing:"#fcfcfc",tunnel_other:"#d6d6d6",tunnel_minor:"#d6d6d6",tunnel_link:"#d6d6d6",tunnel_medium:"#d6d6d6",tunnel_major:"#d6d6d6",tunnel_highway:"#d6d6d6",transit_pier:"#efefef",buildings:"#efefef",minor_service_casing:"#ffffff",minor_casing:"#ffffff",link_casing:"#ffffff",medium_casing:"#ffffff",major_casing_late:"#ffffff",highway_casing_late:"#ffffff",other:"#f5f5f5",minor_service:"#f5f5f5",minor_a:"#ebebeb",minor_b:"#f5f5f5",link:"#ebebeb",medium:"#ebebeb",major_casing_early:"#ffffff",major:"#ebebeb",highway_casing_early:"#ffffff",highway:"#ebebeb",railway:"#d6d6d6",boundaries:"#adadad",waterway_label:"#adadad",bridges_other_casing:"#ffffff",bridges_minor_casing:"#ffffff",bridges_link_casing:"#ffffff",bridges_medium_casing:"#ffffff",bridges_major_casing:"#ffffff",bridges_highway_casing:"#ffffff",bridges_other:"#f5f5f5",bridges_minor:"#f5f5f5",bridges_link:"#ebebeb",bridges_medium:"#ebebeb",bridges_major:"#ebebeb",bridges_highway:"#ebebeb",roads_label_minor:"#adadad",roads_label_minor_halo:"#ffffff",roads_label_major:"#999999",roads_label_major_halo:"#ffffff",ocean_label:"#adadad",peak_label:"#adadad",subplace_label:"#8f8f8f",subplace_label_halo:"#ffffff",city_circle:"#ffffff",city_circle_stroke:"#adadad",city_label:"#5c5c5c",city_label_halo:"#ffffff",state_label:"#b3b3b3",state_label_halo:"#ffffff",country_label:"#b8b8b8"},grayscale:{background:"#a3a3a3",earth:"#cccccc",park_a:"#c2c2c2",park_b:"#c2c2c2",hospital:"#d0d0d0",industrial:"#c6c6c6",school:"#d0d0d0",wood_a:"#c2c2c2",wood_b:"#c2c2c2",pedestrian:"#c4c4c4",scrub_a:"#c2c2c2",scrub_b:"#c2c2c2",glacier:"#d2d2d2",sand:"#d2d2d2",beach:"#d2d2d2",aerodrome:"#c9c9c9",runway:"#f5f5f5",water:"#a3a3a3",pier:"#b8b8b8",zoo:"#c7c7c7",military:"#bfbfbf",tunnel_other_casing:"#b8b8b8",tunnel_minor_casing:"#b8b8b8",tunnel_link_casing:"#b8b8b8",tunnel_medium_casing:"#b8b8b8",tunnel_major_casing:"#b8b8b8",tunnel_highway_casing:"#b8b8b8",tunnel_other:"#d6d6d6",tunnel_minor:"#d6d6d6",tunnel_link:"#d6d6d6",tunnel_medium:"#d6d6d6",tunnel_major:"#d6d6d6",tunnel_highway:"#d6d6d6",transit_pier:"#b8b8b8",buildings:"#e0e0e0",minor_service_casing:"#cccccc",minor_casing:"#cccccc",link_casing:"#cccccc",medium_casing:"#cccccc",major_casing_late:"#cccccc",highway_casing_late:"#cccccc",other:"#e0e0e0",minor_service:"#e0e0e0",minor_a:"#ebebeb",minor_b:"#e0e0e0",link:"#ebebeb",medium:"#ebebeb",major_casing_early:"#cccccc",major:"#ebebeb",highway_casing_early:"#cccccc",highway:"#ebebeb",railway:"#f5f5f5",boundaries:"#5c5c5c",waterway_label:"#7a7a7a",bridges_other_casing:"#cccccc",bridges_minor_casing:"#cccccc",bridges_link_casing:"#cccccc",bridges_medium_casing:"#cccccc",bridges_major_casing:"#cccccc",bridges_highway_casing:"#cccccc",bridges_other:"#e0e0e0",bridges_minor:"#e0e0e0",bridges_link:"#ebebeb",bridges_medium:"#ebebeb",bridges_major:"#ebebeb",bridges_highway:"#ebebeb",roads_label_minor:"#999999",roads_label_minor_halo:"#e0e0e0",roads_label_major:"#8f8f8f",roads_label_major_halo:"#ebebeb",ocean_label:"#7a7a7a",peak_label:"#5c5c5c",subplace_label:"#7a7a7a",subplace_label_halo:"#cccccc",city_circle:"#c2c2c2",city_circle_stroke:"#7a7a7a",city_label:"#474747",city_label_halo:"#cccccc",state_label:"#999999",state_label_halo:"#cccccc",country_label:"#858585"},black:{background:"#2b2b2b",earth:"#141414",park_a:"#181818",park_b:"#181818",hospital:"#1d1d1d",industrial:"#101010",school:"#111111",wood_a:"#1a1a1a",wood_b:"#1a1a1a",pedestrian:"#191919",scrub_a:"#1c1c1c",scrub_b:"#1c1c1c",glacier:"#191919",sand:"#161616",beach:"#1f1f1f",aerodrome:"#191919",runway:"#323232",water:"#333333",pier:"#0a0a0a",zoo:"#191919",military:"#121212",tunnel_other_casing:"#101010",tunnel_minor_casing:"#101010",tunnel_link_casing:"#101010",tunnel_medium_casing:"#101010",tunnel_major_casing:"#101010",tunnel_highway_casing:"#101010",tunnel_other:"#292929",tunnel_minor:"#292929",tunnel_link:"#292929",tunnel_medium:"#292929",tunnel_major:"#292929",tunnel_highway:"#292929",transit_pier:"#0a0a0a",buildings:"#0a0a0a",minor_service_casing:"#141414",minor_casing:"#141414",link_casing:"#141414",medium_casing:"#141414",major_casing_late:"#141414",highway_casing_late:"#141414",other:"#1f1f1f",minor_service:"#1f1f1f",minor_a:"#292929",minor_b:"#1f1f1f",link:"#1f1f1f",medium:"#292929",major_casing_early:"#141414",major:"#292929",highway_casing_early:"#141414",highway:"#292929",railway:"#292929",boundaries:"#707070",waterway_label:"#707070",bridges_other_casing:"#141414",bridges_minor_casing:"#141414",bridges_link_casing:"#141414",bridges_medium_casing:"#141414",bridges_major_casing:"#141414",bridges_highway_casing:"#141414",bridges_other:"#1f1f1f",bridges_minor:"#1f1f1f",bridges_link:"#292929",bridges_medium:"#292929",bridges_major:"#292929",bridges_highway:"#292929",roads_label_minor:"#525252",roads_label_minor_halo:"#141414",roads_label_major:"#5c5c5c",roads_label_major_halo:"#141414",ocean_label:"#707070",peak_label:"#707070",subplace_label:"#5c5c5c",subplace_label_halo:"#141414",city_circle:"#000000",city_circle_stroke:"#666666",city_label:"#999999",city_label_halo:"#141414",state_label:"#3d3d3d",state_label_halo:"#141414",country_label:"#707070"}},Yi=ge((t,e,i)=>{let o=[];for(var n of t){let t=[];for(var a of n)t.push(a.clone().mult(e).add(i));o.push(t)}return o},"transformGeom"),Vi=ge((t,e)=>{e=1<this.tileCache.get(t.dataTile)))).map((t,e)=>{e=i[e];return{data:t,z:o,dataTile:e.dataTile,scale:e.scale,dim:e.dim,origin:e.origin}})})}getDisplayTile(e){return be(this,null,function*(){var t=this.dataTileForDisplayTile(e);return{data:yield this.tileCache.get(t.dataTile),z:e.z,dataTile:t.dataTile,scale:t.scale,origin:t.origin,dim:t.dim}})}queryFeatures(t,e,i,o){var n=Math.round(i),i=Math.min(n-this.levelDiff,this.maxDataLevel);return this.tileCache.queryFeatures(t,e,i,o/(1<{let e=ge(t=>{let e=void 0===t.levelDiff?1:t.levelDiff,i=t.maxDataZoom||15,o;if("string"==typeof t.url)o=new(new URL(t.url,"http://example.com").pathname.endsWith(".pmtiles")?Ne:je)(t.url,!0);else{if(!t.url)throw new Error("Invalid source "+t.url);o=new Ne(t.url,!0)}t=new ei(o,256<{let o=t/256,n=Math.floor(i.minX/256),a=Math.floor(i.minY/256),r=Math.floor(i.maxX/256),s=Math.floor(i.maxY/256),l=Math.log2(o),h=[];for(let t=n;t<=r;t++){var c=t%(1<this.dim&&(l=!0);if(s||l){let t=s?this.dim:-this.dim,e=[];for(var h of n.bboxes)e.push({minX:h.minX+t,minY:h.minY,maxX:h.maxX+t,maxY:h.maxY});let i={anchor:new C(n.anchor.x+t,n.anchor.y),bboxes:e,draw:n.draw,order:a,tileKey:r},o=this.current.get(r);o&&o.add(i);for(var c of e)this.tree.insert({minX:c.minX,minY:c.minY,maxX:c.maxX,maxY:c.maxY,indexedLabel:i})}}pruneOrNoop(t){let e=t.split(":"),i,o=0,n=0;for(var a of this.current.keys()){var r=a.split(":");r[3]===e[3]&&(n++,(r=Math.sqrt(_e(+r[0]-+e[0],2)+_e(+r[1]-+e[1],2)))>o&&(o=r,i=a)),i&&n>this.maxLabeledTiles&&this.pruneKey(i)}}pruneKey(e){let i=this.current.get(e);if(i){let t=[];for(var o of this.tree.all())i.has(o.indexedLabel)&&t.push(o);for(var n of t)this.tree.remove(n);this.current.delete(e)}}removeLabel(t){let e=[];for(var i of this.tree.all())t===i.indexedLabel&&e.push(i);for(var o of e)this.tree.remove(o);let n=this.current.get(t.tileKey);n&&n.delete(t)}};ge(xe,"Index");var Wi=xe,Le=class{constructor(t,e,i,o,n){this.index=new Wi(256<i.maxzoom)){var l=i.dataSource||"",h=t.get(l);if(h)for(var c of h){var u=Fe(c.dataTile)+":"+l;if(o.has(u)){var m=c.data.get(i.dataLayer);if(void 0!==m){let t=m;i.sort&&t.sort((t,e)=>i.sort?i.sort(t.props,e.props):0);var d,p={index:this.index,zoom:this.z,scratch:this.scratch,order:e,overzoom:this.z-c.dataTile.z};for(d of t)if(!i.filter||i.filter(this.z,d)){var f,y=Yi(d.geom,c.scale,c.origin),y=i.symbolizer.place(p,y,d);if(y)for(var _ of y){let t=!1;if(!_.deduplicationKey||!this.index.deduplicationCollides(_)){if(this.index.labelCollides(_,1/0)){if(!this.index.labelCollides(_,e)){for(f of this.index.searchLabel(_,1/0)){this.index.removeLabel(f);for(var g of f.bboxes)this.findInvalidatedTiles(s,c.dim,g,u)}this.index.insert(_,e,u),t=!0}}else this.index.insert(_,e,u),t=!0;if(t)for(var b of _.bboxes)(b.maxX>c.origin.x+c.dim||b.minXc.origin.y+c.dim)&&this.findInvalidatedTiles(s,c.dim,b,u)}}}}}}}for(r of o)this.index.pruneOrNoop(r);return 0h.maxzoom)){var m=e.get(h.dataSource||"");if(m)for(var d of m){var p=d.data.get(h.dataLayer);if(void 0!==p){h.symbolizer.before&&h.symbolizer.before(i,d.z);var f,y,_,g,b=d.origin,x=d.dim,v=d.scale;i.save(),s&&(i.beginPath(),f=Math.max(b.x-r.x,a.minX-r.x),y=Math.max(b.y-r.y,a.minY-r.y),_=Math.min(b.x-r.x+x,a.maxX-r.x),x=Math.min(b.y-r.y+x,a.maxY-r.y),i.rect(f,y,_-f,x-y),i.clip()),i.translate(b.x-r.x,b.y-r.y);for(g of p){let t=g.geom,e=g.bbox;e.maxX*v+b.xa.maxX||e.minY*v+b.y>a.maxY||e.maxY*v+b.y{var e=Math.PI/180,i=Math.max(Math.min(eo,t.y),-eo),i=Math.sin(i*e);return new C(to*t.x*e,to*Math.log((1+i)/(1-i))/2)},"project"),no=ge(t=>{var e=180/Math.PI;return{lat:(2*Math.atan(Math.exp(t.y/to))-Math.PI/2)*e,lng:t.x*e/to}},"unproject"),ao=ge((e,i)=>t=>{t=oo(t);return new C((t.x+io)/(2*io),1-(t.y+io)/(2*io)).mult(256*(1<t=>{t=new C(t.x,t.y).add(e).div(256*(1<{return Math.log2(e*(360/t)/256)},"getZoom"),Se=class{constructor(t){var e;t.theme?(e=Hi[t.theme],this.paintRules=Ui(e),this.labelRules=Zi(e),this.backgroundColor=e.background):(this.paintRules=t.paintRules||[],this.labelRules=t.labelRules||[],this.backgroundColor=t.backgroundColor),this.views=Xi(t),this.debug=t.debug||""}drawContext(y,_,g,b,x){return be(this,null,function*(){let t=oo(b),e=new C((t.x+io)/(2*io),1-(t.y+io)/(2*io)).clone().mult(256*_e(2,x)).sub(new C(_/2,g/2)),i={minX:e.x,minY:e.y,maxX:e.x+_,maxY:e.y+g},o=[];for(var[n,a]of this.views){a=a.getBbox(x,i);o.push({key:n,promise:a})}let r=yield Promise.all(o.map(e=>e.promise.then(t=>({status:"fulfilled",value:t,key:e.key}),t=>({status:"rejected",value:[],reason:t,key:e.key})))),s=new Map;for(var l of r)"fulfilled"===l.status&&s.set(l.key,l.value);let h=performance.now(),c=new Ki(x,y,this.labelRules,16,void 0);c.add(s),this.backgroundColor&&(y.save(),y.fillStyle=this.backgroundColor,y.fillRect(0,0,_,g),y.restore());var u=this.paintRules;if(Qi(y,x,s,c.index,u,i,e,!0,this.debug),this.debug){y.save(),y.translate(-e.x,-e.y),y.strokeStyle=this.debug,y.fillStyle=this.debug,y.font="12px sans-serif";let t=0;for(var[m,d]of s){for(var p of d){y.strokeRect(p.origin.x,p.origin.y,p.dim,p.dim);var f=p.dataTile;y.fillText(m+(m?" ":"")+f.z+` ${f.x} `+f.y,p.origin.x+4,p.origin.y+14*(1+t))}t++}y.restore()}return{elapsed:performance.now()-h,project:ao(e,x),unproject:ro(e,x)}})}drawCanvas(t,e,i){return be(this,arguments,function*(t,e,i,o={}){var n=window.devicePixelRatio,a=t.clientWidth,r=t.clientHeight;t.width===a*n&&t.height===r*n||(t.width=a*n,t.height=r*n),o.lang&&(t.lang=o.lang);let s=t.getContext("2d");if(s)return s.setTransform(n,0,0,n,0,0),this.drawContext(s,a,r,e,i);console.error("Failed to initialize canvas2d context.")})}drawContextBounds(i,o,n,a,r){return be(this,null,function*(){var t=n.x-o.x,e=new C((o.x+n.x)/2,(o.y+n.y)/2);return this.drawContext(i,a,r,e,so(t,a))})}drawCanvasBounds(t,e,i,o){return be(this,arguments,function*(t,e,i,o,n={}){var a=i.x-e.x,i=new C((e.x+i.x)/2,(e.y+i.y)/2);return this.drawCanvas(t,i,so(a,o),n)})}};ge(Se,"Static");var Ee=Se,lo=ge(e=>new Promise(t=>{setTimeout(()=>{t()},e)}),"timer"),ho=ge(t=>t.then(t=>({status:"fulfilled",value:t}),t=>({status:"rejected",reason:t})),"reflect"),co=ge((t={})=>{let e=class extends L.GridLayer{constructor(t={}){t.noWrap&&!t.bounds&&(t.bounds=[[-90,-180],[90,180]]),null==t.attribution&&(t.attribution='Protomaps © OpenStreetMap'),super(t),t.theme?(e=Hi[t.theme],this.paintRules=Ui(e),this.labelRules=Zi(e),this.backgroundColor=e.background):(this.paintRules=t.paintRules||[],this.labelRules=t.labelRules||[],this.backgroundColor=t.backgroundColor),this.lastRequestedZ=void 0,this.tasks=t.tasks||[],this.views=Xi(t),this.debug=t.debug;var e=document.createElement("canvas").getContext("2d");this.scratch=e,this.onTilesInvalidated=t=>{for(var e of t)this.rerenderTile(e)},this.labelers=new Ji(this.scratch,this.labelRules,16,this.onTilesInvalidated),this.tileSize=256*window.devicePixelRatio,this.tileDelay=t.tileDelay||3,this.lang=t.lang}renderTile(u,m,d,p=()=>{}){return be(this,null,function*(){this.lastRequestedZ=u.z;let t=[];for(var[e,i]of this.views){i=i.getDisplayTile(u);t.push({key:e,promise:i})}let o=yield Promise.all(t.map(e=>e.promise.then(t=>({status:"fulfilled",value:t,key:e.key}),t=>({status:"rejected",reason:t,key:e.key})))),n=new Map;for(var a of o)"fulfilled"===a.status?n.set(a.key,[a.value]):"AbortError"===a.reason.name||console.error(a.reason);if(m.key===d&&this.lastRequestedZ===u.z&&(yield Promise.all(this.tasks.map(ho)),m.key===d)&&this.lastRequestedZ===u.z){let o=this.labelers.add(u.z,n);if(m.key===d&&this.lastRequestedZ===u.z){var r=this.labelers.getIndex(u.z);if(this._map){var s=this._map.getCenter().wrap(),l=this._getTiledPixelBounds(s),s=this._pxBoundsToTileRange(l).getCenter(),l=u.distanceTo(s)*this.tileDelay;if(yield lo(l),m.key===d&&this.lastRequestedZ===u.z){s={minX:256*u.x-16,minY:256*u.y-16,maxX:256*(u.x+1)+16,maxY:256*(u.y+1)+16},l=new C(256*u.x,256*u.y);m.width=this.tileSize,m.height=this.tileSize;let i=m.getContext("2d");if(i){i.setTransform(this.tileSize/256,0,0,this.tileSize/256,0,0),i.clearRect(0,0,256,256),this.backgroundColor&&(i.save(),i.fillStyle=this.backgroundColor,i.fillRect(0,0,256,256),i.restore());let e=0,t=this.paintRules;if(e=Qi(i,u.z,n,this.xray?null:r,t,s,l,!1,this.debug),this.debug){i.save(),i.fillStyle=this.debug,i.font="600 12px sans-serif",i.fillText(`${u.z} ${u.x} `+u.y,4,14),i.font="12px sans-serif";let t=28;for(var[h,c]of n){c=c[0].dataTile;i.fillText(h+(h?" ":"")+c.z+` ${c.x} `+c.y,4,t),t+=14}i.font="600 10px sans-serif",8{e(void 0,i)}),i}_removeTile(t){let e=this._tiles[t];e&&(e.el.removed=!0,e.el.key=void 0,L.DomUtil.removeClass(e.el,"leaflet-tile-loaded"),e.el.width=e.el.height=0,L.DomUtil.remove(e.el),delete this._tiles[t],this.fire("tileunload",{tile:e.el,coords:this._keyToTileCoords(t)}))}};ge(e,"LeafletLayer");let i=e;return new i(t)},"leafletLayer"),Oe=ge((t,e,i)=>{let o=new FontFace(t,`url(${e})`,{weight:i});return document.fonts.add(o),o.load()},"Font"),uo=ge(o=>be(void 0,null,function*(){return new Promise((t,e)=>{let i=new Image;i.onload=()=>t(i),i.onerror=()=>e("Invalid SVG"),i.src=o})}),"mkimg"),qe=class{constructor(t){this.src=t,this.canvas=document.createElement("canvas"),this.mapping=new Map,this.missingBox={x:0,y:0,w:0,h:0}}load(){return be(this,null,function*(){let t=this.src,e=window.devicePixelRatio;t.endsWith(".html")&&(t=yield(yield fetch(t)).text());let i=(new window.DOMParser).parseFromString(t,"text/html"),o=Array.from(i.body.children),n=yield uo("data:image/svg+xml;base64,"+btoa(` + + + + + + +`)),a=[{w:n.width*e,h:n.height*e,img:n,id:""}],r=new XMLSerializer;for(var s of o){var l="data:image/svg+xml;base64,"+btoa(r.serializeToString(s)),l=yield uo(l);a.push({w:l.width*e,h:l.height*e,img:l,id:s.id})}var h=function(t){let e=0,i=0;for(const s of t)e+=s.w*s.h,i=Math.max(i,s.w);var o;t.sort((t,e)=>e.h-t.h);const n=[{x:0,y:0,w:Math.max(Math.ceil(Math.sqrt(e/.95)),i),h:1/0}];let a=0,r=0;for(const l of t)for(let t=n.length-1;0<=t;t--){const h=n[t];if(!(l.w>h.w||l.h>h.h)){l.x=h.x,l.y=h.y,r=Math.max(r,l.y+l.h),a=Math.max(a,l.x+l.w),l.w===h.w&&l.h===h.h?(o=n.pop(),t "+this._template.template),this.zoomBounds=e.zoomBounds,this.extentBounds=e.extentBounds,delete e.zoomBounds,delete e.extentBounds,this._linkEl=e.linkEl,L.setOptions(this,e)},_mapInputNamesToProtomapsUrl:function(t){let e=t.template;var i=new RegExp(t.zoom?.name?"{"+t.zoom.name+"}":"{z}","ig");e=e.replace(i,"{z}");var o=t.values.find(t=>"location"===t.type&&"row"===t.axis)?.name,i=new RegExp(o?"{"+o+"}":"{y}","ig");e=e.replace(i,"{y}");t=t.values.find(t=>"location"===t.type&&"column"===t.axis)?.name;return i=new RegExp(t?"{"+t+"}":"{x}","ig"),e=e.replace(i,"{x}"),e},onAdd:function(t){this._map=t,this.options.pane.appendChild(this._container),this.setZIndex(this.options.zIndex),this._pmtilesLayer=M.protomapsL.leafletLayer(this._pmtilesOptions).addTo(t)},onRemove:function(t){this._pmtilesLayer.remove(),L.DomUtil.remove(this._container)},isVisible:function(){if("OSMTILE"!==this._template.projection)return!1;let t=this._linkEl.getMapEl()._map;var e=t.getZoom(),i=M.pixelToPCRSBounds(t.getPixelBounds(),e,t.options.projection);return e<=this.zoomBounds.maxZoom&&e>=this.zoomBounds.minZoom&&this.extentBounds.overlaps(i)},setZIndex:function(t){return this.options.zIndex=t,this._container&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._container.style.zIndex=this.options.zIndex),this}}),go=L.ImageOverlay.extend({initialize:function(t,e,i,o,n,a){this._container=n,this._url=t,this._location=e,this._size=L.point(i),this._angle=o,L.setOptions(this,a)},getEvents:function(){var t={viewreset:this._reset};return this._zoomAnimated&&this._step<=1&&(t.zoomanim=this._animateZoom),t},onAdd:function(t){this.on({load:this._onImageLoad}),this._image||this._initImage(),this.options.interactive&&(L.DomUtil.addClass(this._image,"leaflet-interactive"),this.addInteractiveTarget(this._image)),this._container.appendChild(this._image),this._reset()},onRemove:function(){L.DomUtil.remove(this._image),this.options.interactive&&this.removeInteractiveTarget(this._image)},_onImageLoad:function(){this._image&&(this._image.loaded=+new Date,this._updateOpacity())},_animateZoom:function(t){var e=this._map.getZoomScale(t.zoom),t=this._map.getPixelOrigin().add(this._location).multiplyBy(e).subtract(this._map._getNewPixelOrigin(t.center,t.zoom)).round();L.Browser.any3d?L.DomUtil.setTransform(this._image,t,e):L.DomUtil.setPosition(this._image,t)},_reset:function(t){var e=this._image,i=this._location,o=this._size;t&&1 map-meta[name=extent][content]")?M.getBoundsFromMeta(this._layerEl.shadowRoot):this._layerEl.querySelector(":scope > map-meta[name=extent][content]")?M.getBoundsFromMeta(this._layerEl):void 0,s=this._layerEl.src&&this._layerEl.shadowRoot.querySelector(":host > map-meta[name=zoom][content]")?M.getZoomBoundsFromMeta(this._layerEl.shadowRoot):this._layerEl.querySelector(":scope > map-meta[name=zoom][content]")?M.getZoomBoundsFromMeta(this._layerEl):void 0;const l=(this._layerEl.src?this._layerEl.shadowRoot:this._layerEl).querySelectorAll("map-extent");["_staticTileLayer","_mapmlvectors","_extentLayer"].forEach(t=>{let e,i,o,n;if(s&&(e=s.maxZoom,i=s.minZoom,n=s.maxNativeZoom||-1/0,o=s.minNativeZoom||1/0),"_extentLayer"===t&&l.length)for(let t=0;t'+e+"");L.setOptions(n,{attribution:e});var e=a.querySelector("map-link[rel=legend]");e&&(n._legendUrl=e.getAttribute("href"));n._map&&n._map.hasLayer(n)&&n._map.attributionControl.addAttribution(n.getAttribution())}(),a.querySelector("map-title")?(n._title=a.querySelector("map-title").textContent.trim(),n._titleIsReadOnly=!0):n._layerEl&&n._layerEl.hasAttribute("label")&&(n._title=n._layerEl.getAttribute("label").trim()),M[n.options.projection]&&function(){if(a.querySelector("map-tile")){var t=document.createElement("map-tiles"),e=a.querySelector("map-meta[name=zoom][content]")||a.querySelector("map-input[type=zoom][value]");t.setAttribute("zoom",e&&e.getAttribute("content")||e&&e.getAttribute("value")||"0");for(var i=a.getElementsByTagName("map-tile"),o=0;o{L.DomEvent.stop(t),r.featureIndex._sortIndex(),r.closePopup(),r._container.focus()},n);let s=L.DomUtil.create("button","mapml-popup-button",t);s.type="button",s.title="Previous Feature",s.innerHTML="",L.DomEvent.on(s,"click",e._previousFeature,n);let l=L.DomUtil.create("p","mapml-feature-count",t),h=this._totalFeatureCount||1;l.innerText=n._count+1+"/"+h;let c=L.DomUtil.create("button","mapml-popup-button",t);c.type="button",c.title="Next Feature",c.innerHTML="",L.DomEvent.on(c,"click",e._nextFeature,n);let u=L.DomUtil.create("button","mapml-popup-button",t);u.type="button",u.title="Focus Controls",u.innerHTML="",L.DomEvent.on(u,"click",t=>{r.featureIndex._sortIndex(),r.featureIndex.currentIndex=r.featureIndex.inBoundFeatures.length-1,r.featureIndex.inBoundFeatures[0]?.path.setAttribute("tabindex",-1),r.featureIndex.inBoundFeatures[r.featureIndex.currentIndex]?.path.setAttribute("tabindex",0),L.DomEvent.stop(t),r.closePopup(),r._controlContainer.querySelector("A:not([hidden])").focus()},n);var m=L.DomUtil.create("hr","mapml-popup-divider");function d(t){let e=t.originalEvent.path||t.originalEvent.composedPath();var i=9===t.originalEvent.keyCode,o=t.originalEvent.shiftKey;(e[0].classList.contains("leaflet-popup-close-button")&&i&&!o||27===t.originalEvent.keyCode||e[0].classList.contains("leaflet-popup-close-button")&&13===t.originalEvent.keyCode||e[0].classList.contains("mapml-popup-content")&&i&&o||e[0]===n._content.querySelector("a")&&i&&o)&&setTimeout(()=>{r.closePopup(n),a.focus(),L.DomEvent.stop(t)},0)}function p(t){let e=t.originalEvent.path||t.originalEvent.composedPath();var i=9===t.originalEvent.keyCode,o=t.originalEvent.shiftKey;13===t.originalEvent.keyCode&&e[0].classList.contains("leaflet-popup-close-button")||27===t.originalEvent.keyCode?(L.DomEvent.stopPropagation(t),r.closePopup(n),r._container.focus(),27!==t.originalEvent.keyCode&&(r._popupClosed=!0)):i&&e[0].classList.contains("leaflet-popup-close-button")?r.closePopup(n):e[0].classList.contains("mapml-popup-content")&&i&&o?(r.closePopup(n),setTimeout(()=>{L.DomEvent.stop(t),r._container.focus()},0)):e[0]===n._content.querySelector("a")&&i&&o&&(r.closePopup(n),setTimeout(()=>{L.DomEvent.stop(t),r.getContainer.focus()},0))}function f(i){let o=this._content,n=i?i.currFeature:this._source._groupLayer._featureEl;if(o.querySelector("a.mapml-zoom-link")&&o.querySelector("a.mapml-zoom-link").remove(),n.querySelector("map-geometry")){var a=n.extent.topLeft.gcrs,i=n.extent.bottomRight.gcrs,i=L.latLngBounds(L.latLng(a.horizontal,a.vertical),L.latLng(i.horizontal,i.vertical)).getCenter(!0);let t=document.createElement("a");t.href=`#${n.getZoomToZoom()},${i.lng},`+i.lat,t.innerHTML=""+M.options.locale.popupZoom,t.className="mapml-zoom-link",t.onclick=t.onkeydown=function(t){(t instanceof MouseEvent||13===t.keyCode)&&(t.preventDefault(),n.zoomTo(),r.closePopup(),r.getContainer().focus())};let e=o.querySelector(".mapml-zoom-link");e&&e.remove(),o.insertBefore(t,o.querySelector("hr.mapml-popup-divider"))}}n._navigationBar=t,n._content.appendChild(m),n._content.appendChild(t),i.focus(),a&&!M.options.featureIndexOverlayOption?(a.setAttribute("aria-expanded","true"),r.on("keydown",d)):r.on("keydown",p),r.on("popupclose",function t(e){e.popup===n&&(r.off("keydown",d),r.off("keydown",p),r.off("popupopen",f),r.off("popupclose",t),a&&a.setAttribute("aria-expanded","false"))})}}),xo=L.Layer.extend({onAdd:function(t){var e=t.getSize();(400tile: i: ${Math.trunc(a)}, - j: ${Math.trunc(s)} + j: ${Math.trunc(r)} `,this.debug._mapCoord.innerHTML=` map: - i: ${Math.trunc(r.containerPoint.x)}, - j: ${Math.trunc(r.containerPoint.y)} + i: ${Math.trunc(s.containerPoint.x)}, + j: ${Math.trunc(s.containerPoint.y)} `,this.debug._gcrsCoord.innerHTML=` gcrs: - lon: ${r.latlng.lng.toFixed(6)}, - lat: ${r.latlng.lat.toFixed(6)} + lon: ${s.latlng.lng.toFixed(6)}, + lat: ${s.latlng.lat.toFixed(6)} `,this.debug._tcrsCoord.innerHTML=` tcrs: x: ${Math.trunc(e.x)}, @@ -22,9 +29,9 @@ row: ${Math.trunc(e.y/n)} `,this.debug._pcrsCoord.innerHTML=` pcrs: - easting: ${i.x.toFixed(2)}, - northing: ${i.y.toFixed(2)} - `}}}),v=function(t){return new x(t)},C=L.GridLayer.extend({initialize:function(t){L.setOptions(this,t),L.GridLayer.prototype.initialize.call(this,this._map)},createTile:function(t){let e=L.DomUtil.create("div","mapml-debug-tile");return e.setAttribute("col",t.x),e.setAttribute("row",t.y),e.setAttribute("zoom",t.z),e.innerHTML=["col: "+t.x,"row: "+t.y,"zoom: "+t.z].join(", "),e.style.outline="1px dashed red",e}}),E=function(t){return new C(t)},S=L.LayerGroup.extend({initialize:function(t){L.setOptions(this,t),L.LayerGroup.prototype.initialize.call(this,this._map,t)},onAdd:function(t){t.on("overlayremove",this._mapLayerUpdate,this),t.on("overlayadd",this._mapLayerUpdate,this);var e=t.options.crs.transformation.transform(L.point(0,0),t.options.crs.scale(0));this._centerVector=L.circle(t.options.crs.pointToLatLng(e,0),{radius:250,className:"mapml-debug-vectors projection-centre"}),this._centerVector.bindTooltip("Projection Center"),this._addBounds(t)},onRemove:function(t){this.clearLayers()},_addBounds:function(r){setTimeout(()=>{let t=Object.keys(r._layers),o=r._layers,i=["#FF5733","#8DFF33","#3397FF","#E433FF","#F3FF33"],n=0;this.addLayer(this._centerVector);for(var a of t)if(o[a].layerBounds||o[a].extentBounds){let t;t=o[a].layerBounds?[o[a].layerBounds.min,L.point(o[a].layerBounds.max.x,o[a].layerBounds.min.y),o[a].layerBounds.max,L.point(o[a].layerBounds.min.x,o[a].layerBounds.max.y)]:[o[a].extentBounds.min,L.point(o[a].extentBounds.max.x,o[a].extentBounds.min.y),o[a].extentBounds.max,L.point(o[a].extentBounds.min.x,o[a].extentBounds.max.y)];var s=o[a].extentBounds&&o[a].options.linkEl.getLayerEl().hasAttribute("data-testid")?o[a].options.linkEl.getLayerEl().getAttribute("data-testid"):o[a].layerBounds&&o[a].options?._leafletLayer?._layerEl?.hasAttribute("data-testid")?o[a].options._leafletLayer._layerEl.getAttribute("data-testid"):"";let e=k(t,{className:this.options.className.concat(" ",s),color:i[n%i.length],weight:2,opacity:1,fillOpacity:.01,fill:!0});o[a].options._leafletLayer&&e.bindTooltip(o[a].options._leafletLayer._title,{sticky:!0}),this.addLayer(e),n++}var e;r.totalLayerBounds&&(e=[r.totalLayerBounds.min,L.point(r.totalLayerBounds.max.x,r.totalLayerBounds.min.y),r.totalLayerBounds.max,L.point(r.totalLayerBounds.min.x,r.totalLayerBounds.max.y)],e=k(e,{className:"mapml-debug-vectors mapml-total-bounds",color:"#808080",weight:5,opacity:.5,fill:!1}),this.addLayer(e))},0)},_mapLayerUpdate:function(t){this.clearLayers(),this._addBounds(t.target)}}),T=function(t){return new S(t)},A=L.Path.extend({getCenter:function(t){let e=this._map.options.crs;return e.unproject(L.bounds(this._locations).getCenter())},options:{className:"mapml-debug-extent"},initialize:function(t,e){this._locations=t,L.setOptions(this,e)},_project:function(){this._rings=[];let e=this._map.options.crs.scale(this._map.getZoom()),o=this._map;for(let t=0;t{!this._map.isFocused||this._map._popupClosed||" "!==t.originalEvent.key&&13!=+t.originalEvent.keyCode?delete this._map._popupClosed:this._map.fire("click",{latlng:this._map.getCenter(),layerPoint:this._map.latLngToLayerPoint(this._map.getCenter()),containerPoint:this._map.latLngToContainerPoint(this._map.getCenter())})},0)},_queryTopLayer:function(t){var e=this._getTopQueryableLayer();e&&(e._mapmlFeatures&&delete e._mapmlFeatures,this._query(t,e))},_query(m,a){function e(t){return n.transformation.untransform(t,n.scale(i))}function o(t){return n.unproject(n.transformation.untransform(t,n.scale(i)),i)}var i=m.target.getZoom(),s=this._map,n=M[a.options.projection],r=s.options.crs.options.crs.tile.bounds.max.x,l=a._container,u={autoClose:!1,autoPan:!0,maxHeight:.5*s.getSize().y-50},c=n.latLngToPoint(m.latlng,i),p=c.divideBy(r).floor(),h=new L.Bounds(c.divideBy(r).floor().multiplyBy(r),c.divideBy(r).ceil().multiplyBy(r)),t=this._map.project(m.latlng),d=this._map.options.crs.scale(this._map.getZoom()),d=this._map.options.crs.transformation.untransform(t,d),_=a.getQueryTemplates(d,i);let y=[];for(let t=0;t<_.length;t++){var f,g={},b=_[t];for(f in g[b.query.tilei]=c.x.toFixed()-p.x*r,g[b.query.tilej]=c.y.toFixed()-p.y*r,g[b.query.mapi]=s.getSize().divideBy(2).x.toFixed(),g[b.query.mapj]=s.getSize().divideBy(2).y.toFixed(),g[b.query.pixelleft]=n.pointToLatLng(c,i).lng,g[b.query.pixeltop]=n.pointToLatLng(c,i).lat,g[b.query.pixelright]=n.pointToLatLng(c.add([1,1]),i).lng,g[b.query.pixelbottom]=n.pointToLatLng(c.add([1,1]),i).lat,g[b.query.column]=p.x,g[b.query.row]=p.y,g[b.query.x]=c.x.toFixed(),g[b.query.y]=c.y.toFixed(),g[b.query.easting]=e(c).x,g[b.query.northing]=e(c).y,g[b.query.longitude]=o(c).lng,g[b.query.latitude]=o(c).lat,g[b.query.zoom]=i,g[b.query.width]=s.getSize().x,g[b.query.height]=s.getSize().y,g[b.query.mapbottom]=e(c.add(s.getSize().divideBy(2))).y,g[b.query.mapleft]=e(c.subtract(s.getSize().divideBy(2))).x,g[b.query.maptop]=e(c.subtract(s.getSize().divideBy(2))).y,g[b.query.mapright]=e(c.add(s.getSize().divideBy(2))).x,g[b.query.tilebottom]=e(h.max).y,g[b.query.tileleft]=e(h.min).x,g[b.query.tiletop]=e(h.min).y,g[b.query.tileright]=e(h.max).x,b.query)["mapi","mapj","tilei","tilej","row","col","x","y","easting","northing","longitude","latitude","width","height","zoom","mapleft","mapright",",maptop","mapbottom","tileleft","tileright","tiletop","tilebottom","pixeltop","pixelbottom","pixelleft","pixelright"].indexOf(f)<0&&(g[f]=b.query[f]);y.push(function(t,e){const u=new DOMParser;return fetch(L.Util.template(t.template,e),{redirect:"follow"}).then(e=>{if(200<=e.status&&e.status<300)return e.text().then(t=>({contenttype:e.headers.get("Content-Type"),text:t}));throw new Error(e.status)}).then(i=>{let n=[],o=[];var a=""+m.latlng.lng+" "+m.latlng.lat+"";if(i.contenttype.startsWith("text/mapml")){let t=u.parseFromString(i.text,"application/xml");var s=t.querySelectorAll("map-feature:not(:has(map-geometry))");if(s.length){let o=u.parseFromString(a,"application/xml");for(let e=0;et.meta=o)}else try{let t=u.parseFromString(i.text,"application/xml");var r,l=t.querySelectorAll("map-feature");if(t.querySelector("parsererror")||0===l.length)throw new Error("parsererror");let e=u.parseFromString(a,"application/xml");o=Array.prototype.slice.call(t.querySelectorAll("map-meta[name=cs], map-meta[name=zoom], map-meta[name=projection]"));for(r of l)r.querySelector("map-geometry")||r.appendChild(e.firstElementChild.cloneNode(!0)),r.meta=o,n.push(r)}catch(t){let e=u.parseFromString(i.text,"text/html"),o=u.parseFromString(""+a+"","text/html");e.body?o.querySelector("map-properties").appendChild(e.querySelector("html")):o.querySelector("map-properties").append(i.text),n.push(o.querySelector("map-feature"))}return{features:n,template:t}}).catch(t=>{console.log("Looks like there was a problem. Status: "+t.message)})}(b,g))}Promise.allSettled(y).then(t=>{a._mapmlFeatures=[];for(var e of t)if("fulfilled"===e.status){for(var o of e.value.features)o._linkEl=e.value.template.linkEl;a._mapmlFeatures=a._mapmlFeatures.concat(e.value.features)}0Alt+Left Arrow)",callback:this._goBack},{text:M.options.locale.cmForward+" (Alt+Right Arrow)",callback:this._goForward},{text:M.options.locale.cmReload+" (Ctrl+R)",callback:this._reload},{text:M.options.locale.btnFullScreen+" (F)",callback:this._toggleFullScreen},{spacer:"-"},{text:M.options.locale.cmCopyCoords+" (C)",callback:this._copyCoords,hideOnSelect:!1,popup:!0,submenu:[{text:M.options.locale.cmCopyMapML,callback:this._copyMapML},{text:M.options.locale.cmCopyExtent,callback:this._copyExtent},{text:M.options.locale.cmCopyLocation,callback:this._copyLocation}]},{text:M.options.locale.cmPasteLayer+" (P)",callback:this._paste},{spacer:"-"},{text:M.options.locale.cmToggleControls+" (T)",callback:this._toggleControls},{text:M.options.locale.cmToggleDebug+" (D)",callback:this._toggleDebug},{text:M.options.locale.cmViewSource+" (V)",callback:this._viewSource}],this.defExtCS=M.options.defaultExtCoor,this.defLocCS=M.options.defaultLocCoor;this._menuItems.LYRZOOMTO=0,this._menuItems.LYRCOPY=1,this._layerItems=[{text:M.options.locale.lmZoomToLayer+" (Z)",callback:this._zoomToLayer},{text:M.options.locale.lmCopyLayer+" (L)",callback:this._copyLayer}],this._extentLayerItems=[{text:M.options.locale.lmZoomToExtent+" (Z)",callback:this._zoomToMapExtent},{text:M.options.locale.lmCopyExtent+" (L)",callback:this._copyMapExtent}],this._mapMenuVisible=!1,this._keyboardEvent=!1,this._container=L.DomUtil.create("div","mapml-contextmenu",t.getContainer()),this._container.setAttribute("hidden",""),this._items[0].el=this._createItem(this._container,this._items[0]),this._items[1].el=this._createItem(this._container,this._items[1]),this._items[2].el=this._createItem(this._container,this._items[2]),this._items[3].el=this._createItem(this._container,this._items[3]),this._items[4].el=this._createItem(this._container,this._items[4]),this._items[5].el=this._createItem(this._container,this._items[5]),this._copySubMenu=L.DomUtil.create("div","mapml-contextmenu mapml-submenu",this._container),this._copySubMenu.id="mapml-copy-submenu",this._copySubMenu.setAttribute("hidden",""),this._clickEvent=null;this._menuItems.CPYMENUMAP=0,this._menuItems.CPYMENUEXTENT=1,this._menuItems.CPYMENULOC=2,this._createItem(this._copySubMenu,this._items[5].submenu[0],0),this._createItem(this._copySubMenu,this._items[5].submenu[1],1),this._createItem(this._copySubMenu,this._items[5].submenu[2],2),this._items[6].el=this._createItem(this._container,this._items[6]),this._items[7].el=this._createItem(this._container,this._items[7]),this._items[8].el=this._createItem(this._container,this._items[8]),this._items[9].el=this._createItem(this._container,this._items[9]),this._items[10].el=this._createItem(this._container,this._items[10]),this._layerMenu=L.DomUtil.create("div","mapml-contextmenu mapml-layer-menu",t.getContainer()),this._layerMenu.setAttribute("hidden",""),this._createItem(this._layerMenu,this._layerItems[0]),this._createItem(this._layerMenu,this._layerItems[1]),this._extentLayerMenu=L.DomUtil.create("div","mapml-contextmenu mapml-extent-menu",t.getContainer()),this._extentLayerMenu.setAttribute("hidden",""),this._createItem(this._extentLayerMenu,this._extentLayerItems[0]),this._createItem(this._extentLayerMenu,this._extentLayerItems[1]),L.DomEvent.on(this._container,"click",L.DomEvent.stop).on(this._container,"mousedown",L.DomEvent.stop).on(this._container,"dblclick",L.DomEvent.stop).on(this._container,"contextmenu",L.DomEvent.stop).on(this._layerMenu,"click",L.DomEvent.stop).on(this._layerMenu,"mousedown",L.DomEvent.stop).on(this._layerMenu,"dblclick",L.DomEvent.stop).on(this._layerMenu,"contextmenu",L.DomEvent.stop).on(this._extentLayerMenu,"click",L.DomEvent.stop).on(this._extentLayerMenu,"mousedown",L.DomEvent.stop).on(this._extentLayerMenu,"dblclick",L.DomEvent.stop).on(this._extentLayerMenu,"contextmenu",L.DomEvent.stop),this.t=document.createElement("template"),this.t.innerHTML=` + easting: ${o.x.toFixed(2)}, + northing: ${o.y.toFixed(2)} + `}}}),Lo=function(t){return new vo(t)},wo=L.GridLayer.extend({initialize:function(t){L.setOptions(this,t),L.GridLayer.prototype.initialize.call(this,this._map)},createTile:function(t){let e=L.DomUtil.create("div","mapml-debug-tile");return e.setAttribute("col",t.x),e.setAttribute("row",t.y),e.setAttribute("zoom",t.z),e.innerHTML=["col: "+t.x,"row: "+t.y,"zoom: "+t.z].join(", "),e.style.outline="1px dashed red",e}}),Mo=function(t){return new wo(t)},Co=L.LayerGroup.extend({initialize:function(t){L.setOptions(this,t),L.LayerGroup.prototype.initialize.call(this,this._map,t)},onAdd:function(t){t.on("overlayremove",this._mapLayerUpdate,this),t.on("overlayadd",this._mapLayerUpdate,this);var e=t.options.crs.transformation.transform(L.point(0,0),t.options.crs.scale(0));this._centerVector=L.circle(t.options.crs.pointToLatLng(e,0),{radius:250,className:"mapml-debug-vectors projection-centre"}),this._centerVector.bindTooltip("Projection Center"),this._addBounds(t)},onRemove:function(t){this.clearLayers()},_addBounds:function(s){setTimeout(()=>{let t=Object.keys(s._layers),i=s._layers,o=["#FF5733","#8DFF33","#3397FF","#E433FF","#F3FF33"],n=0;this.addLayer(this._centerVector);for(var a of t)if(i[a].layerBounds||i[a].extentBounds){let t;t=i[a].layerBounds?[i[a].layerBounds.min,L.point(i[a].layerBounds.max.x,i[a].layerBounds.min.y),i[a].layerBounds.max,L.point(i[a].layerBounds.min.x,i[a].layerBounds.max.y)]:[i[a].extentBounds.min,L.point(i[a].extentBounds.max.x,i[a].extentBounds.min.y),i[a].extentBounds.max,L.point(i[a].extentBounds.min.x,i[a].extentBounds.max.y)];var r=i[a].extentBounds&&i[a].options.linkEl.getLayerEl().hasAttribute("data-testid")?i[a].options.linkEl.getLayerEl().getAttribute("data-testid"):i[a].layerBounds&&i[a].options?._leafletLayer?._layerEl?.hasAttribute("data-testid")?i[a].options._leafletLayer._layerEl.getAttribute("data-testid"):"";let e=Eo(t,{className:this.options.className.concat(" ",r),color:o[n%o.length],weight:2,opacity:1,fillOpacity:.01,fill:!0});i[a].options._leafletLayer&&e.bindTooltip(i[a].options._leafletLayer._title,{sticky:!0}),this.addLayer(e),n++}var e;s.totalLayerBounds&&(e=[s.totalLayerBounds.min,L.point(s.totalLayerBounds.max.x,s.totalLayerBounds.min.y),s.totalLayerBounds.max,L.point(s.totalLayerBounds.min.x,s.totalLayerBounds.max.y)],e=Eo(e,{className:"mapml-debug-vectors mapml-total-bounds",color:"#808080",weight:5,opacity:.5,fill:!1}),this.addLayer(e))},0)},_mapLayerUpdate:function(t){this.clearLayers(),this._addBounds(t.target)}}),So=function(t){return new Co(t)},To=L.Path.extend({getCenter:function(t){let e=this._map.options.crs;return e.unproject(L.bounds(this._locations).getCenter())},options:{className:"mapml-debug-extent"},initialize:function(t,e){this._locations=t,L.setOptions(this,e)},_project:function(){this._rings=[];let e=this._map.options.crs.scale(this._map.getZoom()),i=this._map;for(let t=0;t{!this._map.isFocused||this._map._popupClosed||" "!==t.originalEvent.key&&13!=+t.originalEvent.keyCode?delete this._map._popupClosed:this._map.fire("click",{latlng:this._map.getCenter(),layerPoint:this._map.latLngToLayerPoint(this._map.getCenter()),containerPoint:this._map.latLngToContainerPoint(this._map.getCenter())})},0)},_queryTopLayer:function(t){var e=this._getTopQueryableLayer();e&&(e._mapmlFeatures&&delete e._mapmlFeatures,this._query(t,e))},_query(c,a){function e(t){return n.transformation.untransform(t,n.scale(o))}function i(t){return n.unproject(n.transformation.untransform(t,n.scale(o)),o)}var o=c.target.getZoom(),r=this._map,n=M[a.options.projection],s=r.options.crs.options.crs.tile.bounds.max.x,l=a._container,h={autoClose:!1,autoPan:!0,maxHeight:.5*r.getSize().y-50},u=n.latLngToPoint(c.latlng,o),m=u.divideBy(s).floor(),d=new L.Bounds(u.divideBy(s).floor().multiplyBy(s),u.divideBy(s).ceil().multiplyBy(s)),t=this._map.project(c.latlng),p=this._map.options.crs.scale(this._map.getZoom()),p=this._map.options.crs.transformation.untransform(t,p),f=a.getQueryTemplates(p,o);let y=[];for(let t=0;t{if(200<=e.status&&e.status<300)return e.text().then(t=>({contenttype:e.headers.get("Content-Type"),text:t}));throw new Error(e.status)}).then(o=>{let n=[],i=[];var a=""+c.latlng.lng+" "+c.latlng.lat+"";if(o.contenttype.startsWith("text/mapml")){let t=h.parseFromString(o.text,"application/xml");var r=t.querySelectorAll("map-feature:not(:has(map-geometry))");if(r.length){let i=h.parseFromString(a,"application/xml");for(let e=0;et.meta=i)}else try{let t=h.parseFromString(o.text,"application/xml");var s,l=t.querySelectorAll("map-feature");if(t.querySelector("parsererror")||0===l.length)throw new Error("parsererror");let e=h.parseFromString(a,"application/xml");i=Array.prototype.slice.call(t.querySelectorAll("map-meta[name=cs], map-meta[name=zoom], map-meta[name=projection]"));for(s of l)s.querySelector("map-geometry")||s.appendChild(e.firstElementChild.cloneNode(!0)),s.meta=i,n.push(s)}catch(t){let e=h.parseFromString(o.text,"text/html"),i=h.parseFromString(""+a+"","text/html");e.body?i.querySelector("map-properties").appendChild(e.querySelector("html")):i.querySelector("map-properties").append(o.text),n.push(i.querySelector("map-feature"))}return{features:n,template:t}}).catch(t=>{console.log("Looks like there was a problem. Status: "+t.message)})}(b,g))}Promise.allSettled(y).then(t=>{a._mapmlFeatures=[];for(var e of t)if("fulfilled"===e.status){for(var i of e.value.features)i._linkEl=e.value.template.linkEl;a._mapmlFeatures=a._mapmlFeatures.concat(e.value.features)}0Alt+Left Arrow)",callback:this._goBack},{text:M.options.locale.cmForward+" (Alt+Right Arrow)",callback:this._goForward},{text:M.options.locale.cmReload+" (Ctrl+R)",callback:this._reload},{text:M.options.locale.btnFullScreen+" (F)",callback:this._toggleFullScreen},{spacer:"-"},{text:M.options.locale.cmCopyCoords+" (C)",callback:this._copyCoords,hideOnSelect:!1,popup:!0,submenu:[{text:M.options.locale.cmCopyMapML,callback:this._copyMapML},{text:M.options.locale.cmCopyExtent,callback:this._copyExtent},{text:M.options.locale.cmCopyLocation,callback:this._copyLocation}]},{text:M.options.locale.cmPasteLayer+" (P)",callback:this._paste},{spacer:"-"},{text:M.options.locale.cmToggleControls+" (T)",callback:this._toggleControls},{text:M.options.locale.cmToggleDebug+" (D)",callback:this._toggleDebug},{text:M.options.locale.cmViewSource+" (V)",callback:this._viewSource}],this.defExtCS=M.options.defaultExtCoor,this.defLocCS=M.options.defaultLocCoor;this._menuItems.LYRZOOMTO=0,this._menuItems.LYRCOPY=1,this._layerItems=[{text:M.options.locale.lmZoomToLayer+" (Z)",callback:this._zoomToLayer},{text:M.options.locale.lmCopyLayer+" (L)",callback:this._copyLayer}],this._extentLayerItems=[{text:M.options.locale.lmZoomToExtent+" (Z)",callback:this._zoomToMapExtent},{text:M.options.locale.lmCopyExtent+" (L)",callback:this._copyMapExtent}],this._mapMenuVisible=!1,this._keyboardEvent=!1,this._container=L.DomUtil.create("div","mapml-contextmenu",t.getContainer()),this._container.setAttribute("hidden",""),this._items[0].el=this._createItem(this._container,this._items[0]),this._items[1].el=this._createItem(this._container,this._items[1]),this._items[2].el=this._createItem(this._container,this._items[2]),this._items[3].el=this._createItem(this._container,this._items[3]),this._items[4].el=this._createItem(this._container,this._items[4]),this._items[5].el=this._createItem(this._container,this._items[5]),this._copySubMenu=L.DomUtil.create("div","mapml-contextmenu mapml-submenu",this._container),this._copySubMenu.id="mapml-copy-submenu",this._copySubMenu.setAttribute("hidden",""),this._clickEvent=null;this._menuItems.CPYMENUMAP=0,this._menuItems.CPYMENUEXTENT=1,this._menuItems.CPYMENULOC=2,this._createItem(this._copySubMenu,this._items[5].submenu[0],0),this._createItem(this._copySubMenu,this._items[5].submenu[1],1),this._createItem(this._copySubMenu,this._items[5].submenu[2],2),this._items[6].el=this._createItem(this._container,this._items[6]),this._items[7].el=this._createItem(this._container,this._items[7]),this._items[8].el=this._createItem(this._container,this._items[8]),this._items[9].el=this._createItem(this._container,this._items[9]),this._items[10].el=this._createItem(this._container,this._items[10]),this._layerMenu=L.DomUtil.create("div","mapml-contextmenu mapml-layer-menu",t.getContainer()),this._layerMenu.setAttribute("hidden",""),this._createItem(this._layerMenu,this._layerItems[0]),this._createItem(this._layerMenu,this._layerItems[1]),this._extentLayerMenu=L.DomUtil.create("div","mapml-contextmenu mapml-extent-menu",t.getContainer()),this._extentLayerMenu.setAttribute("hidden",""),this._createItem(this._extentLayerMenu,this._extentLayerItems[0]),this._createItem(this._extentLayerMenu,this._extentLayerItems[1]),L.DomEvent.on(this._container,"click",L.DomEvent.stop).on(this._container,"mousedown",L.DomEvent.stop).on(this._container,"dblclick",L.DomEvent.stop).on(this._container,"contextmenu",L.DomEvent.stop).on(this._layerMenu,"click",L.DomEvent.stop).on(this._layerMenu,"mousedown",L.DomEvent.stop).on(this._layerMenu,"dblclick",L.DomEvent.stop).on(this._layerMenu,"contextmenu",L.DomEvent.stop).on(this._extentLayerMenu,"click",L.DomEvent.stop).on(this._extentLayerMenu,"mousedown",L.DomEvent.stop).on(this._extentLayerMenu,"dblclick",L.DomEvent.stop).on(this._extentLayerMenu,"contextmenu",L.DomEvent.stop),this.t=document.createElement("template"),this.t.innerHTML=`

@@ -35,12 +42,12 @@ -
`},addHooks:function(){var t=this._map.getContainer();L.DomEvent.on(t,"mouseleave",this._hide,this).on(document,"keydown",this._onKeyDown,this),L.Browser.touch&&L.DomEvent.on(document,this._touchstart,this._hide,this),this._map.on({contextmenu:this._show,mousedown:this._hide,zoomstart:this._hide},this)},removeHooks:function(){var t=this._map.getContainer();L.DomEvent.off(t,"mouseleave",this._hide,this).off(document,"keydown",this._onKeyDown,this),L.Browser.touch&&L.DomEvent.off(document,this._touchstart,this._hide,this),this._map.off({contextmenu:this._show,mousedown:this._hide,zoomstart:this._hide},this)},_updateCS:function(){this.defExtCS===M.options.defaultExtCoor&&this.defLocCS===M.options.defaultLocCoor||(this.defExtCS=M.options.defaultExtCoor,this.defLocCS=M.options.defaultLocCoor)},_copyExtent:function(t){let e=(t instanceof KeyboardEvent?this._map:this).contextMenu,o=e.defExtCS?e.defExtCS.toLowerCase():"pcrs",i=(t instanceof KeyboardEvent?this:this.options.mapEl).extent.topLeft[o],n=(t instanceof KeyboardEvent?this:this.options.mapEl).extent.bottomRight[o],a="";"pcrs"===o?a=``:"gcrs"===o?a=``:"tcrs"===o?a=``:"tilematrix"===o?a=``:console.log("not support"),e._copyData(a)},_zoomToLayer:function(t){let e=(t instanceof KeyboardEvent?this._map:this).contextMenu;e._layerClicked.layer._layerEl.zoomTo()},_copyLayer:function(t){let e=(t instanceof KeyboardEvent?this._map:this).contextMenu,o=e._layerClicked.layer._layerEl;e._copyData(o.getOuterHTML())},_zoomToMapExtent:function(t){let e=(t instanceof KeyboardEvent?this._map:this).contextMenu;e._layerClicked.extent.zoomTo()},_copyMapExtent:function(t){let e=(t instanceof KeyboardEvent?this._map:this).contextMenu,o=e._layerClicked.extent;e._copyData(o.getOuterHTML())},_goForward:function(t){let e=(t instanceof KeyboardEvent?this._map:this).options.mapEl;e.forward()},_goBack:function(t){let e=(t instanceof KeyboardEvent?this._map:this).options.mapEl;e.back()},_reload:function(t){let e=(t instanceof KeyboardEvent?this._map:this).options.mapEl;e.reload()},_toggleFullScreen:function(t){let e=(t instanceof KeyboardEvent?this._map:this).options.mapEl;e._toggleFullScreen()},_toggleControls:function(t){let e=(t instanceof KeyboardEvent?this._map:this).options.mapEl;e.controls?e.controls=!1:e.controls=!0},_copyMapML:function(t){let e=(t instanceof KeyboardEvent?this._map:this).contextMenu,o=(t instanceof KeyboardEvent?this._map:this).options.mapEl;e._copyData(o.outerHTML.replace(/
.*?<\/div>|