From 4bac466bb800ef6a3f2ef257674195adc0fc9ac9 Mon Sep 17 00:00:00 2001 From: prushforth Date: Fri, 13 Sep 2024 21:26:14 +0000 Subject: [PATCH] [AUTO] Sync MapML Build --- src/dist/index.html | 15 +++++++++++++++ src/dist/layer.js | 2 +- src/dist/leaflet.js | 2 +- src/dist/map-area.js | 2 +- src/dist/map-caption.js | 2 +- src/dist/map-extent.js | 2 +- src/dist/map-feature.js | 2 +- src/dist/map-input.js | 2 +- src/dist/map-link.js | 2 +- src/dist/map-select.js | 2 +- src/dist/map-style.js | 2 +- src/dist/mapml-viewer.js | 4 ++-- src/dist/mapml-viewer.js.map | 2 +- src/dist/mapml.js | 2 +- src/dist/web-map.js | 4 ++-- src/dist/web-map.js.map | 2 +- 16 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/dist/index.html b/src/dist/index.html index 856d66e..b623811 100644 --- a/src/dist/index.html +++ b/src/dist/index.html @@ -83,6 +83,21 @@ + + + + + All cuisines + African + Asian + Cajun + Indian + Italian + Mexican + + + + diff --git a/src/dist/layer.js b/src/dist/layer.js index 5c40eb6..f527612 100644 --- a/src/dist/layer.js +++ b/src/dist/layer.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 09-09-2024 */ +/*! @maps4html/mapml 13-09-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 ea5c8ff..a183477 100644 --- a/src/dist/leaflet.js +++ b/src/dist/leaflet.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 09-09-2024 */ +/*! @maps4html/mapml 13-09-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 7dc58b0..5b2640b 100644 --- a/src/dist/map-area.js +++ b/src/dist/map-area.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 09-09-2024 */ +/*! @maps4html/mapml 13-09-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 4beafd7..5d33e2d 100644 --- a/src/dist/map-extent.js +++ b/src/dist/map-extent.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 09-09-2024 */ +/*! @maps4html/mapml 13-09-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 800a8b0..4bbe047 100644 --- a/src/dist/map-feature.js +++ b/src/dist/map-feature.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 09-09-2024 */ +/*! @maps4html/mapml 13-09-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 f1dc1ae..777a857 100644 --- a/src/dist/map-input.js +++ b/src/dist/map-input.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 09-09-2024 */ +/*! @maps4html/mapml 13-09-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 011b0cc..38aade3 100644 --- a/src/dist/map-link.js +++ b/src/dist/map-link.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 09-09-2024 */ +/*! @maps4html/mapml 13-09-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,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=this.getLayerEl().src?this.closest("map-extent")?.querySelector(t)??this.getRootNode().querySelector(":host > "+t):M.getClosest(this,"map-extent:has("+t+"),layer-:has("+t+")")?.querySelector(t),t={zoomBounds:this.getZoomBounds(),extentBounds:this.getBounds(),crs:M[this.parentExtent.units],zIndex:this.zIndex,pane:this.parentExtent._extentLayer.getContainer(),linkEl:this,pmtilesRules:t?._pmtilesRules},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-select.js b/src/dist/map-select.js index 78c8839..34df7fe 100644 --- a/src/dist/map-select.js +++ b/src/dist/map-select.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 09-09-2024 */ +/*! @maps4html/mapml 13-09-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 1433402..0584ba6 100644 --- a/src/dist/map-style.js +++ b/src/dist/map-style.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 09-09-2024 */ +/*! @maps4html/mapml 13-09-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 1255048..ec063ae 100644 --- a/src/dist/mapml-viewer.js +++ b/src/dist/mapml-viewer.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 09-09-2024 */ +/*! @maps4html/mapml 13-09-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}; +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);this.whenProjectionDefined(s).then(()=>o()).then(()=>{if(this._map&&this._map.options.projection!==e&&this._resetHistory(),this._debug)for(let t=0;t<2;t++)this.toggleDebug()}).catch(()=>{throw new Error("Undefined projection: "+s)})}}}_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-viewer.js.map b/src/dist/mapml-viewer.js.map index f18ca4c..8cf3220 100644 --- a/src/dist/mapml-viewer.js.map +++ b/src/dist/mapml-viewer.js.map @@ -1 +1 @@ -{"version":3,"file":"mapml-viewer.js","sources":["../src/mapml-viewer.js"],"sourcesContent":["import './leaflet.js'; // bundled with proj4, proj4leaflet, modularized\nimport './mapml.js';\nimport { MapLayer } from './layer.js';\nimport { MapCaption } from './map-caption.js';\nimport { MapFeature } from './map-feature.js';\nimport { MapExtent } from './map-extent.js';\nimport { MapInput } from './map-input.js';\nimport { MapSelect } from './map-select.js';\nimport { MapLink } from './map-link.js';\nimport { MapStyle } from './map-style.js';\n\nexport class MapViewer extends HTMLElement {\n static get observedAttributes() {\n return [\n 'lat',\n 'lon',\n 'zoom',\n 'projection',\n 'width',\n 'height',\n 'controls',\n 'static',\n 'controlslist'\n ];\n }\n // see comments below regarding attributeChangedCallback vs. getter/setter\n // usage. Effectively, the user of the element must use the property, not\n // the getAttribute/setAttribute/removeAttribute DOM API, because the latter\n // calls don't result in the getter/setter being called (so you have to use\n // the getter/setter directly)\n get controls() {\n return this.hasAttribute('controls');\n }\n set controls(value) {\n const hasControls = Boolean(value);\n if (hasControls) {\n this.setAttribute('controls', '');\n } else {\n this.removeAttribute('controls');\n }\n }\n get controlsList() {\n return this._controlsList;\n }\n set controlsList(value) {\n this._controlsList.value = value;\n this.setAttribute('controlslist', value);\n }\n get width() {\n return +window.getComputedStyle(this).width.replace('px', '');\n }\n set width(val) {\n //img.height or img.width setters change or add the corresponding attributes\n this.setAttribute('width', val);\n }\n get height() {\n return +window.getComputedStyle(this).height.replace('px', '');\n }\n set height(val) {\n //img.height or img.width setters change or add the corresponding attributes\n this.setAttribute('height', val);\n }\n get lat() {\n return +(this.hasAttribute('lat') ? this.getAttribute('lat') : 0);\n }\n set lat(val) {\n if (val) {\n this.setAttribute('lat', val);\n }\n }\n get lon() {\n return +(this.hasAttribute('lon') ? this.getAttribute('lon') : 0);\n }\n set lon(val) {\n if (val) {\n this.setAttribute('lon', val);\n }\n }\n get projection() {\n return this.hasAttribute('projection')\n ? this.getAttribute('projection')\n : 'OSMTILE';\n }\n set projection(val) {\n if (val) {\n this.whenProjectionDefined(val)\n .then(() => {\n this.setAttribute('projection', val);\n })\n .catch(() => {\n throw new Error('Undefined projection:' + val);\n });\n }\n }\n get zoom() {\n return +(this.hasAttribute('zoom') ? this.getAttribute('zoom') : 0);\n }\n set zoom(val) {\n var parsedVal = parseInt(val, 10);\n if (!isNaN(parsedVal) && parsedVal >= 0 && parsedVal <= 25) {\n this.setAttribute('zoom', parsedVal);\n }\n }\n get layers() {\n return this.getElementsByTagName('layer-');\n }\n\n get extent() {\n let map = this._map,\n pcrsBounds = M.pixelToPCRSBounds(\n map.getPixelBounds(),\n map.getZoom(),\n map.options.projection\n );\n let formattedExtent = M._convertAndFormatPCRS(\n pcrsBounds,\n map.options.crs,\n this.projection\n );\n // get min/max zoom from layers at this moment\n let minZoom = Infinity,\n maxZoom = -Infinity;\n for (let i = 0; i < this.layers.length; i++) {\n if (this.layers[i].extent) {\n if (this.layers[i].extent.zoom.minZoom < minZoom)\n minZoom = this.layers[i].extent.zoom.minZoom;\n if (this.layers[i].extent.zoom.maxZoom > maxZoom)\n maxZoom = this.layers[i].extent.zoom.maxZoom;\n }\n }\n\n formattedExtent.zoom = {\n minZoom: minZoom !== Infinity ? minZoom : map.getMinZoom(),\n maxZoom: maxZoom !== -Infinity ? maxZoom : map.getMaxZoom()\n };\n return formattedExtent;\n }\n get static() {\n return this.hasAttribute('static');\n }\n set static(value) {\n const isStatic = Boolean(value);\n if (isStatic) this.setAttribute('static', '');\n else this.removeAttribute('static');\n }\n\n constructor() {\n // Always call super first in constructor\n super();\n this._source = this.outerHTML;\n // create an array to track the history of the map and the current index\n this._history = [];\n this._historyIndex = -1;\n this._traversalCall = false;\n }\n connectedCallback() {\n this.whenProjectionDefined(this.projection)\n .then(() => {\n this._initShadowRoot();\n\n this._controlsList = new M.DOMTokenList(\n this.getAttribute('controlslist'),\n this,\n 'controlslist',\n [\n 'noreload',\n 'nofullscreen',\n 'nozoom',\n 'nolayer',\n 'noscale',\n 'geolocation'\n ]\n );\n\n var s = window.getComputedStyle(this),\n wpx = s.width,\n hpx = s.height,\n w = this.hasAttribute('width')\n ? this.getAttribute('width')\n : parseInt(wpx.replace('px', '')),\n h = this.hasAttribute('height')\n ? this.getAttribute('height')\n : parseInt(hpx.replace('px', ''));\n this._changeWidth(w);\n this._changeHeight(h);\n\n this._createMap();\n\n // https://github.com/Maps4HTML/MapML.js/issues/274\n this.setAttribute('role', 'application');\n this._toggleStatic();\n\n /*\n 1. only deletes aria-label when the last (only remaining) map caption is removed\n 2. only deletes aria-label if the aria-label was defined by the map caption element itself\n */\n\n let mapcaption = this.querySelector('map-caption');\n\n if (mapcaption !== null) {\n setTimeout(() => {\n let ariaupdate = this.getAttribute('aria-label');\n\n if (ariaupdate === mapcaption.innerHTML) {\n this.mapCaptionObserver = new MutationObserver((m) => {\n let mapcaptionupdate = this.querySelector('map-caption');\n if (mapcaptionupdate !== mapcaption) {\n this.removeAttribute('aria-label');\n }\n });\n this.mapCaptionObserver.observe(this, {\n childList: true\n });\n }\n }, 0);\n }\n })\n .catch(() => {\n throw new Error('Projection not defined');\n });\n }\n _initShadowRoot() {\n if (!this.shadowRoot) {\n this.attachShadow({ mode: 'open' });\n }\n let tmpl = document.createElement('template');\n /* jshint ignore:start */\n tmpl.innerHTML = ``;\n /* jshint ignore:end */\n\n let shadowRoot = this.shadowRoot;\n this._container = document.createElement('div');\n\n let output =\n \"\";\n this._container.insertAdjacentHTML('beforeend', output);\n\n // Set default styles for the map element.\n let mapDefaultCSS = document.createElement('style');\n mapDefaultCSS.innerHTML =\n `:host {` +\n `all: initial;` + // Reset properties inheritable from html/body, as some inherited styles may cause unexpected issues with the map element's components (https://github.com/Maps4HTML/MapML.js/issues/140).\n `contain: layout size;` + // Contain layout and size calculations within the map element.\n `display: inline-block;` + // This together with dimension properties is required so that Leaflet isn't working with a height=0 box by default.\n `height: 150px;` + // Provide a \"default object size\" (https://github.com/Maps4HTML/HTML-Map-Element/issues/31).\n `width: 300px;` +\n `border-width: 2px;` + // Set a default border for contrast, similar to UA default for iframes.\n `border-style: inset;` +\n `}` +\n `:host([frameborder=\"0\"]) {` +\n `border-width: 0;` +\n `}` +\n `:host([hidden]) {` +\n `display: none!important;` +\n `}` +\n `:host .leaflet-control-container {` +\n `visibility: hidden!important;` + // Visibility hack to improve percieved performance (mitigate FOUC) – visibility is unset in mapml.css! (https://github.com/Maps4HTML/MapML.js/issues/154).\n `}`;\n\n // Hide all (light DOM) children of the map element.\n let hideElementsCSS = document.createElement('style');\n hideElementsCSS.innerHTML =\n `mapml-viewer > * {` + `display: none!important;` + `}`;\n this.appendChild(hideElementsCSS);\n\n // Make the Leaflet container element programmatically identifiable\n // (https://github.com/Leaflet/Leaflet/issues/7193).\n this._container.setAttribute('role', 'region');\n this._container.setAttribute('aria-label', 'Interactive map');\n\n shadowRoot.appendChild(mapDefaultCSS);\n shadowRoot.appendChild(tmpl.content.cloneNode(true));\n shadowRoot.appendChild(this._container);\n }\n _createMap() {\n if (!this._map) {\n this._map = L.map(this._container, {\n center: new L.LatLng(this.lat, this.lon),\n minZoom: 0,\n maxZoom: M[this.projection].options.resolutions.length - 1,\n projection: this.projection,\n query: true,\n contextMenu: true,\n announceMovement: M.options.announceMovement,\n featureIndex: true,\n mapEl: this,\n crs: M[this.projection],\n zoom: this.zoom,\n zoomControl: false\n });\n this._addToHistory();\n\n this._createControls();\n this._toggleControls();\n this._crosshair = M.crosshair().addTo(this._map);\n\n if (M.options.featureIndexOverlayOption)\n this._featureIndexOverlay = M.featureIndexOverlay().addTo(this._map);\n\n this._setUpEvents();\n }\n }\n disconnectedCallback() {\n this._removeEvents();\n while (this.shadowRoot.firstChild) {\n this.shadowRoot.removeChild(this.shadowRoot.firstChild);\n }\n delete this._map;\n this._deleteControls();\n }\n adoptedCallback() {\n // console.log('Custom map element moved to new page.');\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n // console.log('Attribute: ' + name + ' changed from: '+ oldValue + ' to: '+newValue);\n // \"Best practice\": handle side-effects in this callback\n // https://developers.google.com/web/fundamentals/web-components/best-practices\n // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy\n // note that the example is misleading, since the user can't use\n // setAttribute or removeAttribute to set the property, they need to use\n // the property directly in their API usage, which kinda sucks\n /*\n const hasValue = newValue !== null;\n switch (name) {\n case 'checked':\n // Note the attributeChangedCallback is only handling the *side effects*\n // of setting the attribute.\n this.setAttribute('aria-checked', hasValue);\n break;\n ...\n } */\n switch (name) {\n case 'controlslist':\n if (this._controlsList) {\n if (this._controlsList.valueSet === false) {\n this._controlsList.value = newValue;\n }\n this._toggleControls();\n }\n break;\n case 'controls':\n if (oldValue !== null && newValue === null) {\n this._hideControls();\n } else if (oldValue === null && newValue !== null) {\n this._showControls();\n }\n break;\n case 'height':\n if (oldValue !== newValue) {\n this._changeHeight(newValue);\n }\n break;\n case 'width':\n if (oldValue !== newValue) {\n this._changeWidth(newValue);\n }\n break;\n case 'static':\n this._toggleStatic();\n break;\n case 'projection':\n const reconnectLayers = () => {\n // save map location and zoom\n let lat = this.lat;\n let lon = this.lon;\n let zoom = this.zoom;\n // saving the lat, lon and zoom is necessary because Leaflet seems\n // to try to compensate for the change in the scales for each zoom\n // level in the crs by changing the zoom level of the map when\n // you set the map crs. So, we save the current view for use below\n // when all the layers' reconnections have settled.\n // leaflet doesn't like this: https://github.com/Leaflet/Leaflet/issues/2553\n this._map.options.crs = M[newValue];\n this._map.options.projection = newValue;\n let layersReady = [];\n this._map.announceMovement.disable();\n for (let layer of this.querySelectorAll('layer-')) {\n layer.removeAttribute('disabled');\n let reAttach = this.removeChild(layer);\n this.appendChild(reAttach);\n layersReady.push(reAttach.whenReady());\n }\n return Promise.allSettled(layersReady).then(() => {\n // use the saved map location to ensure it is correct after\n // changing the map CRS. Specifically affects projection\n // upgrades, e.g. https://maps4html.org/experiments/custom-projections/BNG/\n // see leaflet bug: https://github.com/Leaflet/Leaflet/issues/2553\n this.zoomTo(lat, lon, zoom);\n if (M.options.announceMovement) this._map.announceMovement.enable();\n // required to delay until map-extent.disabled is correctly set\n // which happens as a result of layer-._validateDisabled()\n // which happens so much we have to delay until they calls are\n // completed\n setTimeout(() => {\n this.dispatchEvent(new CustomEvent('map-projectionchange'));\n }, 0);\n });\n };\n if (\n newValue &&\n this._map &&\n this._map.options.projection !== newValue\n ) {\n const connect = reconnectLayers.bind(this);\n connect().then(() => {\n if (this._map && this._map.options.projection !== oldValue) {\n // this doesn't completely work either\n this._resetHistory();\n }\n if (this._debug) for (let i = 0; i < 2; i++) this.toggleDebug();\n });\n }\n break;\n }\n }\n\n // Creates All map controls and adds them to the map, when created.\n _createControls() {\n let mapSize = this._map.getSize().y,\n totalSize = 0;\n\n this._layerControl = M.layerControl(null, {\n collapsed: true,\n mapEl: this\n }).addTo(this._map);\n this._map.on('movestart', this._layerControl.collapse, this._layerControl);\n\n let scaleValue = M.options.announceScale;\n\n if (scaleValue === 'metric') {\n scaleValue = { metric: true, imperial: false };\n }\n if (scaleValue === 'imperial') {\n scaleValue = { metric: false, imperial: true };\n }\n\n if (!this._scaleBar)\n this._scaleBar = M.scaleBar(scaleValue).addTo(this._map);\n\n // Only add controls if there is enough top left vertical space\n if (!this._zoomControl && totalSize + 93 <= mapSize) {\n totalSize += 93;\n this._zoomControl = L.control.zoom().addTo(this._map);\n }\n if (!this._reloadButton && totalSize + 49 <= mapSize) {\n totalSize += 49;\n this._reloadButton = M.reloadButton().addTo(this._map);\n }\n if (!this._fullScreenControl && totalSize + 49 <= mapSize) {\n totalSize += 49;\n this._fullScreenControl = M.fullscreenButton().addTo(this._map);\n }\n\n if (!this._geolocationButton) {\n this._geolocationButton = M.geolocationButton().addTo(this._map);\n }\n }\n\n // Sets controls by hiding/unhiding them based on the map attribute\n _toggleControls() {\n if (this.controls === false) {\n this._hideControls();\n this._map.contextMenu.toggleContextMenuItem('Controls', 'disabled');\n } else {\n this._showControls();\n this._map.contextMenu.toggleContextMenuItem('Controls', 'enabled');\n }\n }\n\n _hideControls() {\n this._setControlsVisibility('fullscreen', true);\n this._setControlsVisibility('layercontrol', true);\n this._setControlsVisibility('reload', true);\n this._setControlsVisibility('zoom', true);\n this._setControlsVisibility('geolocation', true);\n this._setControlsVisibility('scale', true);\n }\n _showControls() {\n this._setControlsVisibility('fullscreen', false);\n this._setControlsVisibility('layercontrol', false);\n this._setControlsVisibility('reload', false);\n this._setControlsVisibility('zoom', false);\n this._setControlsVisibility('geolocation', true);\n this._setControlsVisibility('scale', false);\n\n // prune the controls shown if necessary\n // this logic could be embedded in _showControls\n // but would require being able to iterate the domain of supported tokens\n // for the controlslist\n if (this._controlsList) {\n this._controlsList.forEach((value) => {\n switch (value.toLowerCase()) {\n case 'nofullscreen':\n this._setControlsVisibility('fullscreen', true);\n break;\n case 'nolayer':\n this._setControlsVisibility('layercontrol', true);\n break;\n case 'noreload':\n this._setControlsVisibility('reload', true);\n break;\n case 'nozoom':\n this._setControlsVisibility('zoom', true);\n break;\n case 'geolocation':\n this._setControlsVisibility('geolocation', false);\n break;\n case 'noscale':\n this._setControlsVisibility('scale', true);\n break;\n }\n });\n }\n if (this._layerControl && this._layerControl._layers.length === 0) {\n this._layerControl._container.setAttribute('hidden', '');\n }\n }\n\n // delete the map controls that are private properties of this custom element\n _deleteControls() {\n delete this._layerControl;\n delete this._zoomControl;\n delete this._reloadButton;\n delete this._fullScreenControl;\n delete this._geolocationButton;\n delete this._scaleBar;\n }\n // Sets the control's visibility AND all its childrens visibility,\n // for the control element based on the Boolean hide parameter\n _setControlsVisibility(control, hide) {\n let container;\n switch (control) {\n case 'zoom':\n if (this._zoomControl) {\n container = this._zoomControl._container;\n }\n break;\n case 'reload':\n if (this._reloadButton) {\n container = this._reloadButton._container;\n }\n break;\n case 'fullscreen':\n if (this._fullScreenControl) {\n container = this._fullScreenControl._container;\n }\n break;\n case 'layercontrol':\n if (this._layerControl) {\n container = this._layerControl._container;\n }\n break;\n case 'geolocation':\n if (this._geolocationButton) {\n container = this._geolocationButton._container;\n }\n break;\n case 'scale':\n if (this._scaleBar) {\n container = this._scaleBar._container;\n }\n break;\n }\n if (container) {\n if (hide) {\n // setting the visibility for all the children of the element\n [...container.children].forEach((childEl) => {\n childEl.setAttribute('hidden', '');\n });\n container.setAttribute('hidden', '');\n } else {\n // setting the visibility for all the children of the element\n [...container.children].forEach((childEl) => {\n childEl.removeAttribute('hidden');\n });\n container.removeAttribute('hidden');\n }\n }\n }\n _toggleStatic() {\n const isStatic = this.hasAttribute('static');\n if (this._map) {\n if (isStatic) {\n this._map.dragging.disable();\n this._map.touchZoom.disable();\n this._map.doubleClickZoom.disable();\n this._map.scrollWheelZoom.disable();\n this._map.boxZoom.disable();\n this._map.keyboard.disable();\n this._zoomControl.disable();\n } else {\n this._map.dragging.enable();\n this._map.touchZoom.enable();\n this._map.doubleClickZoom.enable();\n this._map.scrollWheelZoom.enable();\n this._map.boxZoom.enable();\n this._map.keyboard.enable();\n this._zoomControl.enable();\n }\n }\n }\n\n _dropHandler(event) {\n event.preventDefault();\n let text = event.dataTransfer.getData('text');\n M._pasteLayer(this, text);\n }\n _dragoverHandler(event) {\n event.preventDefault();\n event.dataTransfer.dropEffect = 'copy';\n }\n _removeEvents() {\n if (this._map) {\n this._map.off();\n this.removeEventListener('drop', this._dropHandler, false);\n this.removeEventListener('dragover', this._dragoverHandler, false);\n }\n }\n _setUpEvents() {\n this.addEventListener('drop', this._dropHandler, false);\n this.addEventListener('dragover', this._dragoverHandler, false);\n this.addEventListener(\n 'change',\n function (e) {\n if (e.target.tagName === 'LAYER-') {\n this.dispatchEvent(\n new CustomEvent('layerchange', {\n details: { target: this, originalEvent: e }\n })\n );\n }\n },\n false\n );\n\n let host =\n this.getRootNode() instanceof ShadowRoot\n ? this.getRootNode().host\n : this.parentElement;\n host.addEventListener('keyup', function (e) {\n if (\n e.keyCode === 9 &&\n document.activeElement.nodeName === 'MAPML-VIEWER'\n ) {\n document.activeElement.dispatchEvent(\n new CustomEvent('mapfocused', { detail: { target: this } })\n );\n }\n });\n // pasting layer-, links and geojson using Ctrl+V\n this.addEventListener('keydown', function (e) {\n if (e.keyCode === 86 && e.ctrlKey) {\n navigator.clipboard.readText().then((layer) => {\n M._pasteLayer(this, layer);\n });\n // Prevents default spacebar event on all of mapml-viewer\n } else if (\n e.keyCode === 32 &&\n this.shadowRoot.activeElement.nodeName !== 'INPUT'\n ) {\n e.preventDefault();\n this._map.fire('keypress', { originalEvent: e });\n }\n });\n host.addEventListener('mousedown', function (e) {\n if (document.activeElement.nodeName === 'MAPML-VIEWER') {\n document.activeElement.dispatchEvent(\n new CustomEvent('mapfocused', { detail: { target: this } })\n );\n }\n });\n\n this._map.on(\n 'locationfound',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('maplocationfound', {\n detail: { latlng: e.latlng, accuracy: e.accuracy }\n })\n );\n },\n this\n );\n this._map.on(\n 'locationerror',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('locationerror', { detail: { error: e.message } })\n );\n },\n this\n );\n this._map.on(\n 'load',\n function () {\n this.dispatchEvent(\n new CustomEvent('load', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'preclick',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('preclick', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'click',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('click', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'dblclick',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('dblclick', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mousemove',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mousemove', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mouseover',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mouseover', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mouseout',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mouseout', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mousedown',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mousedown', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mouseup',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mouseup', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'contextmenu',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('contextmenu', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'movestart',\n function () {\n this.dispatchEvent(\n new CustomEvent('movestart', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'move',\n function () {\n this.dispatchEvent(\n new CustomEvent('move', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'moveend',\n function () {\n this._updateMapCenter();\n this._addToHistory();\n this.dispatchEvent(\n new CustomEvent('map-moveend', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'zoomstart',\n function () {\n this.dispatchEvent(\n new CustomEvent('zoomstart', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'zoom',\n function () {\n this.dispatchEvent(\n new CustomEvent('zoom', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'zoomend',\n function () {\n this._updateMapCenter();\n this.dispatchEvent(\n new CustomEvent('zoomend', { detail: { target: this } })\n );\n },\n this\n );\n const setMapMinAndMaxZoom = ((e) => {\n this.whenLayersReady().then(() => {\n if (e && e.layer._layerEl) {\n this._map.setMaxZoom(this.extent.zoom.maxZoom);\n this._map.setMinZoom(this.extent.zoom.minZoom);\n }\n });\n }).bind(this);\n this.whenLayersReady().then(() => {\n this._map.setMaxZoom(this.extent.zoom.maxZoom);\n this._map.setMinZoom(this.extent.zoom.minZoom);\n this._map.on('layeradd layerremove', setMapMinAndMaxZoom, this);\n });\n this.addEventListener('fullscreenchange', function (event) {\n if (document.fullscreenElement === null) {\n // full-screen mode has been exited\n this._map.contextMenu.setViewFullScreenInnerHTML('view');\n } else {\n this._map.contextMenu.setViewFullScreenInnerHTML('exit');\n }\n });\n this.addEventListener('keydown', function (event) {\n if (document.activeElement.nodeName === 'MAPML-VIEWER') {\n // Check if Ctrl+R is pressed and map is focused\n if (event.ctrlKey && event.keyCode === 82) {\n // Prevent default browser behavior\n event.preventDefault();\n this.reload();\n } else if (event.altKey && event.keyCode === 39) {\n // Prevent default browser behavior\n event.preventDefault();\n this.forward();\n } else if (event.altKey && event.keyCode === 37) {\n // Prevent default browser behavior\n event.preventDefault();\n this.back();\n }\n }\n });\n }\n\n locate(options) {\n //options: https://leafletjs.com/reference.html#locate-options\n if (this._geolocationButton) {\n this._geolocationButton.stop();\n }\n if (options) {\n if (options.zoomTo) {\n options.setView = options.zoomTo;\n delete options.zoomTo;\n }\n this._map.locate(options);\n } else {\n this._map.locate({ setView: true, maxZoom: 16 });\n }\n }\n\n toggleDebug() {\n if (this._debug) {\n this._debug.remove();\n this._debug = undefined;\n } else {\n this._debug = M.debugOverlay().addTo(this._map);\n }\n }\n\n _changeWidth(width) {\n if (this._container) {\n this._container.style.width = width + 'px';\n this.shadowRoot.styleSheets[0].cssRules[0].style.width = width + 'px';\n }\n if (this._map) {\n this._map.invalidateSize(false);\n }\n }\n _changeHeight(height) {\n if (this._container) {\n this._container.style.height = height + 'px';\n this.shadowRoot.styleSheets[0].cssRules[0].style.height = height + 'px';\n }\n if (this._map) {\n this._map.invalidateSize(false);\n }\n }\n zoomTo(lat, lon, zoom) {\n zoom = Number.isInteger(+zoom) ? +zoom : this.zoom;\n let location = new L.LatLng(+lat, +lon);\n this._map.setView(location, zoom);\n this.zoom = zoom;\n this.lat = location.lat;\n this.lon = location.lng;\n }\n _updateMapCenter() {\n // remember to tell Leaflet event handler that 'this' in here refers to\n // something other than the map in this case the custom polymer element\n this.lat = this._map.getCenter().lat;\n this.lon = this._map.getCenter().lng;\n this.zoom = this._map.getZoom();\n }\n _resetHistory() {\n this._history = [];\n this._historyIndex = -1;\n this._traversalCall = false;\n // weird but ok\n this._addToHistory();\n }\n /**\n * Adds to the maps history on moveends\n * @private\n */\n _addToHistory() {\n if (this._traversalCall > 0) {\n // this._traversalCall tracks how many consecutive moveends to ignore from history\n this._traversalCall--; // this is useful for ignoring moveends corresponding to back, forward and reload\n return;\n }\n\n let mapLocation = this._map.getPixelBounds().getCenter();\n let location = {\n zoom: this._map.getZoom(),\n x: mapLocation.x,\n y: mapLocation.y\n };\n this._historyIndex++;\n this._history.splice(this._historyIndex, 0, location);\n // Remove future history and overwrite it when map pan/zoom while inside history\n if (this._historyIndex + 1 !== this._history.length) {\n this._history.length = this._historyIndex + 1;\n }\n if (this._historyIndex === 0) {\n // when at initial state of map, disable back, forward, and reload items\n this._map.contextMenu.toggleContextMenuItem('Back', 'disabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'disabled'); // reload contextmenu item\n this._reloadButton?.disable();\n } else {\n this._map.contextMenu.toggleContextMenuItem('Back', 'enabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'enabled'); // reload contextmenu item\n this._reloadButton?.enable();\n }\n }\n /**\n * Allow user to move back in history\n */\n back() {\n let history = this._history;\n let curr = history[this._historyIndex];\n\n if (this._historyIndex > 0) {\n this._map.contextMenu.toggleContextMenuItem('Forward', 'enabled'); // forward contextmenu item\n this._historyIndex--;\n let prev = history[this._historyIndex];\n // Disable back, reload contextmenu item when at the end of history\n if (this._historyIndex === 0) {\n this._map.contextMenu.toggleContextMenuItem('Back', 'disabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'disabled'); // reload contextmenu item\n this._reloadButton?.disable();\n }\n\n if (prev.zoom !== curr.zoom) {\n this._traversalCall = 2; // allows the next 2 moveends to be ignored from history\n\n let currScale = this._map.options.crs.scale(curr.zoom); // gets the scale of the current zoom level\n let prevScale = this._map.options.crs.scale(prev.zoom); // gets the scale of the previous zoom level\n\n let scale = currScale / prevScale; // used to convert the previous pixel location to be in terms of the current zoom level\n\n this._map.panBy([prev.x * scale - curr.x, prev.y * scale - curr.y], {\n animate: false\n });\n this._map.setZoom(prev.zoom);\n } else {\n this._traversalCall = 1;\n this._map.panBy([prev.x - curr.x, prev.y - curr.y]);\n }\n }\n }\n\n /**\n * Allows user to move forward in history\n */\n forward() {\n let history = this._history;\n let curr = history[this._historyIndex];\n if (this._historyIndex < history.length - 1) {\n this._map.contextMenu.toggleContextMenuItem('Back', 'enabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'enabled'); // reload contextmenu item\n this._reloadButton?.enable();\n this._historyIndex++;\n let next = history[this._historyIndex];\n // disable forward contextmenu item, when at the end of forward history\n if (this._historyIndex + 1 === this._history.length) {\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n }\n\n if (next.zoom !== curr.zoom) {\n this._traversalCall = 2; // allows the next 2 moveends to be ignored from history\n\n let currScale = this._map.options.crs.scale(curr.zoom); // gets the scale of the current zoom level\n let nextScale = this._map.options.crs.scale(next.zoom); // gets the scale of the next zoom level\n\n let scale = currScale / nextScale; // used to convert the next pixel location to be in terms of the current zoom level\n\n this._map.panBy([next.x * scale - curr.x, next.y * scale - curr.y], {\n animate: false\n });\n this._map.setZoom(next.zoom);\n } else {\n this._traversalCall = 1;\n this._map.panBy([next.x - curr.x, next.y - curr.y]);\n }\n }\n }\n\n /**\n * Allows the user to reload/reset the map's location to it's initial location\n */\n reload() {\n let initialLocation = this._history.shift();\n let mapLocation = this._map.getPixelBounds().getCenter();\n let curr = {\n zoom: this._map.getZoom(),\n x: mapLocation.x,\n y: mapLocation.y\n };\n\n this._map.contextMenu.toggleContextMenuItem('Back', 'disabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'disabled'); // reload contextmenu item\n this._reloadButton?.disable();\n\n this._history = [initialLocation];\n this._historyIndex = 0;\n\n if (initialLocation.zoom !== curr.zoom) {\n this._traversalCall = 2; // ignores the next 2 moveend events\n\n let currScale = this._map.options.crs.scale(curr.zoom); // gets the scale of the current zoom level\n let initScale = this._map.options.crs.scale(initialLocation.zoom); // gets the scale of the initial location's zoom\n\n let scale = currScale / initScale;\n\n this._map.panBy(\n [\n initialLocation.x * scale - curr.x,\n initialLocation.y * scale - curr.y\n ],\n { animate: false }\n );\n this._map.setZoom(initialLocation.zoom);\n } else {\n // if it's on the same zoom level as the initial location, no need to calculate scales\n this._traversalCall = 1;\n this._map.panBy([initialLocation.x - curr.x, initialLocation.y - curr.y]);\n }\n this._map.getContainer().focus();\n }\n\n _toggleFullScreen() {\n this._map.toggleFullscreen();\n }\n\n viewSource() {\n let blob = new Blob([this._source], { type: 'text/plain' }),\n url = URL.createObjectURL(blob);\n window.open(url);\n URL.revokeObjectURL(url);\n }\n\n defineCustomProjection(jsonTemplate) {\n let t = JSON.parse(jsonTemplate);\n if (\n t === undefined ||\n !t.proj4string ||\n !t.projection ||\n !t.resolutions ||\n !t.origin ||\n !t.bounds\n )\n throw new Error('Incomplete TCRS Definition');\n if (t.projection.indexOf(':') >= 0)\n throw new Error('\":\" is not permitted in projection name');\n if (M[t.projection.toUpperCase()]) return t.projection.toUpperCase();\n let tileSize = [256, 512, 1024, 2048, 4096].includes(t.tilesize)\n ? t.tilesize\n : M.TILE_SIZE;\n\n M[t.projection] = new L.Proj.CRS(t.projection, t.proj4string, {\n origin: t.origin,\n resolutions: t.resolutions,\n bounds: L.bounds(t.bounds),\n crs: {\n tcrs: {\n horizontal: {\n name: 'x',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.bounds.getSize().x /\n M[t.projection].options.resolutions[zoom]\n )\n },\n vertical: {\n name: 'y',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.bounds.getSize().y /\n M[t.projection].options.resolutions[zoom]\n )\n },\n bounds: (zoom) =>\n L.bounds(\n [\n M[t.projection].options.crs.tcrs.horizontal.min,\n M[t.projection].options.crs.tcrs.vertical.min\n ],\n [\n M[t.projection].options.crs.tcrs.horizontal.max(zoom),\n M[t.projection].options.crs.tcrs.vertical.max(zoom)\n ]\n )\n },\n pcrs: {\n horizontal: {\n name: 'easting',\n get min() {\n return M[t.projection].options.bounds.min.x;\n },\n get max() {\n return M[t.projection].options.bounds.max.x;\n }\n },\n vertical: {\n name: 'northing',\n get min() {\n return M[t.projection].options.bounds.min.y;\n },\n get max() {\n return M[t.projection].options.bounds.max.y;\n }\n },\n get bounds() {\n return M[t.projection].options.bounds;\n }\n },\n gcrs: {\n horizontal: {\n name: 'longitude',\n // set min/max axis values from EPSG registry area of use, retrieved 2019-07-25\n get min() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.min)\n .lng;\n },\n get max() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.max)\n .lng;\n }\n },\n vertical: {\n name: 'latitude',\n // set min/max axis values from EPSG registry area of use, retrieved 2019-07-25\n get min() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.min)\n .lat;\n },\n get max() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.max)\n .lat;\n }\n },\n get bounds() {\n return L.latLngBounds(\n [\n M[t.projection].options.crs.gcrs.vertical.min,\n M[t.projection].options.crs.gcrs.horizontal.min\n ],\n [\n M[t.projection].options.crs.gcrs.vertical.max,\n M[t.projection].options.crs.gcrs.horizontal.max\n ]\n );\n }\n },\n map: {\n horizontal: {\n name: 'i',\n min: 0,\n max: (map) => map.getSize().x\n },\n vertical: {\n name: 'j',\n min: 0,\n max: (map) => map.getSize().y\n },\n bounds: (map) => L.bounds(L.point([0, 0]), map.getSize())\n },\n tile: {\n horizontal: {\n name: 'i',\n min: 0,\n max: tileSize\n },\n vertical: {\n name: 'j',\n min: 0,\n max: tileSize\n },\n get bounds() {\n return L.bounds(\n [\n M[t.projection].options.crs.tile.horizontal.min,\n M[t.projection].options.crs.tile.vertical.min\n ],\n [\n M[t.projection].options.crs.tile.horizontal.max,\n M[t.projection].options.crs.tile.vertical.max\n ]\n );\n }\n },\n tilematrix: {\n horizontal: {\n name: 'column',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.crs.tcrs.horizontal.max(zoom) /\n M[t.projection].options.crs.tile.bounds.getSize().x\n )\n },\n vertical: {\n name: 'row',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.crs.tcrs.vertical.max(zoom) /\n M[t.projection].options.crs.tile.bounds.getSize().y\n )\n },\n bounds: (zoom) =>\n L.bounds(\n [\n M[t.projection].options.crs.tilematrix.horizontal.min,\n M[t.projection].options.crs.tilematrix.vertical.min\n ],\n [\n M[t.projection].options.crs.tilematrix.horizontal.max(zoom),\n M[t.projection].options.crs.tilematrix.vertical.max(zoom)\n ]\n )\n }\n }\n }); //creates crs using L.Proj\n M[t.projection.toUpperCase()] = M[t.projection]; //adds the projection uppercase to global M\n return t.projection;\n }\n whenReady() {\n return new Promise((resolve, reject) => {\n let interval, failureTimer;\n if (this._map) {\n resolve();\n } else {\n let viewer = this;\n interval = setInterval(testForMap, 200, viewer);\n failureTimer = setTimeout(mapNotDefined, 5000);\n }\n function testForMap(viewer) {\n if (viewer._map) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n resolve();\n }\n }\n function mapNotDefined() {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Timeout reached waiting for map to be ready');\n }\n });\n }\n whenLayersReady() {\n let layersReady = [];\n // check if all the children elements (map-extent, map-feature) of all layer- are ready\n for (let layer of [...this.layers]) {\n layersReady.push(layer.whenReady());\n }\n return Promise.allSettled(layersReady);\n }\n whenProjectionDefined(projection) {\n return new Promise((resolve, reject) => {\n let interval, failureTimer;\n if (M[projection]) {\n resolve();\n } else {\n interval = setInterval(testForProjection, 200, projection);\n failureTimer = setTimeout(projectionNotDefined, 5000);\n }\n function testForProjection(p) {\n if (M[p]) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n resolve();\n }\n }\n function projectionNotDefined() {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Timeout reached waiting for projection to be defined');\n }\n });\n }\n geojson2mapml(json, options = {}) {\n if (options.projection === undefined) {\n options.projection = this.projection;\n }\n let geojsonLayer = M.geojson2mapml(json, options);\n this.appendChild(geojsonLayer);\n return geojsonLayer;\n }\n}\n// need to provide options { extends: ... } for custom built-in elements\nwindow.customElements.define('mapml-viewer', MapViewer);\nwindow.customElements.define('layer-', MapLayer);\nwindow.customElements.define('map-caption', MapCaption);\nwindow.customElements.define('map-feature', MapFeature);\nwindow.customElements.define('map-extent', MapExtent);\nwindow.customElements.define('map-input', MapInput);\nwindow.customElements.define('map-select', MapSelect);\nwindow.customElements.define('map-link', MapLink);\nwindow.customElements.define('map-style', MapStyle);\n"],"names":["MapLayer","MapCaption","MapFeature","MapExtent","MapInput","MapSelect","MapLink","MapStyle","MapViewer","HTMLElement","observedAttributes","controls","this","hasAttribute","value","Boolean","setAttribute","removeAttribute","controlsList","_controlsList","width","window","getComputedStyle","replace","val","height","lat","getAttribute","lon","projection","whenProjectionDefined","then","catch","Error","zoom","parsedVal","parseInt","isNaN","layers","getElementsByTagName","extent","let","map","_map","pcrsBounds","M","pixelToPCRSBounds","getPixelBounds","getZoom","options","formattedExtent","_convertAndFormatPCRS","crs","minZoom","Infinity","maxZoom","i","length","getMinZoom","getMaxZoom","static","constructor","super","_source","outerHTML","_history","_historyIndex","_traversalCall","connectedCallback","_initShadowRoot","DOMTokenList","s","wpx","hpx","w","h","_changeWidth","_changeHeight","_createMap","_toggleStatic","mapcaption","querySelector","setTimeout","innerHTML","mapCaptionObserver","MutationObserver","observe","childList","shadowRoot","attachShadow","mode","tmpl","document","createElement","URL","import","meta","url","href","_container","insertAdjacentHTML","mapDefaultCSS","hideElementsCSS","appendChild","content","cloneNode","L","center","LatLng","resolutions","query","contextMenu","announceMovement","featureIndex","mapEl","zoomControl","_addToHistory","_createControls","_toggleControls","_crosshair","crosshair","addTo","featureIndexOverlayOption","_featureIndexOverlay","featureIndexOverlay","_setUpEvents","disconnectedCallback","_removeEvents","firstChild","removeChild","_deleteControls","adoptedCallback","attributeChangedCallback","name","oldValue","newValue","valueSet","_hideControls","_showControls","connect","layersReady","disable","layer","querySelectorAll","reAttach","push","whenReady","Promise","allSettled","zoomTo","enable","dispatchEvent","CustomEvent","bind","_resetHistory","_debug","toggleDebug","mapSize","getSize","y","totalSize","_layerControl","layerControl","collapsed","on","collapse","scaleValue","announceScale","metric","imperial","_scaleBar","scaleBar","_zoomControl","control","_reloadButton","reloadButton","_fullScreenControl","fullscreenButton","_geolocationButton","geolocationButton","toggleContextMenuItem","_setControlsVisibility","forEach","toLowerCase","_layers","hide","container","children","childEl","isStatic","dragging","touchZoom","doubleClickZoom","scrollWheelZoom","boxZoom","keyboard","_dropHandler","event","preventDefault","text","dataTransfer","getData","_pasteLayer","_dragoverHandler","dropEffect","off","removeEventListener","addEventListener","e","target","tagName","details","originalEvent","host","getRootNode","ShadowRoot","parentElement","keyCode","activeElement","nodeName","detail","ctrlKey","navigator","clipboard","readText","fire","latlng","accuracy","error","message","lng","x","containerPoint","_updateMapCenter","setMapMinAndMaxZoom","whenLayersReady","_layerEl","setMaxZoom","setMinZoom","fullscreenElement","setViewFullScreenInnerHTML","reload","altKey","forward","back","locate","stop","setView","remove","undefined","debugOverlay","style","styleSheets","cssRules","invalidateSize","Number","isInteger","location","getCenter","mapLocation","splice","prev","history","curr","scale","panBy","animate","setZoom","next","initialLocation","shift","getContainer","focus","_toggleFullScreen","toggleFullscreen","viewSource","blob","Blob","type","createObjectURL","open","revokeObjectURL","defineCustomProjection","jsonTemplate","t","JSON","parse","proj4string","origin","bounds","indexOf","toUpperCase","tileSize","includes","tilesize","TILE_SIZE","Proj","CRS","tcrs","horizontal","min","max","Math","round","vertical","pcrs","gcrs","unproject","OSMTILE","latLngBounds","point","tile","tilematrix","resolve","reject","interval","failureTimer","setInterval","viewer","clearInterval","clearTimeout","p","geojson2mapml","json","geojsonLayer","customElements","define"],"mappings":";;+CAESA,iCACAC,yCACAC,yCACAC,uCACAC,qCACAC,uCACAC,mCACAC,oCAEIC,kBAAkBC,YAC7BC,gCACE,MAAO,CACL,MACA,MACA,OACA,aACA,QACA,SACA,WACA,SACA,gBAQJC,eACE,OAAOC,KAAKC,aAAa,YAE3BF,aAAaG,GACSC,QAAQD,GAE1BF,KAAKI,aAAa,WAAY,IAE9BJ,KAAKK,gBAAgB,YAGzBC,mBACE,OAAON,KAAKO,cAEdD,iBAAiBJ,GACfF,KAAKO,cAAcL,MAAQA,EAC3BF,KAAKI,aAAa,eAAgBF,GAEpCM,YACE,OAAQC,OAAOC,iBAAiBV,MAAMQ,MAAMG,QAAQ,KAAM,IAE5DH,UAAUI,GAERZ,KAAKI,aAAa,QAASQ,GAE7BC,aACE,OAAQJ,OAAOC,iBAAiBV,MAAMa,OAAOF,QAAQ,KAAM,IAE7DE,WAAWD,GAETZ,KAAKI,aAAa,SAAUQ,GAE9BE,UACE,QAASd,KAAKC,aAAa,OAASD,KAAKe,aAAa,OAAS,GAEjED,QAAQF,GACFA,GAC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AAOgT,eAAeC,OAAO,cAAerU,YAC5CoB,OAAOgT,eAAeC,OAAO,cAAepU,YAC5CmB,OAAOgT,eAAeC,OAAO,aAAcnU,WAC3CkB,OAAOgT,eAAeC,OAAO,YAAalU,UAC1CiB,OAAOgT,eAAeC,OAAO,aAAcjU,WAC3CgB,OAAOgT,eAAeC,OAAO,WAAYhU,SACzCe,OAAOgT,eAAeC,OAAO,YAAa/T,iBAj5C7BC"} \ No newline at end of file +{"version":3,"file":"mapml-viewer.js","sources":["../src/mapml-viewer.js"],"sourcesContent":["import './leaflet.js'; // bundled with proj4, proj4leaflet, modularized\nimport './mapml.js';\nimport { MapLayer } from './layer.js';\nimport { MapCaption } from './map-caption.js';\nimport { MapFeature } from './map-feature.js';\nimport { MapExtent } from './map-extent.js';\nimport { MapInput } from './map-input.js';\nimport { MapSelect } from './map-select.js';\nimport { MapLink } from './map-link.js';\nimport { MapStyle } from './map-style.js';\n\nexport class MapViewer extends HTMLElement {\n static get observedAttributes() {\n return [\n 'lat',\n 'lon',\n 'zoom',\n 'projection',\n 'width',\n 'height',\n 'controls',\n 'static',\n 'controlslist'\n ];\n }\n // see comments below regarding attributeChangedCallback vs. getter/setter\n // usage. Effectively, the user of the element must use the property, not\n // the getAttribute/setAttribute/removeAttribute DOM API, because the latter\n // calls don't result in the getter/setter being called (so you have to use\n // the getter/setter directly)\n get controls() {\n return this.hasAttribute('controls');\n }\n set controls(value) {\n const hasControls = Boolean(value);\n if (hasControls) {\n this.setAttribute('controls', '');\n } else {\n this.removeAttribute('controls');\n }\n }\n get controlsList() {\n return this._controlsList;\n }\n set controlsList(value) {\n this._controlsList.value = value;\n this.setAttribute('controlslist', value);\n }\n get width() {\n return +window.getComputedStyle(this).width.replace('px', '');\n }\n set width(val) {\n //img.height or img.width setters change or add the corresponding attributes\n this.setAttribute('width', val);\n }\n get height() {\n return +window.getComputedStyle(this).height.replace('px', '');\n }\n set height(val) {\n //img.height or img.width setters change or add the corresponding attributes\n this.setAttribute('height', val);\n }\n get lat() {\n return +(this.hasAttribute('lat') ? this.getAttribute('lat') : 0);\n }\n set lat(val) {\n if (val) {\n this.setAttribute('lat', val);\n }\n }\n get lon() {\n return +(this.hasAttribute('lon') ? this.getAttribute('lon') : 0);\n }\n set lon(val) {\n if (val) {\n this.setAttribute('lon', val);\n }\n }\n get projection() {\n return this.hasAttribute('projection')\n ? this.getAttribute('projection')\n : 'OSMTILE';\n }\n set projection(val) {\n if (val) {\n this.whenProjectionDefined(val)\n .then(() => {\n this.setAttribute('projection', val);\n })\n .catch(() => {\n throw new Error('Undefined projection: ' + val);\n });\n }\n }\n get zoom() {\n return +(this.hasAttribute('zoom') ? this.getAttribute('zoom') : 0);\n }\n set zoom(val) {\n var parsedVal = parseInt(val, 10);\n if (!isNaN(parsedVal) && parsedVal >= 0 && parsedVal <= 25) {\n this.setAttribute('zoom', parsedVal);\n }\n }\n get layers() {\n return this.getElementsByTagName('layer-');\n }\n\n get extent() {\n let map = this._map,\n pcrsBounds = M.pixelToPCRSBounds(\n map.getPixelBounds(),\n map.getZoom(),\n map.options.projection\n );\n let formattedExtent = M._convertAndFormatPCRS(\n pcrsBounds,\n map.options.crs,\n this.projection\n );\n // get min/max zoom from layers at this moment\n let minZoom = Infinity,\n maxZoom = -Infinity;\n for (let i = 0; i < this.layers.length; i++) {\n if (this.layers[i].extent) {\n if (this.layers[i].extent.zoom.minZoom < minZoom)\n minZoom = this.layers[i].extent.zoom.minZoom;\n if (this.layers[i].extent.zoom.maxZoom > maxZoom)\n maxZoom = this.layers[i].extent.zoom.maxZoom;\n }\n }\n\n formattedExtent.zoom = {\n minZoom: minZoom !== Infinity ? minZoom : map.getMinZoom(),\n maxZoom: maxZoom !== -Infinity ? maxZoom : map.getMaxZoom()\n };\n return formattedExtent;\n }\n get static() {\n return this.hasAttribute('static');\n }\n set static(value) {\n const isStatic = Boolean(value);\n if (isStatic) this.setAttribute('static', '');\n else this.removeAttribute('static');\n }\n\n constructor() {\n // Always call super first in constructor\n super();\n this._source = this.outerHTML;\n // create an array to track the history of the map and the current index\n this._history = [];\n this._historyIndex = -1;\n this._traversalCall = false;\n }\n connectedCallback() {\n this.whenProjectionDefined(this.projection)\n .then(() => {\n this._initShadowRoot();\n\n this._controlsList = new M.DOMTokenList(\n this.getAttribute('controlslist'),\n this,\n 'controlslist',\n [\n 'noreload',\n 'nofullscreen',\n 'nozoom',\n 'nolayer',\n 'noscale',\n 'geolocation'\n ]\n );\n\n var s = window.getComputedStyle(this),\n wpx = s.width,\n hpx = s.height,\n w = this.hasAttribute('width')\n ? this.getAttribute('width')\n : parseInt(wpx.replace('px', '')),\n h = this.hasAttribute('height')\n ? this.getAttribute('height')\n : parseInt(hpx.replace('px', ''));\n this._changeWidth(w);\n this._changeHeight(h);\n\n this._createMap();\n\n // https://github.com/Maps4HTML/MapML.js/issues/274\n this.setAttribute('role', 'application');\n this._toggleStatic();\n\n /*\n 1. only deletes aria-label when the last (only remaining) map caption is removed\n 2. only deletes aria-label if the aria-label was defined by the map caption element itself\n */\n\n let mapcaption = this.querySelector('map-caption');\n\n if (mapcaption !== null) {\n setTimeout(() => {\n let ariaupdate = this.getAttribute('aria-label');\n\n if (ariaupdate === mapcaption.innerHTML) {\n this.mapCaptionObserver = new MutationObserver((m) => {\n let mapcaptionupdate = this.querySelector('map-caption');\n if (mapcaptionupdate !== mapcaption) {\n this.removeAttribute('aria-label');\n }\n });\n this.mapCaptionObserver.observe(this, {\n childList: true\n });\n }\n }, 0);\n }\n })\n .catch(() => {\n throw new Error('Projection not defined');\n });\n }\n _initShadowRoot() {\n if (!this.shadowRoot) {\n this.attachShadow({ mode: 'open' });\n }\n let tmpl = document.createElement('template');\n /* jshint ignore:start */\n tmpl.innerHTML = ``;\n /* jshint ignore:end */\n\n let shadowRoot = this.shadowRoot;\n this._container = document.createElement('div');\n\n let output =\n \"\";\n this._container.insertAdjacentHTML('beforeend', output);\n\n // Set default styles for the map element.\n let mapDefaultCSS = document.createElement('style');\n mapDefaultCSS.innerHTML =\n `:host {` +\n `all: initial;` + // Reset properties inheritable from html/body, as some inherited styles may cause unexpected issues with the map element's components (https://github.com/Maps4HTML/MapML.js/issues/140).\n `contain: layout size;` + // Contain layout and size calculations within the map element.\n `display: inline-block;` + // This together with dimension properties is required so that Leaflet isn't working with a height=0 box by default.\n `height: 150px;` + // Provide a \"default object size\" (https://github.com/Maps4HTML/HTML-Map-Element/issues/31).\n `width: 300px;` +\n `border-width: 2px;` + // Set a default border for contrast, similar to UA default for iframes.\n `border-style: inset;` +\n `}` +\n `:host([frameborder=\"0\"]) {` +\n `border-width: 0;` +\n `}` +\n `:host([hidden]) {` +\n `display: none!important;` +\n `}` +\n `:host .leaflet-control-container {` +\n `visibility: hidden!important;` + // Visibility hack to improve percieved performance (mitigate FOUC) – visibility is unset in mapml.css! (https://github.com/Maps4HTML/MapML.js/issues/154).\n `}`;\n\n // Hide all (light DOM) children of the map element.\n let hideElementsCSS = document.createElement('style');\n hideElementsCSS.innerHTML =\n `mapml-viewer > * {` + `display: none!important;` + `}`;\n this.appendChild(hideElementsCSS);\n\n // Make the Leaflet container element programmatically identifiable\n // (https://github.com/Leaflet/Leaflet/issues/7193).\n this._container.setAttribute('role', 'region');\n this._container.setAttribute('aria-label', 'Interactive map');\n\n shadowRoot.appendChild(mapDefaultCSS);\n shadowRoot.appendChild(tmpl.content.cloneNode(true));\n shadowRoot.appendChild(this._container);\n }\n _createMap() {\n if (!this._map) {\n this._map = L.map(this._container, {\n center: new L.LatLng(this.lat, this.lon),\n minZoom: 0,\n maxZoom: M[this.projection].options.resolutions.length - 1,\n projection: this.projection,\n query: true,\n contextMenu: true,\n announceMovement: M.options.announceMovement,\n featureIndex: true,\n mapEl: this,\n crs: M[this.projection],\n zoom: this.zoom,\n zoomControl: false\n });\n this._addToHistory();\n\n this._createControls();\n this._toggleControls();\n this._crosshair = M.crosshair().addTo(this._map);\n\n if (M.options.featureIndexOverlayOption)\n this._featureIndexOverlay = M.featureIndexOverlay().addTo(this._map);\n\n this._setUpEvents();\n }\n }\n disconnectedCallback() {\n this._removeEvents();\n while (this.shadowRoot.firstChild) {\n this.shadowRoot.removeChild(this.shadowRoot.firstChild);\n }\n delete this._map;\n this._deleteControls();\n }\n adoptedCallback() {\n // console.log('Custom map element moved to new page.');\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n // console.log('Attribute: ' + name + ' changed from: '+ oldValue + ' to: '+newValue);\n // \"Best practice\": handle side-effects in this callback\n // https://developers.google.com/web/fundamentals/web-components/best-practices\n // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy\n // note that the example is misleading, since the user can't use\n // setAttribute or removeAttribute to set the property, they need to use\n // the property directly in their API usage, which kinda sucks\n /*\n const hasValue = newValue !== null;\n switch (name) {\n case 'checked':\n // Note the attributeChangedCallback is only handling the *side effects*\n // of setting the attribute.\n this.setAttribute('aria-checked', hasValue);\n break;\n ...\n } */\n switch (name) {\n case 'controlslist':\n if (this._controlsList) {\n if (this._controlsList.valueSet === false) {\n this._controlsList.value = newValue;\n }\n this._toggleControls();\n }\n break;\n case 'controls':\n if (oldValue !== null && newValue === null) {\n this._hideControls();\n } else if (oldValue === null && newValue !== null) {\n this._showControls();\n }\n break;\n case 'height':\n if (oldValue !== newValue) {\n this._changeHeight(newValue);\n }\n break;\n case 'width':\n if (oldValue !== newValue) {\n this._changeWidth(newValue);\n }\n break;\n case 'static':\n this._toggleStatic();\n break;\n case 'projection':\n const reconnectLayers = () => {\n // save map location and zoom\n let lat = this.lat;\n let lon = this.lon;\n let zoom = this.zoom;\n // saving the lat, lon and zoom is necessary because Leaflet seems\n // to try to compensate for the change in the scales for each zoom\n // level in the crs by changing the zoom level of the map when\n // you set the map crs. So, we save the current view for use below\n // when all the layers' reconnections have settled.\n // leaflet doesn't like this: https://github.com/Leaflet/Leaflet/issues/2553\n this._map.options.crs = M[newValue];\n this._map.options.projection = newValue;\n let layersReady = [];\n this._map.announceMovement.disable();\n for (let layer of this.querySelectorAll('layer-')) {\n layer.removeAttribute('disabled');\n let reAttach = this.removeChild(layer);\n this.appendChild(reAttach);\n layersReady.push(reAttach.whenReady());\n }\n return Promise.allSettled(layersReady).then(() => {\n // use the saved map location to ensure it is correct after\n // changing the map CRS. Specifically affects projection\n // upgrades, e.g. https://maps4html.org/experiments/custom-projections/BNG/\n // see leaflet bug: https://github.com/Leaflet/Leaflet/issues/2553\n this.zoomTo(lat, lon, zoom);\n if (M.options.announceMovement) this._map.announceMovement.enable();\n // required to delay until map-extent.disabled is correctly set\n // which happens as a result of layer-._validateDisabled()\n // which happens so much we have to delay until they calls are\n // completed\n setTimeout(() => {\n this.dispatchEvent(new CustomEvent('map-projectionchange'));\n }, 0);\n });\n };\n if (\n newValue &&\n this._map &&\n this._map.options.projection !== newValue\n ) {\n const connect = reconnectLayers.bind(this);\n this.whenProjectionDefined(newValue)\n .then(() => connect())\n .then(() => {\n if (this._map && this._map.options.projection !== oldValue) {\n // this doesn't completely work either\n this._resetHistory();\n }\n if (this._debug) for (let i = 0; i < 2; i++) this.toggleDebug();\n })\n .catch(() => {\n throw new Error('Undefined projection: ' + newValue);\n });\n }\n break;\n }\n }\n\n // Creates All map controls and adds them to the map, when created.\n _createControls() {\n let mapSize = this._map.getSize().y,\n totalSize = 0;\n\n this._layerControl = M.layerControl(null, {\n collapsed: true,\n mapEl: this\n }).addTo(this._map);\n this._map.on('movestart', this._layerControl.collapse, this._layerControl);\n\n let scaleValue = M.options.announceScale;\n\n if (scaleValue === 'metric') {\n scaleValue = { metric: true, imperial: false };\n }\n if (scaleValue === 'imperial') {\n scaleValue = { metric: false, imperial: true };\n }\n\n if (!this._scaleBar)\n this._scaleBar = M.scaleBar(scaleValue).addTo(this._map);\n\n // Only add controls if there is enough top left vertical space\n if (!this._zoomControl && totalSize + 93 <= mapSize) {\n totalSize += 93;\n this._zoomControl = L.control.zoom().addTo(this._map);\n }\n if (!this._reloadButton && totalSize + 49 <= mapSize) {\n totalSize += 49;\n this._reloadButton = M.reloadButton().addTo(this._map);\n }\n if (!this._fullScreenControl && totalSize + 49 <= mapSize) {\n totalSize += 49;\n this._fullScreenControl = M.fullscreenButton().addTo(this._map);\n }\n\n if (!this._geolocationButton) {\n this._geolocationButton = M.geolocationButton().addTo(this._map);\n }\n }\n\n // Sets controls by hiding/unhiding them based on the map attribute\n _toggleControls() {\n if (this.controls === false) {\n this._hideControls();\n this._map.contextMenu.toggleContextMenuItem('Controls', 'disabled');\n } else {\n this._showControls();\n this._map.contextMenu.toggleContextMenuItem('Controls', 'enabled');\n }\n }\n\n _hideControls() {\n this._setControlsVisibility('fullscreen', true);\n this._setControlsVisibility('layercontrol', true);\n this._setControlsVisibility('reload', true);\n this._setControlsVisibility('zoom', true);\n this._setControlsVisibility('geolocation', true);\n this._setControlsVisibility('scale', true);\n }\n _showControls() {\n this._setControlsVisibility('fullscreen', false);\n this._setControlsVisibility('layercontrol', false);\n this._setControlsVisibility('reload', false);\n this._setControlsVisibility('zoom', false);\n this._setControlsVisibility('geolocation', true);\n this._setControlsVisibility('scale', false);\n\n // prune the controls shown if necessary\n // this logic could be embedded in _showControls\n // but would require being able to iterate the domain of supported tokens\n // for the controlslist\n if (this._controlsList) {\n this._controlsList.forEach((value) => {\n switch (value.toLowerCase()) {\n case 'nofullscreen':\n this._setControlsVisibility('fullscreen', true);\n break;\n case 'nolayer':\n this._setControlsVisibility('layercontrol', true);\n break;\n case 'noreload':\n this._setControlsVisibility('reload', true);\n break;\n case 'nozoom':\n this._setControlsVisibility('zoom', true);\n break;\n case 'geolocation':\n this._setControlsVisibility('geolocation', false);\n break;\n case 'noscale':\n this._setControlsVisibility('scale', true);\n break;\n }\n });\n }\n if (this._layerControl && this._layerControl._layers.length === 0) {\n this._layerControl._container.setAttribute('hidden', '');\n }\n }\n\n // delete the map controls that are private properties of this custom element\n _deleteControls() {\n delete this._layerControl;\n delete this._zoomControl;\n delete this._reloadButton;\n delete this._fullScreenControl;\n delete this._geolocationButton;\n delete this._scaleBar;\n }\n // Sets the control's visibility AND all its childrens visibility,\n // for the control element based on the Boolean hide parameter\n _setControlsVisibility(control, hide) {\n let container;\n switch (control) {\n case 'zoom':\n if (this._zoomControl) {\n container = this._zoomControl._container;\n }\n break;\n case 'reload':\n if (this._reloadButton) {\n container = this._reloadButton._container;\n }\n break;\n case 'fullscreen':\n if (this._fullScreenControl) {\n container = this._fullScreenControl._container;\n }\n break;\n case 'layercontrol':\n if (this._layerControl) {\n container = this._layerControl._container;\n }\n break;\n case 'geolocation':\n if (this._geolocationButton) {\n container = this._geolocationButton._container;\n }\n break;\n case 'scale':\n if (this._scaleBar) {\n container = this._scaleBar._container;\n }\n break;\n }\n if (container) {\n if (hide) {\n // setting the visibility for all the children of the element\n [...container.children].forEach((childEl) => {\n childEl.setAttribute('hidden', '');\n });\n container.setAttribute('hidden', '');\n } else {\n // setting the visibility for all the children of the element\n [...container.children].forEach((childEl) => {\n childEl.removeAttribute('hidden');\n });\n container.removeAttribute('hidden');\n }\n }\n }\n _toggleStatic() {\n const isStatic = this.hasAttribute('static');\n if (this._map) {\n if (isStatic) {\n this._map.dragging.disable();\n this._map.touchZoom.disable();\n this._map.doubleClickZoom.disable();\n this._map.scrollWheelZoom.disable();\n this._map.boxZoom.disable();\n this._map.keyboard.disable();\n this._zoomControl.disable();\n } else {\n this._map.dragging.enable();\n this._map.touchZoom.enable();\n this._map.doubleClickZoom.enable();\n this._map.scrollWheelZoom.enable();\n this._map.boxZoom.enable();\n this._map.keyboard.enable();\n this._zoomControl.enable();\n }\n }\n }\n\n _dropHandler(event) {\n event.preventDefault();\n let text = event.dataTransfer.getData('text');\n M._pasteLayer(this, text);\n }\n _dragoverHandler(event) {\n event.preventDefault();\n event.dataTransfer.dropEffect = 'copy';\n }\n _removeEvents() {\n if (this._map) {\n this._map.off();\n this.removeEventListener('drop', this._dropHandler, false);\n this.removeEventListener('dragover', this._dragoverHandler, false);\n }\n }\n _setUpEvents() {\n this.addEventListener('drop', this._dropHandler, false);\n this.addEventListener('dragover', this._dragoverHandler, false);\n this.addEventListener(\n 'change',\n function (e) {\n if (e.target.tagName === 'LAYER-') {\n this.dispatchEvent(\n new CustomEvent('layerchange', {\n details: { target: this, originalEvent: e }\n })\n );\n }\n },\n false\n );\n\n let host =\n this.getRootNode() instanceof ShadowRoot\n ? this.getRootNode().host\n : this.parentElement;\n host.addEventListener('keyup', function (e) {\n if (\n e.keyCode === 9 &&\n document.activeElement.nodeName === 'MAPML-VIEWER'\n ) {\n document.activeElement.dispatchEvent(\n new CustomEvent('mapfocused', { detail: { target: this } })\n );\n }\n });\n // pasting layer-, links and geojson using Ctrl+V\n this.addEventListener('keydown', function (e) {\n if (e.keyCode === 86 && e.ctrlKey) {\n navigator.clipboard.readText().then((layer) => {\n M._pasteLayer(this, layer);\n });\n // Prevents default spacebar event on all of mapml-viewer\n } else if (\n e.keyCode === 32 &&\n this.shadowRoot.activeElement.nodeName !== 'INPUT'\n ) {\n e.preventDefault();\n this._map.fire('keypress', { originalEvent: e });\n }\n });\n host.addEventListener('mousedown', function (e) {\n if (document.activeElement.nodeName === 'MAPML-VIEWER') {\n document.activeElement.dispatchEvent(\n new CustomEvent('mapfocused', { detail: { target: this } })\n );\n }\n });\n\n this._map.on(\n 'locationfound',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('maplocationfound', {\n detail: { latlng: e.latlng, accuracy: e.accuracy }\n })\n );\n },\n this\n );\n this._map.on(\n 'locationerror',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('locationerror', { detail: { error: e.message } })\n );\n },\n this\n );\n this._map.on(\n 'load',\n function () {\n this.dispatchEvent(\n new CustomEvent('load', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'preclick',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('preclick', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'click',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('click', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'dblclick',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('dblclick', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mousemove',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mousemove', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mouseover',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mouseover', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mouseout',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mouseout', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mousedown',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mousedown', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mouseup',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mouseup', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'contextmenu',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('contextmenu', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'movestart',\n function () {\n this.dispatchEvent(\n new CustomEvent('movestart', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'move',\n function () {\n this.dispatchEvent(\n new CustomEvent('move', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'moveend',\n function () {\n this._updateMapCenter();\n this._addToHistory();\n this.dispatchEvent(\n new CustomEvent('map-moveend', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'zoomstart',\n function () {\n this.dispatchEvent(\n new CustomEvent('zoomstart', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'zoom',\n function () {\n this.dispatchEvent(\n new CustomEvent('zoom', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'zoomend',\n function () {\n this._updateMapCenter();\n this.dispatchEvent(\n new CustomEvent('zoomend', { detail: { target: this } })\n );\n },\n this\n );\n const setMapMinAndMaxZoom = ((e) => {\n this.whenLayersReady().then(() => {\n if (e && e.layer._layerEl) {\n this._map.setMaxZoom(this.extent.zoom.maxZoom);\n this._map.setMinZoom(this.extent.zoom.minZoom);\n }\n });\n }).bind(this);\n this.whenLayersReady().then(() => {\n this._map.setMaxZoom(this.extent.zoom.maxZoom);\n this._map.setMinZoom(this.extent.zoom.minZoom);\n this._map.on('layeradd layerremove', setMapMinAndMaxZoom, this);\n });\n this.addEventListener('fullscreenchange', function (event) {\n if (document.fullscreenElement === null) {\n // full-screen mode has been exited\n this._map.contextMenu.setViewFullScreenInnerHTML('view');\n } else {\n this._map.contextMenu.setViewFullScreenInnerHTML('exit');\n }\n });\n this.addEventListener('keydown', function (event) {\n if (document.activeElement.nodeName === 'MAPML-VIEWER') {\n // Check if Ctrl+R is pressed and map is focused\n if (event.ctrlKey && event.keyCode === 82) {\n // Prevent default browser behavior\n event.preventDefault();\n this.reload();\n } else if (event.altKey && event.keyCode === 39) {\n // Prevent default browser behavior\n event.preventDefault();\n this.forward();\n } else if (event.altKey && event.keyCode === 37) {\n // Prevent default browser behavior\n event.preventDefault();\n this.back();\n }\n }\n });\n }\n\n locate(options) {\n //options: https://leafletjs.com/reference.html#locate-options\n if (this._geolocationButton) {\n this._geolocationButton.stop();\n }\n if (options) {\n if (options.zoomTo) {\n options.setView = options.zoomTo;\n delete options.zoomTo;\n }\n this._map.locate(options);\n } else {\n this._map.locate({ setView: true, maxZoom: 16 });\n }\n }\n\n toggleDebug() {\n if (this._debug) {\n this._debug.remove();\n this._debug = undefined;\n } else {\n this._debug = M.debugOverlay().addTo(this._map);\n }\n }\n\n _changeWidth(width) {\n if (this._container) {\n this._container.style.width = width + 'px';\n this.shadowRoot.styleSheets[0].cssRules[0].style.width = width + 'px';\n }\n if (this._map) {\n this._map.invalidateSize(false);\n }\n }\n _changeHeight(height) {\n if (this._container) {\n this._container.style.height = height + 'px';\n this.shadowRoot.styleSheets[0].cssRules[0].style.height = height + 'px';\n }\n if (this._map) {\n this._map.invalidateSize(false);\n }\n }\n zoomTo(lat, lon, zoom) {\n zoom = Number.isInteger(+zoom) ? +zoom : this.zoom;\n let location = new L.LatLng(+lat, +lon);\n this._map.setView(location, zoom);\n this.zoom = zoom;\n this.lat = location.lat;\n this.lon = location.lng;\n }\n _updateMapCenter() {\n // remember to tell Leaflet event handler that 'this' in here refers to\n // something other than the map in this case the custom polymer element\n this.lat = this._map.getCenter().lat;\n this.lon = this._map.getCenter().lng;\n this.zoom = this._map.getZoom();\n }\n _resetHistory() {\n this._history = [];\n this._historyIndex = -1;\n this._traversalCall = false;\n // weird but ok\n this._addToHistory();\n }\n /**\n * Adds to the maps history on moveends\n * @private\n */\n _addToHistory() {\n if (this._traversalCall > 0) {\n // this._traversalCall tracks how many consecutive moveends to ignore from history\n this._traversalCall--; // this is useful for ignoring moveends corresponding to back, forward and reload\n return;\n }\n\n let mapLocation = this._map.getPixelBounds().getCenter();\n let location = {\n zoom: this._map.getZoom(),\n x: mapLocation.x,\n y: mapLocation.y\n };\n this._historyIndex++;\n this._history.splice(this._historyIndex, 0, location);\n // Remove future history and overwrite it when map pan/zoom while inside history\n if (this._historyIndex + 1 !== this._history.length) {\n this._history.length = this._historyIndex + 1;\n }\n if (this._historyIndex === 0) {\n // when at initial state of map, disable back, forward, and reload items\n this._map.contextMenu.toggleContextMenuItem('Back', 'disabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'disabled'); // reload contextmenu item\n this._reloadButton?.disable();\n } else {\n this._map.contextMenu.toggleContextMenuItem('Back', 'enabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'enabled'); // reload contextmenu item\n this._reloadButton?.enable();\n }\n }\n /**\n * Allow user to move back in history\n */\n back() {\n let history = this._history;\n let curr = history[this._historyIndex];\n\n if (this._historyIndex > 0) {\n this._map.contextMenu.toggleContextMenuItem('Forward', 'enabled'); // forward contextmenu item\n this._historyIndex--;\n let prev = history[this._historyIndex];\n // Disable back, reload contextmenu item when at the end of history\n if (this._historyIndex === 0) {\n this._map.contextMenu.toggleContextMenuItem('Back', 'disabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'disabled'); // reload contextmenu item\n this._reloadButton?.disable();\n }\n\n if (prev.zoom !== curr.zoom) {\n this._traversalCall = 2; // allows the next 2 moveends to be ignored from history\n\n let currScale = this._map.options.crs.scale(curr.zoom); // gets the scale of the current zoom level\n let prevScale = this._map.options.crs.scale(prev.zoom); // gets the scale of the previous zoom level\n\n let scale = currScale / prevScale; // used to convert the previous pixel location to be in terms of the current zoom level\n\n this._map.panBy([prev.x * scale - curr.x, prev.y * scale - curr.y], {\n animate: false\n });\n this._map.setZoom(prev.zoom);\n } else {\n this._traversalCall = 1;\n this._map.panBy([prev.x - curr.x, prev.y - curr.y]);\n }\n }\n }\n\n /**\n * Allows user to move forward in history\n */\n forward() {\n let history = this._history;\n let curr = history[this._historyIndex];\n if (this._historyIndex < history.length - 1) {\n this._map.contextMenu.toggleContextMenuItem('Back', 'enabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'enabled'); // reload contextmenu item\n this._reloadButton?.enable();\n this._historyIndex++;\n let next = history[this._historyIndex];\n // disable forward contextmenu item, when at the end of forward history\n if (this._historyIndex + 1 === this._history.length) {\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n }\n\n if (next.zoom !== curr.zoom) {\n this._traversalCall = 2; // allows the next 2 moveends to be ignored from history\n\n let currScale = this._map.options.crs.scale(curr.zoom); // gets the scale of the current zoom level\n let nextScale = this._map.options.crs.scale(next.zoom); // gets the scale of the next zoom level\n\n let scale = currScale / nextScale; // used to convert the next pixel location to be in terms of the current zoom level\n\n this._map.panBy([next.x * scale - curr.x, next.y * scale - curr.y], {\n animate: false\n });\n this._map.setZoom(next.zoom);\n } else {\n this._traversalCall = 1;\n this._map.panBy([next.x - curr.x, next.y - curr.y]);\n }\n }\n }\n\n /**\n * Allows the user to reload/reset the map's location to it's initial location\n */\n reload() {\n let initialLocation = this._history.shift();\n let mapLocation = this._map.getPixelBounds().getCenter();\n let curr = {\n zoom: this._map.getZoom(),\n x: mapLocation.x,\n y: mapLocation.y\n };\n\n this._map.contextMenu.toggleContextMenuItem('Back', 'disabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'disabled'); // reload contextmenu item\n this._reloadButton?.disable();\n\n this._history = [initialLocation];\n this._historyIndex = 0;\n\n if (initialLocation.zoom !== curr.zoom) {\n this._traversalCall = 2; // ignores the next 2 moveend events\n\n let currScale = this._map.options.crs.scale(curr.zoom); // gets the scale of the current zoom level\n let initScale = this._map.options.crs.scale(initialLocation.zoom); // gets the scale of the initial location's zoom\n\n let scale = currScale / initScale;\n\n this._map.panBy(\n [\n initialLocation.x * scale - curr.x,\n initialLocation.y * scale - curr.y\n ],\n { animate: false }\n );\n this._map.setZoom(initialLocation.zoom);\n } else {\n // if it's on the same zoom level as the initial location, no need to calculate scales\n this._traversalCall = 1;\n this._map.panBy([initialLocation.x - curr.x, initialLocation.y - curr.y]);\n }\n this._map.getContainer().focus();\n }\n\n _toggleFullScreen() {\n this._map.toggleFullscreen();\n }\n\n viewSource() {\n let blob = new Blob([this._source], { type: 'text/plain' }),\n url = URL.createObjectURL(blob);\n window.open(url);\n URL.revokeObjectURL(url);\n }\n\n defineCustomProjection(jsonTemplate) {\n let t = JSON.parse(jsonTemplate);\n if (\n t === undefined ||\n !t.proj4string ||\n !t.projection ||\n !t.resolutions ||\n !t.origin ||\n !t.bounds\n )\n throw new Error('Incomplete TCRS Definition');\n if (t.projection.indexOf(':') >= 0)\n throw new Error('\":\" is not permitted in projection name');\n if (M[t.projection.toUpperCase()]) return t.projection.toUpperCase();\n let tileSize = [256, 512, 1024, 2048, 4096].includes(t.tilesize)\n ? t.tilesize\n : M.TILE_SIZE;\n\n M[t.projection] = new L.Proj.CRS(t.projection, t.proj4string, {\n origin: t.origin,\n resolutions: t.resolutions,\n bounds: L.bounds(t.bounds),\n crs: {\n tcrs: {\n horizontal: {\n name: 'x',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.bounds.getSize().x /\n M[t.projection].options.resolutions[zoom]\n )\n },\n vertical: {\n name: 'y',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.bounds.getSize().y /\n M[t.projection].options.resolutions[zoom]\n )\n },\n bounds: (zoom) =>\n L.bounds(\n [\n M[t.projection].options.crs.tcrs.horizontal.min,\n M[t.projection].options.crs.tcrs.vertical.min\n ],\n [\n M[t.projection].options.crs.tcrs.horizontal.max(zoom),\n M[t.projection].options.crs.tcrs.vertical.max(zoom)\n ]\n )\n },\n pcrs: {\n horizontal: {\n name: 'easting',\n get min() {\n return M[t.projection].options.bounds.min.x;\n },\n get max() {\n return M[t.projection].options.bounds.max.x;\n }\n },\n vertical: {\n name: 'northing',\n get min() {\n return M[t.projection].options.bounds.min.y;\n },\n get max() {\n return M[t.projection].options.bounds.max.y;\n }\n },\n get bounds() {\n return M[t.projection].options.bounds;\n }\n },\n gcrs: {\n horizontal: {\n name: 'longitude',\n // set min/max axis values from EPSG registry area of use, retrieved 2019-07-25\n get min() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.min)\n .lng;\n },\n get max() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.max)\n .lng;\n }\n },\n vertical: {\n name: 'latitude',\n // set min/max axis values from EPSG registry area of use, retrieved 2019-07-25\n get min() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.min)\n .lat;\n },\n get max() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.max)\n .lat;\n }\n },\n get bounds() {\n return L.latLngBounds(\n [\n M[t.projection].options.crs.gcrs.vertical.min,\n M[t.projection].options.crs.gcrs.horizontal.min\n ],\n [\n M[t.projection].options.crs.gcrs.vertical.max,\n M[t.projection].options.crs.gcrs.horizontal.max\n ]\n );\n }\n },\n map: {\n horizontal: {\n name: 'i',\n min: 0,\n max: (map) => map.getSize().x\n },\n vertical: {\n name: 'j',\n min: 0,\n max: (map) => map.getSize().y\n },\n bounds: (map) => L.bounds(L.point([0, 0]), map.getSize())\n },\n tile: {\n horizontal: {\n name: 'i',\n min: 0,\n max: tileSize\n },\n vertical: {\n name: 'j',\n min: 0,\n max: tileSize\n },\n get bounds() {\n return L.bounds(\n [\n M[t.projection].options.crs.tile.horizontal.min,\n M[t.projection].options.crs.tile.vertical.min\n ],\n [\n M[t.projection].options.crs.tile.horizontal.max,\n M[t.projection].options.crs.tile.vertical.max\n ]\n );\n }\n },\n tilematrix: {\n horizontal: {\n name: 'column',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.crs.tcrs.horizontal.max(zoom) /\n M[t.projection].options.crs.tile.bounds.getSize().x\n )\n },\n vertical: {\n name: 'row',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.crs.tcrs.vertical.max(zoom) /\n M[t.projection].options.crs.tile.bounds.getSize().y\n )\n },\n bounds: (zoom) =>\n L.bounds(\n [\n M[t.projection].options.crs.tilematrix.horizontal.min,\n M[t.projection].options.crs.tilematrix.vertical.min\n ],\n [\n M[t.projection].options.crs.tilematrix.horizontal.max(zoom),\n M[t.projection].options.crs.tilematrix.vertical.max(zoom)\n ]\n )\n }\n }\n }); //creates crs using L.Proj\n M[t.projection.toUpperCase()] = M[t.projection]; //adds the projection uppercase to global M\n return t.projection;\n }\n whenReady() {\n return new Promise((resolve, reject) => {\n let interval, failureTimer;\n if (this._map) {\n resolve();\n } else {\n let viewer = this;\n interval = setInterval(testForMap, 200, viewer);\n failureTimer = setTimeout(mapNotDefined, 5000);\n }\n function testForMap(viewer) {\n if (viewer._map) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n resolve();\n }\n }\n function mapNotDefined() {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Timeout reached waiting for map to be ready');\n }\n });\n }\n whenLayersReady() {\n let layersReady = [];\n // check if all the children elements (map-extent, map-feature) of all layer- are ready\n for (let layer of [...this.layers]) {\n layersReady.push(layer.whenReady());\n }\n return Promise.allSettled(layersReady);\n }\n whenProjectionDefined(projection) {\n return new Promise((resolve, reject) => {\n let interval, failureTimer;\n if (M[projection]) {\n resolve();\n } else {\n interval = setInterval(testForProjection, 200, projection);\n failureTimer = setTimeout(projectionNotDefined, 5000);\n }\n function testForProjection(p) {\n if (M[p]) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n resolve();\n }\n }\n function projectionNotDefined() {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Timeout reached waiting for projection to be defined');\n }\n });\n }\n geojson2mapml(json, options = {}) {\n if (options.projection === undefined) {\n options.projection = this.projection;\n }\n let geojsonLayer = M.geojson2mapml(json, options);\n this.appendChild(geojsonLayer);\n return geojsonLayer;\n }\n}\n// need to provide options { extends: ... } for custom built-in elements\nwindow.customElements.define('mapml-viewer', MapViewer);\nwindow.customElements.define('layer-', MapLayer);\nwindow.customElements.define('map-caption', MapCaption);\nwindow.customElements.define('map-feature', MapFeature);\nwindow.customElements.define('map-extent', MapExtent);\nwindow.customElements.define('map-input', MapInput);\nwindow.customElements.define('map-select', MapSelect);\nwindow.customElements.define('map-link', MapLink);\nwindow.customElements.define('map-style', MapStyle);\n"],"names":["MapLayer","MapCaption","MapFeature","MapExtent","MapInput","MapSelect","MapLink","MapStyle","MapViewer","HTMLElement","observedAttributes","controls","this","hasAttribute","value","Boolean","setAttribute","removeAttribute","controlsList","_controlsList","width","window","getComputedStyle","replace","val","height","lat","getAttribute","lon","projection","whenProjectionDefined","then","catch","Error","zoom","parsedVal","parseInt","isNaN","layers","getElementsByTagName","extent","let","map","_map","pcrsBounds","M","pixelToPCRSBounds","getPixelBounds","getZoom","options","formattedExtent","_convertAndFormatPCRS","crs","minZoom","Infinity","maxZoom","i","length","getMinZoom","getMaxZoom","static","constructor","super","_source","outerHTML","_history","_historyIndex","_traversalCall","connectedCallback","_initShadowRoot","DOMTokenList","s","wpx","hpx","w","h","_changeWidth","_changeHeight","_createMap","_toggleStatic","mapcaption","querySelector","setTimeout","innerHTML","mapCaptionObserver","MutationObserver","observe","childList","shadowRoot","attachShadow","mode","tmpl","document","createElement","URL","import","meta","url","href","_container","insertAdjacentHTML","mapDefaultCSS","hideElementsCSS","appendChild","content","cloneNode","L","center","LatLng","resolutions","query","contextMenu","announceMovement","featureIndex","mapEl","zoomControl","_addToHistory","_createControls","_toggleControls","_crosshair","crosshair","addTo","featureIndexOverlayOption","_featureIndexOverlay","featureIndexOverlay","_setUpEvents","disconnectedCallback","_removeEvents","firstChild","removeChild","_deleteControls","adoptedCallback","attributeChangedCallback","name","oldValue","newValue","valueSet","_hideControls","_showControls","connect","layersReady","disable","layer","querySelectorAll","reAttach","push","whenReady","Promise","allSettled","zoomTo","enable","dispatchEvent","CustomEvent","bind","_resetHistory","_debug","toggleDebug","mapSize","getSize","y","totalSize","_layerControl","layerControl","collapsed","on","collapse","scaleValue","announceScale","metric","imperial","_scaleBar","scaleBar","_zoomControl","control","_reloadButton","reloadButton","_fullScreenControl","fullscreenButton","_geolocationButton","geolocationButton","toggleContextMenuItem","_setControlsVisibility","forEach","toLowerCase","_layers","hide","container","children","childEl","isStatic","dragging","touchZoom","doubleClickZoom","scrollWheelZoom","boxZoom","keyboard","_dropHandler","event","preventDefault","text","dataTransfer","getData","_pasteLayer","_dragoverHandler","dropEffect","off","removeEventListener","addEventListener","e","target","tagName","details","originalEvent","host","getRootNode","ShadowRoot","parentElement","keyCode","activeElement","nodeName","detail","ctrlKey","navigator","clipboard","readText","fire","latlng","accuracy","error","message","lng","x","containerPoint","_updateMapCenter","setMapMinAndMaxZoom","whenLayersReady","_layerEl","setMaxZoom","setMinZoom","fullscreenElement","setViewFullScreenInnerHTML","reload","altKey","forward","back","locate","stop","setView","remove","undefined","debugOverlay","style","styleSheets","cssRules","invalidateSize","Number","isInteger","location","getCenter","mapLocation","splice","prev","history","curr","scale","panBy","animate","setZoom","next","initialLocation","shift","getContainer","focus","_toggleFullScreen","toggleFullscreen","viewSource","blob","Blob","type","createObjectURL","open","revokeObjectURL","defineCustomProjection","jsonTemplate","t","JSON","parse","proj4string","origin","bounds","indexOf","toUpperCase","tileSize","includes","tilesize","TILE_SIZE","Proj","CRS","tcrs","horizontal","min","max","Math","round","vertical","pcrs","gcrs","unproject","OSMTILE","latLngBounds","point","tile","tilematrix","resolve","reject","interval","failureTimer","setInterval","viewer","clearInterval","clearTimeout","p","geojson2mapml","json","geojsonLayer","customElements","define"],"mappings":";;+CAESA,iCACAC,yCACAC,yCACAC,uCACAC,qCACAC,uCACAC,mCACAC,oCAEIC,kBAAkBC,YAC7BC,gCACE,MAAO,CACL,MACA,MACA,OACA,aACA,QACA,SACA,WACA,SACA,gBAQJC,eACE,OAAOC,KAAKC,aAAa,YAE3BF,aAAaG,GACSC,QAAQD,GAE1BF,KAAKI,aAAa,WAAY,IAE9BJ,KAAKK,gBAAgB,YA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,CAACsK,EAASC,KAC3BjR,IAAIkR,EAAUC,EACV/Q,EAAEhB,GACJ4R,KAEAE,EAAWE,YAGb,SAA2BI,GACrBpR,EAAEoR,KACJF,cAAcJ,GACdK,aAAaJ,GACbH,MAPwC,IAAK5R,GAC/C+R,EAAe1O,WASjB,WACE6O,cAAcJ,GACdK,aAAaJ,GACbF,EAAO,yDAZyC,QAgBtDQ,cAAcC,EAAMlR,EAAU,SACDwM,IAAvBxM,EAAQpB,aACVoB,EAAQpB,WAAajB,KAAKiB,YAExBuS,EAAevR,EAAEqR,cAAcC,EAAMlR,GAEzC,OADArC,KAAK2F,YAAY6N,GACVA,GAIX/S,OAAOgT,eAAeC,OAAO,eAAgB9T,WAC7Ca,OAAOgT,eAAeC,OAAO,SAAUtU,UACvCqB,OAAOgT,eAAeC,OAAO,cAAerU,YAC5CoB,OAAOgT,eAAeC,OAAO,cAAepU,YAC5CmB,OAAOgT,eAAeC,OAAO,aAAcnU,WAC3CkB,OAAOgT,eAAeC,OAAO,YAAalU,UAC1CiB,OAAOgT,eAAeC,OAAO,aAAcjU,WAC3CgB,OAAOgT,eAAeC,OAAO,WAAYhU,SACzCe,OAAOgT,eAAeC,OAAO,YAAa/T,iBAt5C7BC"} \ No newline at end of file diff --git a/src/dist/mapml.js b/src/dist/mapml.js index c4ba44d..03bff64 100644 --- a/src/dist/mapml.js +++ b/src/dist/mapml.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 09-09-2024 */ +/*! @maps4html/mapml 13-09-2024 */ !function(){"use strict";function t(t){return new s(t)}function e(t,e){return new l(t,e)}function i(t,e){return new h(t,e)}function o(t,e){return new c(t,e)}function n(t){return new u(t)}function a(t,e){return new m(t,e)}function r(t,e){return new d(t,e)}var s=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 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(` diff --git a/src/dist/web-map.js b/src/dist/web-map.js index 3e3e56a..7cea2a4 100644 --- a/src/dist/web-map.js +++ b/src/dist/web-map.js @@ -1,4 +1,4 @@ -/*! @maps4html/mapml 09-09-2024 */ +/*! @maps4html/mapml 13-09-2024 */ -import"./leaflet.js";import"./mapml.js";import{MapLayer}from"./layer.js";import{MapArea}from"./map-area.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 WebMap extends HTMLMapElement{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 areas(){return this.getElementsByTagName("area")}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._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(){let t=document.createElement("template");t.innerHTML=``;const e=document.createElement("div");e.classList.add("mapml-web-map");let o=e.attachShadow({mode:"open"});this._container=document.createElement("div");this._container.insertAdjacentHTML("beforeend","");let i=document.createElement("style");i.id="web-map-default-style",i.innerHTML='[is="web-map"] {all: initial;contain: layout size;display: inline-block;height: 150px;width: 300px;border-width: 2px;border-style: inset;box-sizing: inherit;}[is="web-map"][frameborder="0"] {border-width: 0;}[is="web-map"][hidden] {display: none!important;}[is="web-map"] .mapml-web-map {display: contents;}';let n=document.createElement("style");n.innerHTML=":host .leaflet-control-container {visibility: hidden!important;}";let s=document.createElement("style");s.innerHTML='[is="web-map"] > :not(area):not(.mapml-web-map) {display: none!important;}',this.appendChild(s),o.appendChild(n),o.appendChild(t.content.cloneNode(!0)),o.appendChild(this._container),this.appendChild(e),this.getRootNode()instanceof ShadowRoot?this.getRootNode().getElementById(i.id)||this.getRootNode().prepend(i):document.getElementById(i.id)||document.head.insertAdjacentElement("afterbegin",i)}_createMap(){var t;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.hasAttribute("name")||(t=this.getAttribute("name"))&&(this.poster=document.querySelector('img[usemap="#'+t+'"]'),this.poster&&L.Browser.gecko&&this.poster.removeAttribute("usemap")),this.poster&&this.poster.setAttribute("hidden",""),this.setAttribute("role","application"),this._container.setAttribute("role","region"),this._container.setAttribute("aria-label","Interactive map"),this._setUpEvents())}disconnectedCallback(){this._removeEvents();let t=this.querySelector(".mapml-web-map");for(;t.shadowRoot.firstChild;)t.shadowRoot.removeChild(t.shadowRoot.firstChild);t.remove(),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=(()=>{if(this._map&&this._map.options.projection!==s){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-web-map"===document.activeElement.className&&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"!==document.activeElement.shadowRoot.activeElement.nodeName&&(t.preventDefault(),this._map.fire("keypress",{originalEvent:t}))}),t.addEventListener("mousedown",function(t){"mapml-web-map"===document.activeElement.className&&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-web-map"===document.activeElement.className&&(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",document.querySelector('[is="web-map"]').style.width=t+"px"),this._map&&this._map.invalidateSize(!1)}_changeHeight(t){this._container&&(this._container.style.height=t+"px",document.querySelector('[is="web-map"]').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}_ready(){var t;!this.hasAttribute("name")||(t=this.getAttribute("name"))&&(this.poster=document.querySelector('img[usemap="#'+t+'"]'),this.poster&&(L.Browser.gecko&&this.poster.removeAttribute("usemap"),this._container.appendChild(this.poster)))}}window.customElements.define("web-map",WebMap,{extends:"map"}),window.customElements.define("layer-",MapLayer),window.customElements.define("map-area",MapArea,{extends:"area"}),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{WebMap}; +import"./leaflet.js";import"./mapml.js";import{MapLayer}from"./layer.js";import{MapArea}from"./map-area.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 WebMap extends HTMLMapElement{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 areas(){return this.getElementsByTagName("area")}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._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(){let t=document.createElement("template");t.innerHTML=``;const e=document.createElement("div");e.classList.add("mapml-web-map");let o=e.attachShadow({mode:"open"});this._container=document.createElement("div");this._container.insertAdjacentHTML("beforeend","");let i=document.createElement("style");i.id="web-map-default-style",i.innerHTML='[is="web-map"] {all: initial;contain: layout size;display: inline-block;height: 150px;width: 300px;border-width: 2px;border-style: inset;box-sizing: inherit;}[is="web-map"][frameborder="0"] {border-width: 0;}[is="web-map"][hidden] {display: none!important;}[is="web-map"] .mapml-web-map {display: contents;}';let n=document.createElement("style");n.innerHTML=":host .leaflet-control-container {visibility: hidden!important;}";let s=document.createElement("style");s.innerHTML='[is="web-map"] > :not(area):not(.mapml-web-map) {display: none!important;}',this.appendChild(s),o.appendChild(n),o.appendChild(t.content.cloneNode(!0)),o.appendChild(this._container),this.appendChild(e),this.getRootNode()instanceof ShadowRoot?this.getRootNode().getElementById(i.id)||this.getRootNode().prepend(i):document.getElementById(i.id)||document.head.insertAdjacentElement("afterbegin",i)}_createMap(){var t;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.hasAttribute("name")||(t=this.getAttribute("name"))&&(this.poster=document.querySelector('img[usemap="#'+t+'"]'),this.poster&&L.Browser.gecko&&this.poster.removeAttribute("usemap")),this.poster&&this.poster.setAttribute("hidden",""),this.setAttribute("role","application"),this._container.setAttribute("role","region"),this._container.setAttribute("aria-label","Interactive map"),this._setUpEvents())}disconnectedCallback(){this._removeEvents();let t=this.querySelector(".mapml-web-map");for(;t.shadowRoot.firstChild;)t.shadowRoot.removeChild(t.shadowRoot.firstChild);t.remove(),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=(()=>{if(this._map&&this._map.options.projection!==s){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);this.whenProjectionDefined(s).then(()=>o()).then(()=>{if(this._map&&this._map.options.projection!==e&&this._resetHistory(),this._debug)for(let t=0;t<2;t++)this.toggleDebug()}).catch(()=>{throw new Error("Undefined projection: "+s)})}}}_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-web-map"===document.activeElement.className&&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"!==document.activeElement.shadowRoot.activeElement.nodeName&&(t.preventDefault(),this._map.fire("keypress",{originalEvent:t}))}),t.addEventListener("mousedown",function(t){"mapml-web-map"===document.activeElement.className&&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-web-map"===document.activeElement.className&&(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",document.querySelector('[is="web-map"]').style.width=t+"px"),this._map&&this._map.invalidateSize(!1)}_changeHeight(t){this._container&&(this._container.style.height=t+"px",document.querySelector('[is="web-map"]').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}_ready(){var t;!this.hasAttribute("name")||(t=this.getAttribute("name"))&&(this.poster=document.querySelector('img[usemap="#'+t+'"]'),this.poster&&(L.Browser.gecko&&this.poster.removeAttribute("usemap"),this._container.appendChild(this.poster)))}}window.customElements.define("web-map",WebMap,{extends:"map"}),window.customElements.define("layer-",MapLayer),window.customElements.define("map-area",MapArea,{extends:"area"}),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{WebMap}; //# sourceMappingURL=web-map.js.map \ No newline at end of file diff --git a/src/dist/web-map.js.map b/src/dist/web-map.js.map index aefc7f7..c42a286 100644 --- a/src/dist/web-map.js.map +++ b/src/dist/web-map.js.map @@ -1 +1 @@ -{"version":3,"file":"web-map.js","sources":["../src/web-map.js"],"sourcesContent":["import './leaflet.js'; // bundled with proj4, proj4leaflet, modularized\nimport './mapml.js';\nimport { MapLayer } from './layer.js';\nimport { MapArea } from './map-area.js';\nimport { MapCaption } from './map-caption.js';\nimport { MapFeature } from './map-feature.js';\nimport { MapExtent } from './map-extent.js';\nimport { MapInput } from './map-input.js';\nimport { MapSelect } from './map-select.js';\nimport { MapLink } from './map-link.js';\nimport { MapStyle } from './map-style.js';\n\nexport class WebMap extends HTMLMapElement {\n static get observedAttributes() {\n return [\n 'lat',\n 'lon',\n 'zoom',\n 'projection',\n 'width',\n 'height',\n 'controls',\n 'static',\n 'controlslist'\n ];\n }\n // see comments below regarding attributeChangedCallback vs. getter/setter\n // usage. Effectively, the user of the element must use the property, not\n // the getAttribute/setAttribute/removeAttribute DOM API, because the latter\n // calls don't result in the getter/setter being called (so you have to use\n // the getter/setter directly)\n get controls() {\n return this.hasAttribute('controls');\n }\n set controls(value) {\n const hasControls = Boolean(value);\n if (hasControls) {\n this.setAttribute('controls', '');\n } else {\n this.removeAttribute('controls');\n }\n }\n get controlsList() {\n return this._controlsList;\n }\n set controlsList(value) {\n this._controlsList.value = value;\n this.setAttribute('controlslist', value);\n }\n get width() {\n return +window.getComputedStyle(this).width.replace('px', '');\n }\n set width(val) {\n //img.height or img.width setters change or add the corresponding attributes\n this.setAttribute('width', val);\n }\n get height() {\n return +window.getComputedStyle(this).height.replace('px', '');\n }\n set height(val) {\n //img.height or img.width setters change or add the corresponding attributes\n this.setAttribute('height', val);\n }\n get lat() {\n return +(this.hasAttribute('lat') ? this.getAttribute('lat') : 0);\n }\n set lat(val) {\n if (val) {\n this.setAttribute('lat', val);\n }\n }\n get lon() {\n return +(this.hasAttribute('lon') ? this.getAttribute('lon') : 0);\n }\n set lon(val) {\n if (val) {\n this.setAttribute('lon', val);\n }\n }\n get projection() {\n return this.hasAttribute('projection')\n ? this.getAttribute('projection')\n : 'OSMTILE';\n }\n set projection(val) {\n if (val) {\n this.whenProjectionDefined(val)\n .then(() => {\n this.setAttribute('projection', val);\n })\n .catch(() => {\n throw new Error('Undefined projection:' + val);\n });\n }\n }\n get zoom() {\n return +(this.hasAttribute('zoom') ? this.getAttribute('zoom') : 0);\n }\n set zoom(val) {\n var parsedVal = parseInt(val, 10);\n if (!isNaN(parsedVal) && parsedVal >= 0 && parsedVal <= 25) {\n this.setAttribute('zoom', parsedVal);\n }\n }\n get layers() {\n return this.getElementsByTagName('layer-');\n }\n get areas() {\n return this.getElementsByTagName('area');\n }\n\n get extent() {\n let map = this._map,\n pcrsBounds = M.pixelToPCRSBounds(\n map.getPixelBounds(),\n map.getZoom(),\n map.options.projection\n );\n let formattedExtent = M._convertAndFormatPCRS(\n pcrsBounds,\n map.options.crs,\n this.projection\n );\n // get min/max zoom from layers at this moment\n let minZoom = Infinity,\n maxZoom = -Infinity;\n for (let i = 0; i < this.layers.length; i++) {\n if (this.layers[i].extent) {\n if (this.layers[i].extent.zoom.minZoom < minZoom)\n minZoom = this.layers[i].extent.zoom.minZoom;\n if (this.layers[i].extent.zoom.maxZoom > maxZoom)\n maxZoom = this.layers[i].extent.zoom.maxZoom;\n }\n }\n\n formattedExtent.zoom = {\n minZoom: minZoom !== Infinity ? minZoom : map.getMinZoom(),\n maxZoom: maxZoom !== -Infinity ? maxZoom : map.getMaxZoom()\n };\n return formattedExtent;\n }\n get static() {\n return this.hasAttribute('static');\n }\n set static(value) {\n const isStatic = Boolean(value);\n if (isStatic) this.setAttribute('static', '');\n else this.removeAttribute('static');\n }\n\n constructor() {\n // Always call super first in constructor\n super();\n this._source = this.outerHTML;\n // create an array to track the history of the map and the current index\n this._history = [];\n this._historyIndex = -1;\n this._traversalCall = false;\n }\n connectedCallback() {\n this.whenProjectionDefined(this.projection)\n .then(() => {\n this._initShadowRoot();\n\n this._controlsList = new M.DOMTokenList(\n this.getAttribute('controlslist'),\n this,\n 'controlslist',\n [\n 'noreload',\n 'nofullscreen',\n 'nozoom',\n 'nolayer',\n 'noscale',\n 'geolocation'\n ]\n );\n\n var s = window.getComputedStyle(this),\n wpx = s.width,\n hpx = s.height,\n w = this.hasAttribute('width')\n ? this.getAttribute('width')\n : parseInt(wpx.replace('px', '')),\n h = this.hasAttribute('height')\n ? this.getAttribute('height')\n : parseInt(hpx.replace('px', ''));\n this._changeWidth(w);\n this._changeHeight(h);\n\n this._createMap();\n\n this._toggleStatic();\n\n /*\n 1. only deletes aria-label when the last (only remaining) map caption is removed\n 2. only deletes aria-label if the aria-label was defined by the map caption element itself\n */\n\n let mapcaption = this.querySelector('map-caption');\n\n if (mapcaption !== null) {\n setTimeout(() => {\n let ariaupdate = this.getAttribute('aria-label');\n\n if (ariaupdate === mapcaption.innerHTML) {\n this.mapCaptionObserver = new MutationObserver((m) => {\n let mapcaptionupdate = this.querySelector('map-caption');\n if (mapcaptionupdate !== mapcaption) {\n this.removeAttribute('aria-label');\n }\n });\n this.mapCaptionObserver.observe(this, {\n childList: true\n });\n }\n }, 0);\n }\n })\n .catch(() => {\n throw new Error('Projection not defined');\n });\n }\n _initShadowRoot() {\n let tmpl = document.createElement('template');\n /* jshint ignore:start */\n tmpl.innerHTML = ``;\n /* jshint ignore:end */\n\n const rootDiv = document.createElement('div');\n rootDiv.classList.add('mapml-web-map');\n\n let shadowRoot = rootDiv.attachShadow({ mode: 'open' });\n this._container = document.createElement('div');\n\n let output =\n \"\";\n this._container.insertAdjacentHTML('beforeend', output);\n\n // Set default styles for the map element.\n let mapDefaultCSS = document.createElement('style');\n mapDefaultCSS.id = 'web-map-default-style';\n mapDefaultCSS.innerHTML =\n `[is=\"web-map\"] {` +\n `all: initial;` + // Reset properties inheritable from html/body, as some inherited styles may cause unexpected issues with the map element's components (https://github.com/Maps4HTML/MapML.js/issues/140).\n `contain: layout size;` + // Contain layout and size calculations within the map element.\n `display: inline-block;` + // This together with dimension properties is required so that Leaflet isn't working with a height=0 box by default.\n `height: 150px;` + // Provide a \"default object size\" (https://github.com/Maps4HTML/HTML-Map-Element/issues/31).\n `width: 300px;` +\n `border-width: 2px;` + // Set a default border for contrast, similar to UA default for iframes.\n `border-style: inset;` +\n `box-sizing: inherit;` + // https://github.com/Maps4HTML/MapML.js/issues/350#issuecomment-888361985\n `}` +\n `[is=\"web-map\"][frameborder=\"0\"] {` +\n `border-width: 0;` +\n `}` +\n `[is=\"web-map\"][hidden] {` +\n `display: none!important;` +\n `}` +\n `[is=\"web-map\"] .mapml-web-map {` +\n `display: contents;` + // This div doesn't have to participate in layout by generating its own box.\n `}`;\n\n let shadowRootCSS = document.createElement('style');\n shadowRootCSS.innerHTML =\n `:host .leaflet-control-container {` +\n `visibility: hidden!important;` + // Visibility hack to improve percieved performance (mitigate FOUC) – visibility is unset in mapml.css! (https://github.com/Maps4HTML/MapML.js/issues/154).\n `}`;\n\n // Hide all (light DOM) children of the map element except for the\n // `` and `
` (shadow root host) elements.\n let hideElementsCSS = document.createElement('style');\n hideElementsCSS.innerHTML =\n `[is=\"web-map\"] > :not(area):not(.mapml-web-map) {` +\n `display: none!important;` +\n `}`;\n this.appendChild(hideElementsCSS);\n\n shadowRoot.appendChild(shadowRootCSS);\n shadowRoot.appendChild(tmpl.content.cloneNode(true));\n shadowRoot.appendChild(this._container);\n this.appendChild(rootDiv);\n if (this.getRootNode() instanceof ShadowRoot) {\n if (!this.getRootNode().getElementById(mapDefaultCSS.id))\n this.getRootNode().prepend(mapDefaultCSS);\n } else {\n if (!document.getElementById(mapDefaultCSS.id))\n document.head.insertAdjacentElement('afterbegin', mapDefaultCSS);\n }\n }\n _createMap() {\n if (!this._map) {\n this._map = L.map(this._container, {\n center: new L.LatLng(this.lat, this.lon),\n minZoom: 0,\n maxZoom: M[this.projection].options.resolutions.length - 1,\n projection: this.projection,\n query: true,\n contextMenu: true,\n announceMovement: M.options.announceMovement,\n featureIndex: true,\n mapEl: this,\n crs: M[this.projection],\n zoom: this.zoom,\n zoomControl: false\n });\n this._addToHistory();\n\n this._createControls();\n this._toggleControls();\n this._crosshair = M.crosshair().addTo(this._map);\n\n if (M.options.featureIndexOverlayOption)\n this._featureIndexOverlay = M.featureIndexOverlay().addTo(this._map);\n\n if (this.hasAttribute('name')) {\n var name = this.getAttribute('name');\n if (name) {\n this.poster = document.querySelector(\n 'img[usemap=' + '\"#' + name + '\"]'\n );\n // firefox has an issue where the attribution control's use of\n // _container.innerHTML does not work properly if the engine is throwing\n // exceptions because there are no area element children of the image map\n // for firefox only, a workaround is to actually remove the image...\n if (this.poster) {\n if (L.Browser.gecko) {\n this.poster.removeAttribute('usemap');\n }\n //this.appendChild(this.poster);\n }\n }\n }\n\n // undisplay the img in the image map, because it's not needed now.\n // gives a slight FOUC, unless:\n // 1) the img is pre-styled (https://github.com/Maps4HTML/MapML.js/blob/80a4a4e372d2ef61bb7cad6a111e17e396b8e908/index-map-area.html#L35)\n // 2) placed after the map element\n if (this.poster) {\n this.poster.setAttribute('hidden', '');\n }\n\n // https://github.com/Maps4HTML/MapML.js/issues/274\n this.setAttribute('role', 'application');\n // Make the Leaflet container element programmatically identifiable\n // (https://github.com/Leaflet/Leaflet/issues/7193).\n this._container.setAttribute('role', 'region');\n this._container.setAttribute('aria-label', 'Interactive map');\n\n this._setUpEvents();\n }\n }\n disconnectedCallback() {\n this._removeEvents();\n let rootDiv = this.querySelector('.mapml-web-map');\n while (rootDiv.shadowRoot.firstChild) {\n rootDiv.shadowRoot.removeChild(rootDiv.shadowRoot.firstChild);\n }\n rootDiv.remove();\n delete this._map;\n this._deleteControls();\n }\n adoptedCallback() {\n // console.log('Custom map element moved to new page.');\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n // console.log('Attribute: ' + name + ' changed from: '+ oldValue + ' to: '+newValue);\n // \"Best practice\": handle side-effects in this callback\n // https://developers.google.com/web/fundamentals/web-components/best-practices\n // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy\n // note that the example is misleading, since the user can't use\n // setAttribute or removeAttribute to set the property, they need to use\n // the property directly in their API usage, which kinda sucks\n /*\n const hasValue = newValue !== null;\n switch (name) {\n case 'checked':\n // Note the attributeChangedCallback is only handling the *side effects*\n // of setting the attribute.\n this.setAttribute('aria-checked', hasValue);\n break;\n ...\n } */\n switch (name) {\n case 'controlslist':\n if (this._controlsList) {\n if (this._controlsList.valueSet === false) {\n this._controlsList.value = newValue;\n }\n this._toggleControls();\n }\n break;\n case 'controls':\n if (oldValue !== null && newValue === null) {\n this._hideControls();\n } else if (oldValue === null && newValue !== null) {\n this._showControls();\n }\n break;\n case 'height':\n if (oldValue !== newValue) {\n this._changeHeight(newValue);\n }\n break;\n case 'width':\n if (oldValue !== newValue) {\n this._changeWidth(newValue);\n }\n break;\n case 'static':\n this._toggleStatic();\n break;\n case 'projection':\n const reconnectLayers = () => {\n if (this._map && this._map.options.projection !== newValue) {\n // save map location and zoom\n let lat = this.lat;\n let lon = this.lon;\n let zoom = this.zoom;\n // saving the lat, lon and zoom is necessary because Leaflet seems\n // to try to compensate for the change in the scales for each zoom\n // level in the crs by changing the zoom level of the map when\n // you set the map crs. So, we save the current view for use below\n // when all the layers' reconnections have settled.\n // leaflet doesn't like this: https://github.com/Leaflet/Leaflet/issues/2553\n this._map.options.crs = M[newValue];\n this._map.options.projection = newValue;\n let layersReady = [];\n this._map.announceMovement.disable();\n for (let layer of this.querySelectorAll('layer-')) {\n layer.removeAttribute('disabled');\n let reAttach = this.removeChild(layer);\n this.appendChild(reAttach);\n layersReady.push(reAttach.whenReady());\n }\n return Promise.allSettled(layersReady).then(() => {\n // use the saved map location to ensure it is correct after\n // changing the map CRS. Specifically affects projection\n // upgrades, e.g. https://maps4html.org/experiments/custom-projections/BNG/\n // see leaflet bug: https://github.com/Leaflet/Leaflet/issues/2553\n this.zoomTo(lat, lon, zoom);\n if (M.options.announceMovement)\n this._map.announceMovement.enable();\n // required to delay until map-extent.disabled is correctly set\n // which happens as a result of layer-._validateDisabled()\n // which happens so much we have to delay until they calls are\n // completed\n setTimeout(() => {\n this.dispatchEvent(new CustomEvent('map-projectionchange'));\n }, 0);\n });\n }\n };\n if (\n newValue &&\n this._map &&\n this._map.options.projection !== newValue\n ) {\n const connect = reconnectLayers.bind(this);\n connect().then(() => {\n if (this._map && this._map.options.projection !== oldValue) {\n // this doesn't completely work either\n this._resetHistory();\n }\n if (this._debug) for (let i = 0; i < 2; i++) this.toggleDebug();\n });\n }\n break;\n }\n }\n\n // Creates All map controls and adds them to the map, when created.\n _createControls() {\n let mapSize = this._map.getSize().y,\n totalSize = 0;\n\n this._layerControl = M.layerControl(null, {\n collapsed: true,\n mapEl: this\n }).addTo(this._map);\n this._map.on('movestart', this._layerControl.collapse, this._layerControl);\n\n let scaleValue = M.options.announceScale;\n\n if (scaleValue === 'metric') {\n scaleValue = { metric: true, imperial: false };\n }\n if (scaleValue === 'imperial') {\n scaleValue = { metric: false, imperial: true };\n }\n\n if (!this._scaleBar)\n this._scaleBar = M.scaleBar(scaleValue).addTo(this._map);\n\n // Only add controls if there is enough top left vertical space\n if (!this._zoomControl && totalSize + 93 <= mapSize) {\n totalSize += 93;\n this._zoomControl = L.control.zoom().addTo(this._map);\n }\n if (!this._reloadButton && totalSize + 49 <= mapSize) {\n totalSize += 49;\n this._reloadButton = M.reloadButton().addTo(this._map);\n }\n if (!this._fullScreenControl && totalSize + 49 <= mapSize) {\n totalSize += 49;\n this._fullScreenControl = M.fullscreenButton().addTo(this._map);\n }\n\n if (!this._geolocationButton) {\n this._geolocationButton = M.geolocationButton().addTo(this._map);\n }\n }\n\n // Sets controls by hiding/unhiding them based on the map attribute\n _toggleControls() {\n if (this.controls === false) {\n this._hideControls();\n this._map.contextMenu.toggleContextMenuItem('Controls', 'disabled');\n } else {\n this._showControls();\n this._map.contextMenu.toggleContextMenuItem('Controls', 'enabled');\n }\n }\n\n _hideControls() {\n this._setControlsVisibility('fullscreen', true);\n this._setControlsVisibility('layercontrol', true);\n this._setControlsVisibility('reload', true);\n this._setControlsVisibility('zoom', true);\n this._setControlsVisibility('geolocation', true);\n this._setControlsVisibility('scale', true);\n }\n _showControls() {\n this._setControlsVisibility('fullscreen', false);\n this._setControlsVisibility('layercontrol', false);\n this._setControlsVisibility('reload', false);\n this._setControlsVisibility('zoom', false);\n this._setControlsVisibility('geolocation', true);\n this._setControlsVisibility('scale', false);\n\n // prune the controls shown if necessary\n // this logic could be embedded in _showControls\n // but would require being able to iterate the domain of supported tokens\n // for the controlslist\n if (this._controlsList) {\n this._controlsList.forEach((value) => {\n switch (value.toLowerCase()) {\n case 'nofullscreen':\n this._setControlsVisibility('fullscreen', true);\n break;\n case 'nolayer':\n this._setControlsVisibility('layercontrol', true);\n break;\n case 'noreload':\n this._setControlsVisibility('reload', true);\n break;\n case 'nozoom':\n this._setControlsVisibility('zoom', true);\n break;\n case 'geolocation':\n this._setControlsVisibility('geolocation', false);\n break;\n case 'noscale':\n this._setControlsVisibility('scale', true);\n break;\n }\n });\n }\n if (this._layerControl && this._layerControl._layers.length === 0) {\n this._layerControl._container.setAttribute('hidden', '');\n }\n }\n\n // delete the map controls that are private properties of this custom element\n _deleteControls() {\n delete this._layerControl;\n delete this._zoomControl;\n delete this._reloadButton;\n delete this._fullScreenControl;\n delete this._geolocationButton;\n delete this._scaleBar;\n }\n // Sets the control's visibility AND all its childrens visibility,\n // for the control element based on the Boolean hide parameter\n _setControlsVisibility(control, hide) {\n let container;\n switch (control) {\n case 'zoom':\n if (this._zoomControl) {\n container = this._zoomControl._container;\n }\n break;\n case 'reload':\n if (this._reloadButton) {\n container = this._reloadButton._container;\n }\n break;\n case 'fullscreen':\n if (this._fullScreenControl) {\n container = this._fullScreenControl._container;\n }\n break;\n case 'layercontrol':\n if (this._layerControl) {\n container = this._layerControl._container;\n }\n break;\n case 'geolocation':\n if (this._geolocationButton) {\n container = this._geolocationButton._container;\n }\n break;\n case 'scale':\n if (this._scaleBar) {\n container = this._scaleBar._container;\n }\n break;\n }\n if (container) {\n if (hide) {\n // setting the visibility for all the children of the element\n [...container.children].forEach((childEl) => {\n childEl.setAttribute('hidden', '');\n });\n container.setAttribute('hidden', '');\n } else {\n // setting the visibility for all the children of the element\n [...container.children].forEach((childEl) => {\n childEl.removeAttribute('hidden');\n });\n container.removeAttribute('hidden');\n }\n }\n }\n _toggleStatic() {\n const isStatic = this.hasAttribute('static');\n if (this._map) {\n if (isStatic) {\n this._map.dragging.disable();\n this._map.touchZoom.disable();\n this._map.doubleClickZoom.disable();\n this._map.scrollWheelZoom.disable();\n this._map.boxZoom.disable();\n this._map.keyboard.disable();\n this._zoomControl.disable();\n } else {\n this._map.dragging.enable();\n this._map.touchZoom.enable();\n this._map.doubleClickZoom.enable();\n this._map.scrollWheelZoom.enable();\n this._map.boxZoom.enable();\n this._map.keyboard.enable();\n this._zoomControl.enable();\n }\n }\n }\n\n _dropHandler(event) {\n event.preventDefault();\n let text = event.dataTransfer.getData('text');\n M._pasteLayer(this, text);\n }\n _dragoverHandler(event) {\n event.preventDefault();\n event.dataTransfer.dropEffect = 'copy';\n }\n _removeEvents() {\n if (this._map) {\n this._map.off();\n this.removeEventListener('drop', this._dropHandler, false);\n this.removeEventListener('dragover', this._dragoverHandler, false);\n }\n }\n _setUpEvents() {\n this.addEventListener('drop', this._dropHandler, false);\n this.addEventListener('dragover', this._dragoverHandler, false);\n this.addEventListener(\n 'change',\n function (e) {\n if (e.target.tagName === 'LAYER-') {\n this.dispatchEvent(\n new CustomEvent('layerchange', {\n details: { target: this, originalEvent: e }\n })\n );\n }\n },\n false\n );\n\n let host =\n this.getRootNode() instanceof ShadowRoot\n ? this.getRootNode().host\n : this.parentElement;\n host.addEventListener('keyup', function (e) {\n if (\n e.keyCode === 9 &&\n document.activeElement.className === 'mapml-web-map'\n ) {\n // document.activeElement is div.mapml-web-map, not \n document.activeElement.dispatchEvent(\n new CustomEvent('mapfocused', { detail: { target: this } })\n );\n }\n });\n // pasting layer-, links and geojson using Ctrl+V\n this.addEventListener('keydown', function (e) {\n if (e.keyCode === 86 && e.ctrlKey) {\n navigator.clipboard.readText().then((layer) => {\n M._pasteLayer(this, layer);\n });\n // Prevents default spacebar event on all of web-map\n } else if (\n e.keyCode === 32 &&\n document.activeElement.shadowRoot.activeElement.nodeName !== 'INPUT'\n ) {\n e.preventDefault();\n this._map.fire('keypress', { originalEvent: e });\n }\n });\n host.addEventListener('mousedown', function (e) {\n if (document.activeElement.className === 'mapml-web-map') {\n document.activeElement.dispatchEvent(\n new CustomEvent('mapfocused', { detail: { target: this } })\n );\n }\n });\n\n this._map.on(\n 'locationfound',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('maplocationfound', {\n detail: { latlng: e.latlng, accuracy: e.accuracy }\n })\n );\n },\n this\n );\n this._map.on(\n 'locationerror',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('locationerror', { detail: { error: e.message } })\n );\n },\n this\n );\n this._map.on(\n 'load',\n function () {\n this.dispatchEvent(\n new CustomEvent('load', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'preclick',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('preclick', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'click',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('click', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'dblclick',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('dblclick', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mousemove',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mousemove', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mouseover',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mouseover', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mouseout',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mouseout', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mousedown',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mousedown', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mouseup',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mouseup', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'contextmenu',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('contextmenu', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'movestart',\n function () {\n this.dispatchEvent(\n new CustomEvent('movestart', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'move',\n function () {\n this.dispatchEvent(\n new CustomEvent('move', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'moveend',\n function () {\n this._updateMapCenter();\n this._addToHistory();\n this.dispatchEvent(\n new CustomEvent('map-moveend', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'zoomstart',\n function () {\n this.dispatchEvent(\n new CustomEvent('zoomstart', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'zoom',\n function () {\n this.dispatchEvent(\n new CustomEvent('zoom', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'zoomend',\n function () {\n this._updateMapCenter();\n this.dispatchEvent(\n new CustomEvent('zoomend', { detail: { target: this } })\n );\n },\n this\n );\n const setMapMinAndMaxZoom = ((e) => {\n this.whenLayersReady().then(() => {\n if (e && e.layer._layerEl) {\n this._map.setMaxZoom(this.extent.zoom.maxZoom);\n this._map.setMinZoom(this.extent.zoom.minZoom);\n }\n });\n }).bind(this);\n this.whenLayersReady().then(() => {\n this._map.setMaxZoom(this.extent.zoom.maxZoom);\n this._map.setMinZoom(this.extent.zoom.minZoom);\n this._map.on('layeradd layerremove', setMapMinAndMaxZoom, this);\n });\n this.addEventListener('fullscreenchange', function (event) {\n if (document.fullscreenElement === null) {\n // full-screen mode has been exited\n this._map.contextMenu.setViewFullScreenInnerHTML('view');\n } else {\n this._map.contextMenu.setViewFullScreenInnerHTML('exit');\n }\n });\n this.addEventListener('keydown', function (event) {\n if (document.activeElement.className === 'mapml-web-map') {\n // Check if Ctrl+R is pressed and map is focused\n if (event.ctrlKey && event.keyCode === 82) {\n // Prevent default browser behavior\n event.preventDefault();\n this.reload();\n } else if (event.altKey && event.keyCode === 39) {\n // Prevent default browser behavior\n event.preventDefault();\n this.forward();\n } else if (event.altKey && event.keyCode === 37) {\n // Prevent default browser behavior\n event.preventDefault();\n this.back();\n }\n }\n });\n }\n\n locate(options) {\n //options: https://leafletjs.com/reference.html#locate-options\n if (this._geolocationButton) {\n this._geolocationButton.stop();\n }\n if (options) {\n if (options.zoomTo) {\n options.setView = options.zoomTo;\n delete options.zoomTo;\n }\n this._map.locate(options);\n } else {\n this._map.locate({ setView: true, maxZoom: 16 });\n }\n }\n\n toggleDebug() {\n if (this._debug) {\n this._debug.remove();\n this._debug = undefined;\n } else {\n this._debug = M.debugOverlay().addTo(this._map);\n }\n }\n\n _changeWidth(width) {\n if (this._container) {\n this._container.style.width = width + 'px';\n document.querySelector('[is=\"web-map\"]').style.width = width + 'px';\n }\n if (this._map) {\n this._map.invalidateSize(false);\n }\n }\n _changeHeight(height) {\n if (this._container) {\n this._container.style.height = height + 'px';\n document.querySelector('[is=\"web-map\"]').style.height = height + 'px';\n }\n if (this._map) {\n this._map.invalidateSize(false);\n }\n }\n zoomTo(lat, lon, zoom) {\n zoom = Number.isInteger(+zoom) ? +zoom : this.zoom;\n let location = new L.LatLng(+lat, +lon);\n this._map.setView(location, zoom);\n this.zoom = zoom;\n this.lat = location.lat;\n this.lon = location.lng;\n }\n _updateMapCenter() {\n // remember to tell Leaflet event handler that 'this' in here refers to\n // something other than the map in this case the custom polymer element\n this.lat = this._map.getCenter().lat;\n this.lon = this._map.getCenter().lng;\n this.zoom = this._map.getZoom();\n }\n _resetHistory() {\n this._history = [];\n this._historyIndex = -1;\n this._traversalCall = false;\n // weird but ok\n this._addToHistory();\n }\n /**\n * Adds to the maps history on moveends\n * @private\n */\n _addToHistory() {\n if (this._traversalCall > 0) {\n // this._traversalCall tracks how many consecutive moveends to ignore from history\n this._traversalCall--; // this is useful for ignoring moveends corresponding to back, forward and reload\n return;\n }\n\n let mapLocation = this._map.getPixelBounds().getCenter();\n let location = {\n zoom: this._map.getZoom(),\n x: mapLocation.x,\n y: mapLocation.y\n };\n this._historyIndex++;\n this._history.splice(this._historyIndex, 0, location);\n // Remove future history and overwrite it when map pan/zoom while inside history\n if (this._historyIndex + 1 !== this._history.length) {\n this._history.length = this._historyIndex + 1;\n }\n if (this._historyIndex === 0) {\n // when at initial state of map, disable back, forward, and reload items\n this._map.contextMenu.toggleContextMenuItem('Back', 'disabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'disabled'); // reload contextmenu item\n this._reloadButton?.disable();\n } else {\n this._map.contextMenu.toggleContextMenuItem('Back', 'enabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'enabled'); // reload contextmenu item\n this._reloadButton?.enable();\n }\n }\n /**\n * Allow user to move back in history\n */\n back() {\n let history = this._history;\n let curr = history[this._historyIndex];\n\n if (this._historyIndex > 0) {\n this._map.contextMenu.toggleContextMenuItem('Forward', 'enabled'); // forward contextmenu item\n this._historyIndex--;\n let prev = history[this._historyIndex];\n // Disable back, reload contextmenu item when at the end of history\n if (this._historyIndex === 0) {\n this._map.contextMenu.toggleContextMenuItem('Back', 'disabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'disabled'); // reload contextmenu item\n this._reloadButton?.disable();\n }\n\n if (prev.zoom !== curr.zoom) {\n this._traversalCall = 2; // allows the next 2 moveends to be ignored from history\n\n let currScale = this._map.options.crs.scale(curr.zoom); // gets the scale of the current zoom level\n let prevScale = this._map.options.crs.scale(prev.zoom); // gets the scale of the previous zoom level\n\n let scale = currScale / prevScale; // used to convert the previous pixel location to be in terms of the current zoom level\n\n this._map.panBy([prev.x * scale - curr.x, prev.y * scale - curr.y], {\n animate: false\n });\n this._map.setZoom(prev.zoom);\n } else {\n this._traversalCall = 1;\n this._map.panBy([prev.x - curr.x, prev.y - curr.y]);\n }\n }\n }\n\n /**\n * Allows user to move forward in history\n */\n forward() {\n let history = this._history;\n let curr = history[this._historyIndex];\n if (this._historyIndex < history.length - 1) {\n this._map.contextMenu.toggleContextMenuItem('Back', 'enabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'enabled'); // reload contextmenu item\n this._reloadButton?.enable();\n this._historyIndex++;\n let next = history[this._historyIndex];\n // disable forward contextmenu item, when at the end of forward history\n if (this._historyIndex + 1 === this._history.length) {\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n }\n\n if (next.zoom !== curr.zoom) {\n this._traversalCall = 2; // allows the next 2 moveends to be ignored from history\n\n let currScale = this._map.options.crs.scale(curr.zoom); // gets the scale of the current zoom level\n let nextScale = this._map.options.crs.scale(next.zoom); // gets the scale of the next zoom level\n\n let scale = currScale / nextScale; // used to convert the next pixel location to be in terms of the current zoom level\n\n this._map.panBy([next.x * scale - curr.x, next.y * scale - curr.y], {\n animate: false\n });\n this._map.setZoom(next.zoom);\n } else {\n this._traversalCall = 1;\n this._map.panBy([next.x - curr.x, next.y - curr.y]);\n }\n }\n }\n\n /**\n * Allows the user to reload/reset the map's location to it's initial location\n */\n reload() {\n let initialLocation = this._history.shift();\n let mapLocation = this._map.getPixelBounds().getCenter();\n let curr = {\n zoom: this._map.getZoom(),\n x: mapLocation.x,\n y: mapLocation.y\n };\n\n this._map.contextMenu.toggleContextMenuItem('Back', 'disabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'disabled'); // reload contextmenu item\n this._reloadButton?.disable();\n\n this._history = [initialLocation];\n this._historyIndex = 0;\n\n if (initialLocation.zoom !== curr.zoom) {\n this._traversalCall = 2; // ignores the next 2 moveend events\n\n let currScale = this._map.options.crs.scale(curr.zoom); // gets the scale of the current zoom level\n let initScale = this._map.options.crs.scale(initialLocation.zoom); // gets the scale of the initial location's zoom\n\n let scale = currScale / initScale;\n\n this._map.panBy(\n [\n initialLocation.x * scale - curr.x,\n initialLocation.y * scale - curr.y\n ],\n { animate: false }\n );\n this._map.setZoom(initialLocation.zoom);\n } else {\n // if it's on the same zoom level as the initial location, no need to calculate scales\n this._traversalCall = 1;\n this._map.panBy([initialLocation.x - curr.x, initialLocation.y - curr.y]);\n }\n this._map.getContainer().focus();\n }\n\n _toggleFullScreen() {\n this._map.toggleFullscreen();\n }\n\n viewSource() {\n let blob = new Blob([this._source], { type: 'text/plain' }),\n url = URL.createObjectURL(blob);\n window.open(url);\n URL.revokeObjectURL(url);\n }\n\n defineCustomProjection(jsonTemplate) {\n let t = JSON.parse(jsonTemplate);\n if (\n t === undefined ||\n !t.proj4string ||\n !t.projection ||\n !t.resolutions ||\n !t.origin ||\n !t.bounds\n )\n throw new Error('Incomplete TCRS Definition');\n if (t.projection.indexOf(':') >= 0)\n throw new Error('\":\" is not permitted in projection name');\n if (M[t.projection.toUpperCase()]) return t.projection.toUpperCase();\n let tileSize = [256, 512, 1024, 2048, 4096].includes(t.tilesize)\n ? t.tilesize\n : M.TILE_SIZE;\n\n M[t.projection] = new L.Proj.CRS(t.projection, t.proj4string, {\n origin: t.origin,\n resolutions: t.resolutions,\n bounds: L.bounds(t.bounds),\n crs: {\n tcrs: {\n horizontal: {\n name: 'x',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.bounds.getSize().x /\n M[t.projection].options.resolutions[zoom]\n )\n },\n vertical: {\n name: 'y',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.bounds.getSize().y /\n M[t.projection].options.resolutions[zoom]\n )\n },\n bounds: (zoom) =>\n L.bounds(\n [\n M[t.projection].options.crs.tcrs.horizontal.min,\n M[t.projection].options.crs.tcrs.vertical.min\n ],\n [\n M[t.projection].options.crs.tcrs.horizontal.max(zoom),\n M[t.projection].options.crs.tcrs.vertical.max(zoom)\n ]\n )\n },\n pcrs: {\n horizontal: {\n name: 'easting',\n get min() {\n return M[t.projection].options.bounds.min.x;\n },\n get max() {\n return M[t.projection].options.bounds.max.x;\n }\n },\n vertical: {\n name: 'northing',\n get min() {\n return M[t.projection].options.bounds.min.y;\n },\n get max() {\n return M[t.projection].options.bounds.max.y;\n }\n },\n get bounds() {\n return M[t.projection].options.bounds;\n }\n },\n gcrs: {\n horizontal: {\n name: 'longitude',\n // set min/max axis values from EPSG registry area of use, retrieved 2019-07-25\n get min() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.min)\n .lng;\n },\n get max() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.max)\n .lng;\n }\n },\n vertical: {\n name: 'latitude',\n // set min/max axis values from EPSG registry area of use, retrieved 2019-07-25\n get min() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.min)\n .lat;\n },\n get max() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.max)\n .lat;\n }\n },\n get bounds() {\n return L.latLngBounds(\n [\n M[t.projection].options.crs.gcrs.vertical.min,\n M[t.projection].options.crs.gcrs.horizontal.min\n ],\n [\n M[t.projection].options.crs.gcrs.vertical.max,\n M[t.projection].options.crs.gcrs.horizontal.max\n ]\n );\n }\n },\n map: {\n horizontal: {\n name: 'i',\n min: 0,\n max: (map) => map.getSize().x\n },\n vertical: {\n name: 'j',\n min: 0,\n max: (map) => map.getSize().y\n },\n bounds: (map) => L.bounds(L.point([0, 0]), map.getSize())\n },\n tile: {\n horizontal: {\n name: 'i',\n min: 0,\n max: tileSize\n },\n vertical: {\n name: 'j',\n min: 0,\n max: tileSize\n },\n get bounds() {\n return L.bounds(\n [\n M[t.projection].options.crs.tile.horizontal.min,\n M[t.projection].options.crs.tile.vertical.min\n ],\n [\n M[t.projection].options.crs.tile.horizontal.max,\n M[t.projection].options.crs.tile.vertical.max\n ]\n );\n }\n },\n tilematrix: {\n horizontal: {\n name: 'column',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.crs.tcrs.horizontal.max(zoom) /\n M[t.projection].options.crs.tile.bounds.getSize().x\n )\n },\n vertical: {\n name: 'row',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.crs.tcrs.vertical.max(zoom) /\n M[t.projection].options.crs.tile.bounds.getSize().y\n )\n },\n bounds: (zoom) =>\n L.bounds(\n [\n M[t.projection].options.crs.tilematrix.horizontal.min,\n M[t.projection].options.crs.tilematrix.vertical.min\n ],\n [\n M[t.projection].options.crs.tilematrix.horizontal.max(zoom),\n M[t.projection].options.crs.tilematrix.vertical.max(zoom)\n ]\n )\n }\n }\n }); //creates crs using L.Proj\n M[t.projection.toUpperCase()] = M[t.projection]; //adds the projection uppercase to global M\n return t.projection;\n }\n whenReady() {\n return new Promise((resolve, reject) => {\n let interval, failureTimer;\n if (this._map) {\n resolve();\n } else {\n let viewer = this;\n interval = setInterval(testForMap, 200, viewer);\n failureTimer = setTimeout(mapNotDefined, 5000);\n }\n function testForMap(viewer) {\n if (viewer._map) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n resolve();\n }\n }\n function mapNotDefined() {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Timeout reached waiting for map to be ready');\n }\n });\n }\n whenLayersReady() {\n let layersReady = [];\n // check if all the children elements (map-extent, map-feature) of all layer- are ready\n for (let layer of [...this.layers]) {\n layersReady.push(layer.whenReady());\n }\n return Promise.allSettled(layersReady);\n }\n whenProjectionDefined(projection) {\n return new Promise((resolve, reject) => {\n let interval, failureTimer;\n if (M[projection]) {\n resolve();\n } else {\n interval = setInterval(testForProjection, 200, projection);\n failureTimer = setTimeout(projectionNotDefined, 5000);\n }\n function testForProjection(p) {\n if (M[p]) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n resolve();\n }\n }\n function projectionNotDefined() {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Timeout reached waiting for projection to be defined');\n }\n });\n }\n geojson2mapml(json, options = {}) {\n if (options.projection === undefined) {\n options.projection = this.projection;\n }\n let geojsonLayer = M.geojson2mapml(json, options);\n this.appendChild(geojsonLayer);\n return geojsonLayer;\n }\n\n _ready() {\n if (this.hasAttribute('name')) {\n var name = this.getAttribute('name');\n if (name) {\n this.poster = document.querySelector(\n 'img[usemap=' + '\"#' + name + '\"]'\n );\n // firefox has an issue where the attribution control's use of\n // _container.innerHTML does not work properly if the engine is throwing\n // exceptions because there are no area element children of the image map\n // for firefox only, a workaround is to actually remove the image...\n if (this.poster) {\n if (L.Browser.gecko) {\n this.poster.removeAttribute('usemap');\n }\n this._container.appendChild(this.poster);\n }\n }\n }\n }\n}\n// need to provide options { extends: ... } for custom built-in elements\nwindow.customElements.define('web-map', WebMap, { extends: 'map' });\nwindow.customElements.define('layer-', MapLayer);\nwindow.customElements.define('map-area', MapArea, { extends: 'area' });\nwindow.customElements.define('map-caption', MapCaption);\nwindow.customElements.define('map-feature', MapFeature);\nwindow.customElements.define('map-extent', MapExtent);\nwindow.customElements.define('map-input', MapInput);\nwindow.customElements.define('map-select', MapSelect);\nwindow.customElements.define('map-link', MapLink);\nwindow.customElements.define('map-style', MapStyle);\n"],"names":["MapLayer","MapArea","MapCaption","MapFeature","MapExtent","MapInput","MapSelect","MapLink","MapStyle","WebMap","HTMLMapElement","observedAttributes","controls","this","hasAttribute","value","Boolean","setAttribute","removeAttribute","controlsList","_controlsList","width","window","getComputedStyle","replace","val","height","lat","getAttribute","lon","projection","whenProjectionDefined","then","catch","Error","zoom","parsedVal","parseInt","isNaN","layers","getElementsByTagName","areas","extent","let","map","_map","pcrsBounds","M","pixelToPCRSBounds","getPixelBounds","getZoom","options","formattedExtent","_convertAndFormatPCRS","crs","minZoom","Infinity","maxZoom","i","length","getMinZoom","getMaxZoom","static","constructor","super","_source","outerHTML","_history","_historyIndex","_traversalCall","connectedCallback","_initShadowRoot","DOMTokenList","s","wpx","hpx","w","h","_changeWidth","_changeHeight","_createMap","_toggleStatic","mapcaption","querySelector","setTimeout","innerHTML","mapCaptionObserver","MutationObserver","observe","childList","tmpl","document","createElement","URL","import","meta","url","href","rootDiv","classList","add","shadowRoot","attachShadow","mode","_container","insertAdjacentHTML","mapDefaultCSS","id","shadowRootCSS","hideElementsCSS","appendChild","content","cloneNode","getRootNode","ShadowRoot","getElementById","prepend","head","insertAdjacentElement","name","L","center","LatLng","resolutions","query","contextMenu","announceMovement","featureIndex","mapEl","zoomControl","_addToHistory","_createControls","_toggleControls","_crosshair","crosshair","addTo","featureIndexOverlayOption","_featureIndexOverlay","featureIndexOverlay","poster","Browser","gecko","_setUpEvents","disconnectedCallback","_removeEvents","firstChild","removeChild","remove","_deleteControls","adoptedCallback","attributeChangedCallback","oldValue","newValue","valueSet","_hideControls","_showControls","connect","layersReady","disable","layer","querySelectorAll","reAttach","push","whenReady","Promise","allSettled","zoomTo","enable","dispatchEvent","CustomEvent","bind","_resetHistory","_debug","toggleDebug","mapSize","getSize","y","totalSize","_layerControl","layerControl","collapsed","on","collapse","scaleValue","announceScale","metric","imperial","_scaleBar","scaleBar","_zoomControl","control","_reloadButton","reloadButton","_fullScreenControl","fullscreenButton","_geolocationButton","geolocationButton","toggleContextMenuItem","_setControlsVisibility","forEach","toLowerCase","_layers","hide","container","children","childEl","isStatic","dragging","touchZoom","doubleClickZoom","scrollWheelZoom","boxZoom","keyboard","_dropHandler","event","preventDefault","text","dataTransfer","getData","_pasteLayer","_dragoverHandler","dropEffect","off","removeEventListener","addEventListener","e","target","tagName","details","originalEvent","host","parentElement","keyCode","activeElement","className","detail","ctrlKey","navigator","clipboard","readText","nodeName","fire","latlng","accuracy","error","message","lng","x","containerPoint","_updateMapCenter","setMapMinAndMaxZoom","whenLayersReady","_layerEl","setMaxZoom","setMinZoom","fullscreenElement","setViewFullScreenInnerHTML","reload","altKey","forward","back","locate","stop","setView","undefined","debugOverlay","style","invalidateSize","Number","isInteger","location","getCenter","mapLocation","splice","prev","history","curr","scale","panBy","animate","setZoom","next","initialLocation","shift","getContainer","focus","_toggleFullScreen","toggleFullscreen","viewSource","blob","Blob","type","createObjectURL","open","revokeObjectURL","defineCustomProjection","jsonTemplate","t","JSON","parse","proj4string","origin","bounds","indexOf","toUpperCase","tileSize","includes","tilesize","TILE_SIZE","Proj","CRS","tcrs","horizontal","min","max","Math","round","vertical","pcrs","gcrs","unproject","OSMTILE","latLngBounds","point","tile","tilematrix","resolve","reject","interval","failureTimer","setInterval","viewer","clearInterval","clearTimeout","p","geojson2mapml","json","geojsonLayer","_ready","customElements","define","extends"],"mappings":";;+CAESA,iCACAC,mCACAC,yCACAC,yCACAC,uCACAC,qCACAC,uCACAC,mCACAC,oCAEIC,eAAeC,eAC1BC,gCACE,MAAO,CACL,MACA,MACA,OACA,aACA,QACA,SACA,WACA,SACA,gBAQJC,eACE,OAAOC,KAAKC,aAAa,YAE3BF,aAAaG,GACSC,QAAQD,GAE1BF,KAAKI,aAAa,WAAY,IAE9BJ,KAAKK,gBAAgB,YAGzBC,mBACE,OAAON,KAAKO,cAEdD,iBAAiBJ,GACfF,KAAKO,cAAcL,MAAQA,EAC3BF,KAAKI,aAAa,eAAgBF,GAEpCM,YACE,OAAQC,OAAOC,iBAAiBV,MAAMQ,MAAMG,QAAQ,KAAM,IAE5DH,UAAUI,GAERZ,KAAKI,aAAa,QAASQ,GAE7BC,aACE,OAAQJ,OAAOC,iBAAiBV,MAAMa,OAAOF,QAAQ,KAAM,IAE7DE,WAAWD,GAETZ,KAAKI,aAAa,SAAUQ,GAE9BE,UACE,QAASd,KAAKC,aAAa,OAASD,KAAKe,aAAa,OAAS,GAEjED,QAAQF,GACFA,GACFZ,KAAKI,aAAa,MAAOQ,GAG7BI,UACE,QAAShB,KAAKC,aAAa,OAASD,KAAKe,aAAa,OAAS,GAEjEC,QAAQJ,GACFA,GACFZ,KAA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-map.js","sources":["../src/web-map.js"],"sourcesContent":["import './leaflet.js'; // bundled with proj4, proj4leaflet, modularized\nimport './mapml.js';\nimport { MapLayer } from './layer.js';\nimport { MapArea } from './map-area.js';\nimport { MapCaption } from './map-caption.js';\nimport { MapFeature } from './map-feature.js';\nimport { MapExtent } from './map-extent.js';\nimport { MapInput } from './map-input.js';\nimport { MapSelect } from './map-select.js';\nimport { MapLink } from './map-link.js';\nimport { MapStyle } from './map-style.js';\n\nexport class WebMap extends HTMLMapElement {\n static get observedAttributes() {\n return [\n 'lat',\n 'lon',\n 'zoom',\n 'projection',\n 'width',\n 'height',\n 'controls',\n 'static',\n 'controlslist'\n ];\n }\n // see comments below regarding attributeChangedCallback vs. getter/setter\n // usage. Effectively, the user of the element must use the property, not\n // the getAttribute/setAttribute/removeAttribute DOM API, because the latter\n // calls don't result in the getter/setter being called (so you have to use\n // the getter/setter directly)\n get controls() {\n return this.hasAttribute('controls');\n }\n set controls(value) {\n const hasControls = Boolean(value);\n if (hasControls) {\n this.setAttribute('controls', '');\n } else {\n this.removeAttribute('controls');\n }\n }\n get controlsList() {\n return this._controlsList;\n }\n set controlsList(value) {\n this._controlsList.value = value;\n this.setAttribute('controlslist', value);\n }\n get width() {\n return +window.getComputedStyle(this).width.replace('px', '');\n }\n set width(val) {\n //img.height or img.width setters change or add the corresponding attributes\n this.setAttribute('width', val);\n }\n get height() {\n return +window.getComputedStyle(this).height.replace('px', '');\n }\n set height(val) {\n //img.height or img.width setters change or add the corresponding attributes\n this.setAttribute('height', val);\n }\n get lat() {\n return +(this.hasAttribute('lat') ? this.getAttribute('lat') : 0);\n }\n set lat(val) {\n if (val) {\n this.setAttribute('lat', val);\n }\n }\n get lon() {\n return +(this.hasAttribute('lon') ? this.getAttribute('lon') : 0);\n }\n set lon(val) {\n if (val) {\n this.setAttribute('lon', val);\n }\n }\n get projection() {\n return this.hasAttribute('projection')\n ? this.getAttribute('projection')\n : 'OSMTILE';\n }\n set projection(val) {\n if (val) {\n this.whenProjectionDefined(val)\n .then(() => {\n this.setAttribute('projection', val);\n })\n .catch(() => {\n throw new Error('Undefined projection: ' + val);\n });\n }\n }\n get zoom() {\n return +(this.hasAttribute('zoom') ? this.getAttribute('zoom') : 0);\n }\n set zoom(val) {\n var parsedVal = parseInt(val, 10);\n if (!isNaN(parsedVal) && parsedVal >= 0 && parsedVal <= 25) {\n this.setAttribute('zoom', parsedVal);\n }\n }\n get layers() {\n return this.getElementsByTagName('layer-');\n }\n get areas() {\n return this.getElementsByTagName('area');\n }\n\n get extent() {\n let map = this._map,\n pcrsBounds = M.pixelToPCRSBounds(\n map.getPixelBounds(),\n map.getZoom(),\n map.options.projection\n );\n let formattedExtent = M._convertAndFormatPCRS(\n pcrsBounds,\n map.options.crs,\n this.projection\n );\n // get min/max zoom from layers at this moment\n let minZoom = Infinity,\n maxZoom = -Infinity;\n for (let i = 0; i < this.layers.length; i++) {\n if (this.layers[i].extent) {\n if (this.layers[i].extent.zoom.minZoom < minZoom)\n minZoom = this.layers[i].extent.zoom.minZoom;\n if (this.layers[i].extent.zoom.maxZoom > maxZoom)\n maxZoom = this.layers[i].extent.zoom.maxZoom;\n }\n }\n\n formattedExtent.zoom = {\n minZoom: minZoom !== Infinity ? minZoom : map.getMinZoom(),\n maxZoom: maxZoom !== -Infinity ? maxZoom : map.getMaxZoom()\n };\n return formattedExtent;\n }\n get static() {\n return this.hasAttribute('static');\n }\n set static(value) {\n const isStatic = Boolean(value);\n if (isStatic) this.setAttribute('static', '');\n else this.removeAttribute('static');\n }\n\n constructor() {\n // Always call super first in constructor\n super();\n this._source = this.outerHTML;\n // create an array to track the history of the map and the current index\n this._history = [];\n this._historyIndex = -1;\n this._traversalCall = false;\n }\n connectedCallback() {\n this.whenProjectionDefined(this.projection)\n .then(() => {\n this._initShadowRoot();\n\n this._controlsList = new M.DOMTokenList(\n this.getAttribute('controlslist'),\n this,\n 'controlslist',\n [\n 'noreload',\n 'nofullscreen',\n 'nozoom',\n 'nolayer',\n 'noscale',\n 'geolocation'\n ]\n );\n\n var s = window.getComputedStyle(this),\n wpx = s.width,\n hpx = s.height,\n w = this.hasAttribute('width')\n ? this.getAttribute('width')\n : parseInt(wpx.replace('px', '')),\n h = this.hasAttribute('height')\n ? this.getAttribute('height')\n : parseInt(hpx.replace('px', ''));\n this._changeWidth(w);\n this._changeHeight(h);\n\n this._createMap();\n\n this._toggleStatic();\n\n /*\n 1. only deletes aria-label when the last (only remaining) map caption is removed\n 2. only deletes aria-label if the aria-label was defined by the map caption element itself\n */\n\n let mapcaption = this.querySelector('map-caption');\n\n if (mapcaption !== null) {\n setTimeout(() => {\n let ariaupdate = this.getAttribute('aria-label');\n\n if (ariaupdate === mapcaption.innerHTML) {\n this.mapCaptionObserver = new MutationObserver((m) => {\n let mapcaptionupdate = this.querySelector('map-caption');\n if (mapcaptionupdate !== mapcaption) {\n this.removeAttribute('aria-label');\n }\n });\n this.mapCaptionObserver.observe(this, {\n childList: true\n });\n }\n }, 0);\n }\n })\n .catch(() => {\n throw new Error('Projection not defined');\n });\n }\n _initShadowRoot() {\n let tmpl = document.createElement('template');\n /* jshint ignore:start */\n tmpl.innerHTML = ``;\n /* jshint ignore:end */\n\n const rootDiv = document.createElement('div');\n rootDiv.classList.add('mapml-web-map');\n\n let shadowRoot = rootDiv.attachShadow({ mode: 'open' });\n this._container = document.createElement('div');\n\n let output =\n \"\";\n this._container.insertAdjacentHTML('beforeend', output);\n\n // Set default styles for the map element.\n let mapDefaultCSS = document.createElement('style');\n mapDefaultCSS.id = 'web-map-default-style';\n mapDefaultCSS.innerHTML =\n `[is=\"web-map\"] {` +\n `all: initial;` + // Reset properties inheritable from html/body, as some inherited styles may cause unexpected issues with the map element's components (https://github.com/Maps4HTML/MapML.js/issues/140).\n `contain: layout size;` + // Contain layout and size calculations within the map element.\n `display: inline-block;` + // This together with dimension properties is required so that Leaflet isn't working with a height=0 box by default.\n `height: 150px;` + // Provide a \"default object size\" (https://github.com/Maps4HTML/HTML-Map-Element/issues/31).\n `width: 300px;` +\n `border-width: 2px;` + // Set a default border for contrast, similar to UA default for iframes.\n `border-style: inset;` +\n `box-sizing: inherit;` + // https://github.com/Maps4HTML/MapML.js/issues/350#issuecomment-888361985\n `}` +\n `[is=\"web-map\"][frameborder=\"0\"] {` +\n `border-width: 0;` +\n `}` +\n `[is=\"web-map\"][hidden] {` +\n `display: none!important;` +\n `}` +\n `[is=\"web-map\"] .mapml-web-map {` +\n `display: contents;` + // This div doesn't have to participate in layout by generating its own box.\n `}`;\n\n let shadowRootCSS = document.createElement('style');\n shadowRootCSS.innerHTML =\n `:host .leaflet-control-container {` +\n `visibility: hidden!important;` + // Visibility hack to improve percieved performance (mitigate FOUC) – visibility is unset in mapml.css! (https://github.com/Maps4HTML/MapML.js/issues/154).\n `}`;\n\n // Hide all (light DOM) children of the map element except for the\n // `` and `
` (shadow root host) elements.\n let hideElementsCSS = document.createElement('style');\n hideElementsCSS.innerHTML =\n `[is=\"web-map\"] > :not(area):not(.mapml-web-map) {` +\n `display: none!important;` +\n `}`;\n this.appendChild(hideElementsCSS);\n\n shadowRoot.appendChild(shadowRootCSS);\n shadowRoot.appendChild(tmpl.content.cloneNode(true));\n shadowRoot.appendChild(this._container);\n this.appendChild(rootDiv);\n if (this.getRootNode() instanceof ShadowRoot) {\n if (!this.getRootNode().getElementById(mapDefaultCSS.id))\n this.getRootNode().prepend(mapDefaultCSS);\n } else {\n if (!document.getElementById(mapDefaultCSS.id))\n document.head.insertAdjacentElement('afterbegin', mapDefaultCSS);\n }\n }\n _createMap() {\n if (!this._map) {\n this._map = L.map(this._container, {\n center: new L.LatLng(this.lat, this.lon),\n minZoom: 0,\n maxZoom: M[this.projection].options.resolutions.length - 1,\n projection: this.projection,\n query: true,\n contextMenu: true,\n announceMovement: M.options.announceMovement,\n featureIndex: true,\n mapEl: this,\n crs: M[this.projection],\n zoom: this.zoom,\n zoomControl: false\n });\n this._addToHistory();\n\n this._createControls();\n this._toggleControls();\n this._crosshair = M.crosshair().addTo(this._map);\n\n if (M.options.featureIndexOverlayOption)\n this._featureIndexOverlay = M.featureIndexOverlay().addTo(this._map);\n\n if (this.hasAttribute('name')) {\n var name = this.getAttribute('name');\n if (name) {\n this.poster = document.querySelector(\n 'img[usemap=' + '\"#' + name + '\"]'\n );\n // firefox has an issue where the attribution control's use of\n // _container.innerHTML does not work properly if the engine is throwing\n // exceptions because there are no area element children of the image map\n // for firefox only, a workaround is to actually remove the image...\n if (this.poster) {\n if (L.Browser.gecko) {\n this.poster.removeAttribute('usemap');\n }\n //this.appendChild(this.poster);\n }\n }\n }\n\n // undisplay the img in the image map, because it's not needed now.\n // gives a slight FOUC, unless:\n // 1) the img is pre-styled (https://github.com/Maps4HTML/MapML.js/blob/80a4a4e372d2ef61bb7cad6a111e17e396b8e908/index-map-area.html#L35)\n // 2) placed after the map element\n if (this.poster) {\n this.poster.setAttribute('hidden', '');\n }\n\n // https://github.com/Maps4HTML/MapML.js/issues/274\n this.setAttribute('role', 'application');\n // Make the Leaflet container element programmatically identifiable\n // (https://github.com/Leaflet/Leaflet/issues/7193).\n this._container.setAttribute('role', 'region');\n this._container.setAttribute('aria-label', 'Interactive map');\n\n this._setUpEvents();\n }\n }\n disconnectedCallback() {\n this._removeEvents();\n let rootDiv = this.querySelector('.mapml-web-map');\n while (rootDiv.shadowRoot.firstChild) {\n rootDiv.shadowRoot.removeChild(rootDiv.shadowRoot.firstChild);\n }\n rootDiv.remove();\n delete this._map;\n this._deleteControls();\n }\n adoptedCallback() {\n // console.log('Custom map element moved to new page.');\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n // console.log('Attribute: ' + name + ' changed from: '+ oldValue + ' to: '+newValue);\n // \"Best practice\": handle side-effects in this callback\n // https://developers.google.com/web/fundamentals/web-components/best-practices\n // https://developers.google.com/web/fundamentals/web-components/best-practices#avoid-reentrancy\n // note that the example is misleading, since the user can't use\n // setAttribute or removeAttribute to set the property, they need to use\n // the property directly in their API usage, which kinda sucks\n /*\n const hasValue = newValue !== null;\n switch (name) {\n case 'checked':\n // Note the attributeChangedCallback is only handling the *side effects*\n // of setting the attribute.\n this.setAttribute('aria-checked', hasValue);\n break;\n ...\n } */\n switch (name) {\n case 'controlslist':\n if (this._controlsList) {\n if (this._controlsList.valueSet === false) {\n this._controlsList.value = newValue;\n }\n this._toggleControls();\n }\n break;\n case 'controls':\n if (oldValue !== null && newValue === null) {\n this._hideControls();\n } else if (oldValue === null && newValue !== null) {\n this._showControls();\n }\n break;\n case 'height':\n if (oldValue !== newValue) {\n this._changeHeight(newValue);\n }\n break;\n case 'width':\n if (oldValue !== newValue) {\n this._changeWidth(newValue);\n }\n break;\n case 'static':\n this._toggleStatic();\n break;\n case 'projection':\n const reconnectLayers = () => {\n if (this._map && this._map.options.projection !== newValue) {\n // save map location and zoom\n let lat = this.lat;\n let lon = this.lon;\n let zoom = this.zoom;\n // saving the lat, lon and zoom is necessary because Leaflet seems\n // to try to compensate for the change in the scales for each zoom\n // level in the crs by changing the zoom level of the map when\n // you set the map crs. So, we save the current view for use below\n // when all the layers' reconnections have settled.\n // leaflet doesn't like this: https://github.com/Leaflet/Leaflet/issues/2553\n this._map.options.crs = M[newValue];\n this._map.options.projection = newValue;\n let layersReady = [];\n this._map.announceMovement.disable();\n for (let layer of this.querySelectorAll('layer-')) {\n layer.removeAttribute('disabled');\n let reAttach = this.removeChild(layer);\n this.appendChild(reAttach);\n layersReady.push(reAttach.whenReady());\n }\n return Promise.allSettled(layersReady).then(() => {\n // use the saved map location to ensure it is correct after\n // changing the map CRS. Specifically affects projection\n // upgrades, e.g. https://maps4html.org/experiments/custom-projections/BNG/\n // see leaflet bug: https://github.com/Leaflet/Leaflet/issues/2553\n this.zoomTo(lat, lon, zoom);\n if (M.options.announceMovement)\n this._map.announceMovement.enable();\n // required to delay until map-extent.disabled is correctly set\n // which happens as a result of layer-._validateDisabled()\n // which happens so much we have to delay until they calls are\n // completed\n setTimeout(() => {\n this.dispatchEvent(new CustomEvent('map-projectionchange'));\n }, 0);\n });\n }\n };\n if (\n newValue &&\n this._map &&\n this._map.options.projection !== newValue\n ) {\n const connect = reconnectLayers.bind(this);\n this.whenProjectionDefined(newValue)\n .then(() => connect())\n .then(() => {\n if (this._map && this._map.options.projection !== oldValue) {\n // this doesn't completely work either\n this._resetHistory();\n }\n if (this._debug) for (let i = 0; i < 2; i++) this.toggleDebug();\n })\n .catch(() => {\n throw new Error('Undefined projection: ' + newValue);\n });\n }\n break;\n }\n }\n\n // Creates All map controls and adds them to the map, when created.\n _createControls() {\n let mapSize = this._map.getSize().y,\n totalSize = 0;\n\n this._layerControl = M.layerControl(null, {\n collapsed: true,\n mapEl: this\n }).addTo(this._map);\n this._map.on('movestart', this._layerControl.collapse, this._layerControl);\n\n let scaleValue = M.options.announceScale;\n\n if (scaleValue === 'metric') {\n scaleValue = { metric: true, imperial: false };\n }\n if (scaleValue === 'imperial') {\n scaleValue = { metric: false, imperial: true };\n }\n\n if (!this._scaleBar)\n this._scaleBar = M.scaleBar(scaleValue).addTo(this._map);\n\n // Only add controls if there is enough top left vertical space\n if (!this._zoomControl && totalSize + 93 <= mapSize) {\n totalSize += 93;\n this._zoomControl = L.control.zoom().addTo(this._map);\n }\n if (!this._reloadButton && totalSize + 49 <= mapSize) {\n totalSize += 49;\n this._reloadButton = M.reloadButton().addTo(this._map);\n }\n if (!this._fullScreenControl && totalSize + 49 <= mapSize) {\n totalSize += 49;\n this._fullScreenControl = M.fullscreenButton().addTo(this._map);\n }\n\n if (!this._geolocationButton) {\n this._geolocationButton = M.geolocationButton().addTo(this._map);\n }\n }\n\n // Sets controls by hiding/unhiding them based on the map attribute\n _toggleControls() {\n if (this.controls === false) {\n this._hideControls();\n this._map.contextMenu.toggleContextMenuItem('Controls', 'disabled');\n } else {\n this._showControls();\n this._map.contextMenu.toggleContextMenuItem('Controls', 'enabled');\n }\n }\n\n _hideControls() {\n this._setControlsVisibility('fullscreen', true);\n this._setControlsVisibility('layercontrol', true);\n this._setControlsVisibility('reload', true);\n this._setControlsVisibility('zoom', true);\n this._setControlsVisibility('geolocation', true);\n this._setControlsVisibility('scale', true);\n }\n _showControls() {\n this._setControlsVisibility('fullscreen', false);\n this._setControlsVisibility('layercontrol', false);\n this._setControlsVisibility('reload', false);\n this._setControlsVisibility('zoom', false);\n this._setControlsVisibility('geolocation', true);\n this._setControlsVisibility('scale', false);\n\n // prune the controls shown if necessary\n // this logic could be embedded in _showControls\n // but would require being able to iterate the domain of supported tokens\n // for the controlslist\n if (this._controlsList) {\n this._controlsList.forEach((value) => {\n switch (value.toLowerCase()) {\n case 'nofullscreen':\n this._setControlsVisibility('fullscreen', true);\n break;\n case 'nolayer':\n this._setControlsVisibility('layercontrol', true);\n break;\n case 'noreload':\n this._setControlsVisibility('reload', true);\n break;\n case 'nozoom':\n this._setControlsVisibility('zoom', true);\n break;\n case 'geolocation':\n this._setControlsVisibility('geolocation', false);\n break;\n case 'noscale':\n this._setControlsVisibility('scale', true);\n break;\n }\n });\n }\n if (this._layerControl && this._layerControl._layers.length === 0) {\n this._layerControl._container.setAttribute('hidden', '');\n }\n }\n\n // delete the map controls that are private properties of this custom element\n _deleteControls() {\n delete this._layerControl;\n delete this._zoomControl;\n delete this._reloadButton;\n delete this._fullScreenControl;\n delete this._geolocationButton;\n delete this._scaleBar;\n }\n // Sets the control's visibility AND all its childrens visibility,\n // for the control element based on the Boolean hide parameter\n _setControlsVisibility(control, hide) {\n let container;\n switch (control) {\n case 'zoom':\n if (this._zoomControl) {\n container = this._zoomControl._container;\n }\n break;\n case 'reload':\n if (this._reloadButton) {\n container = this._reloadButton._container;\n }\n break;\n case 'fullscreen':\n if (this._fullScreenControl) {\n container = this._fullScreenControl._container;\n }\n break;\n case 'layercontrol':\n if (this._layerControl) {\n container = this._layerControl._container;\n }\n break;\n case 'geolocation':\n if (this._geolocationButton) {\n container = this._geolocationButton._container;\n }\n break;\n case 'scale':\n if (this._scaleBar) {\n container = this._scaleBar._container;\n }\n break;\n }\n if (container) {\n if (hide) {\n // setting the visibility for all the children of the element\n [...container.children].forEach((childEl) => {\n childEl.setAttribute('hidden', '');\n });\n container.setAttribute('hidden', '');\n } else {\n // setting the visibility for all the children of the element\n [...container.children].forEach((childEl) => {\n childEl.removeAttribute('hidden');\n });\n container.removeAttribute('hidden');\n }\n }\n }\n _toggleStatic() {\n const isStatic = this.hasAttribute('static');\n if (this._map) {\n if (isStatic) {\n this._map.dragging.disable();\n this._map.touchZoom.disable();\n this._map.doubleClickZoom.disable();\n this._map.scrollWheelZoom.disable();\n this._map.boxZoom.disable();\n this._map.keyboard.disable();\n this._zoomControl.disable();\n } else {\n this._map.dragging.enable();\n this._map.touchZoom.enable();\n this._map.doubleClickZoom.enable();\n this._map.scrollWheelZoom.enable();\n this._map.boxZoom.enable();\n this._map.keyboard.enable();\n this._zoomControl.enable();\n }\n }\n }\n\n _dropHandler(event) {\n event.preventDefault();\n let text = event.dataTransfer.getData('text');\n M._pasteLayer(this, text);\n }\n _dragoverHandler(event) {\n event.preventDefault();\n event.dataTransfer.dropEffect = 'copy';\n }\n _removeEvents() {\n if (this._map) {\n this._map.off();\n this.removeEventListener('drop', this._dropHandler, false);\n this.removeEventListener('dragover', this._dragoverHandler, false);\n }\n }\n _setUpEvents() {\n this.addEventListener('drop', this._dropHandler, false);\n this.addEventListener('dragover', this._dragoverHandler, false);\n this.addEventListener(\n 'change',\n function (e) {\n if (e.target.tagName === 'LAYER-') {\n this.dispatchEvent(\n new CustomEvent('layerchange', {\n details: { target: this, originalEvent: e }\n })\n );\n }\n },\n false\n );\n\n let host =\n this.getRootNode() instanceof ShadowRoot\n ? this.getRootNode().host\n : this.parentElement;\n host.addEventListener('keyup', function (e) {\n if (\n e.keyCode === 9 &&\n document.activeElement.className === 'mapml-web-map'\n ) {\n // document.activeElement is div.mapml-web-map, not \n document.activeElement.dispatchEvent(\n new CustomEvent('mapfocused', { detail: { target: this } })\n );\n }\n });\n // pasting layer-, links and geojson using Ctrl+V\n this.addEventListener('keydown', function (e) {\n if (e.keyCode === 86 && e.ctrlKey) {\n navigator.clipboard.readText().then((layer) => {\n M._pasteLayer(this, layer);\n });\n // Prevents default spacebar event on all of web-map\n } else if (\n e.keyCode === 32 &&\n document.activeElement.shadowRoot.activeElement.nodeName !== 'INPUT'\n ) {\n e.preventDefault();\n this._map.fire('keypress', { originalEvent: e });\n }\n });\n host.addEventListener('mousedown', function (e) {\n if (document.activeElement.className === 'mapml-web-map') {\n document.activeElement.dispatchEvent(\n new CustomEvent('mapfocused', { detail: { target: this } })\n );\n }\n });\n\n this._map.on(\n 'locationfound',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('maplocationfound', {\n detail: { latlng: e.latlng, accuracy: e.accuracy }\n })\n );\n },\n this\n );\n this._map.on(\n 'locationerror',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('locationerror', { detail: { error: e.message } })\n );\n },\n this\n );\n this._map.on(\n 'load',\n function () {\n this.dispatchEvent(\n new CustomEvent('load', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'preclick',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('preclick', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'click',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('click', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'dblclick',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('dblclick', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mousemove',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mousemove', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mouseover',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mouseover', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mouseout',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mouseout', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mousedown',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mousedown', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'mouseup',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('mouseup', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'contextmenu',\n function (e) {\n this.dispatchEvent(\n new CustomEvent('contextmenu', {\n detail: {\n lat: e.latlng.lat,\n lon: e.latlng.lng,\n x: e.containerPoint.x,\n y: e.containerPoint.y\n }\n })\n );\n },\n this\n );\n this._map.on(\n 'movestart',\n function () {\n this.dispatchEvent(\n new CustomEvent('movestart', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'move',\n function () {\n this.dispatchEvent(\n new CustomEvent('move', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'moveend',\n function () {\n this._updateMapCenter();\n this._addToHistory();\n this.dispatchEvent(\n new CustomEvent('map-moveend', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'zoomstart',\n function () {\n this.dispatchEvent(\n new CustomEvent('zoomstart', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'zoom',\n function () {\n this.dispatchEvent(\n new CustomEvent('zoom', { detail: { target: this } })\n );\n },\n this\n );\n this._map.on(\n 'zoomend',\n function () {\n this._updateMapCenter();\n this.dispatchEvent(\n new CustomEvent('zoomend', { detail: { target: this } })\n );\n },\n this\n );\n const setMapMinAndMaxZoom = ((e) => {\n this.whenLayersReady().then(() => {\n if (e && e.layer._layerEl) {\n this._map.setMaxZoom(this.extent.zoom.maxZoom);\n this._map.setMinZoom(this.extent.zoom.minZoom);\n }\n });\n }).bind(this);\n this.whenLayersReady().then(() => {\n this._map.setMaxZoom(this.extent.zoom.maxZoom);\n this._map.setMinZoom(this.extent.zoom.minZoom);\n this._map.on('layeradd layerremove', setMapMinAndMaxZoom, this);\n });\n this.addEventListener('fullscreenchange', function (event) {\n if (document.fullscreenElement === null) {\n // full-screen mode has been exited\n this._map.contextMenu.setViewFullScreenInnerHTML('view');\n } else {\n this._map.contextMenu.setViewFullScreenInnerHTML('exit');\n }\n });\n this.addEventListener('keydown', function (event) {\n if (document.activeElement.className === 'mapml-web-map') {\n // Check if Ctrl+R is pressed and map is focused\n if (event.ctrlKey && event.keyCode === 82) {\n // Prevent default browser behavior\n event.preventDefault();\n this.reload();\n } else if (event.altKey && event.keyCode === 39) {\n // Prevent default browser behavior\n event.preventDefault();\n this.forward();\n } else if (event.altKey && event.keyCode === 37) {\n // Prevent default browser behavior\n event.preventDefault();\n this.back();\n }\n }\n });\n }\n\n locate(options) {\n //options: https://leafletjs.com/reference.html#locate-options\n if (this._geolocationButton) {\n this._geolocationButton.stop();\n }\n if (options) {\n if (options.zoomTo) {\n options.setView = options.zoomTo;\n delete options.zoomTo;\n }\n this._map.locate(options);\n } else {\n this._map.locate({ setView: true, maxZoom: 16 });\n }\n }\n\n toggleDebug() {\n if (this._debug) {\n this._debug.remove();\n this._debug = undefined;\n } else {\n this._debug = M.debugOverlay().addTo(this._map);\n }\n }\n\n _changeWidth(width) {\n if (this._container) {\n this._container.style.width = width + 'px';\n document.querySelector('[is=\"web-map\"]').style.width = width + 'px';\n }\n if (this._map) {\n this._map.invalidateSize(false);\n }\n }\n _changeHeight(height) {\n if (this._container) {\n this._container.style.height = height + 'px';\n document.querySelector('[is=\"web-map\"]').style.height = height + 'px';\n }\n if (this._map) {\n this._map.invalidateSize(false);\n }\n }\n zoomTo(lat, lon, zoom) {\n zoom = Number.isInteger(+zoom) ? +zoom : this.zoom;\n let location = new L.LatLng(+lat, +lon);\n this._map.setView(location, zoom);\n this.zoom = zoom;\n this.lat = location.lat;\n this.lon = location.lng;\n }\n _updateMapCenter() {\n // remember to tell Leaflet event handler that 'this' in here refers to\n // something other than the map in this case the custom polymer element\n this.lat = this._map.getCenter().lat;\n this.lon = this._map.getCenter().lng;\n this.zoom = this._map.getZoom();\n }\n _resetHistory() {\n this._history = [];\n this._historyIndex = -1;\n this._traversalCall = false;\n // weird but ok\n this._addToHistory();\n }\n /**\n * Adds to the maps history on moveends\n * @private\n */\n _addToHistory() {\n if (this._traversalCall > 0) {\n // this._traversalCall tracks how many consecutive moveends to ignore from history\n this._traversalCall--; // this is useful for ignoring moveends corresponding to back, forward and reload\n return;\n }\n\n let mapLocation = this._map.getPixelBounds().getCenter();\n let location = {\n zoom: this._map.getZoom(),\n x: mapLocation.x,\n y: mapLocation.y\n };\n this._historyIndex++;\n this._history.splice(this._historyIndex, 0, location);\n // Remove future history and overwrite it when map pan/zoom while inside history\n if (this._historyIndex + 1 !== this._history.length) {\n this._history.length = this._historyIndex + 1;\n }\n if (this._historyIndex === 0) {\n // when at initial state of map, disable back, forward, and reload items\n this._map.contextMenu.toggleContextMenuItem('Back', 'disabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'disabled'); // reload contextmenu item\n this._reloadButton?.disable();\n } else {\n this._map.contextMenu.toggleContextMenuItem('Back', 'enabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'enabled'); // reload contextmenu item\n this._reloadButton?.enable();\n }\n }\n /**\n * Allow user to move back in history\n */\n back() {\n let history = this._history;\n let curr = history[this._historyIndex];\n\n if (this._historyIndex > 0) {\n this._map.contextMenu.toggleContextMenuItem('Forward', 'enabled'); // forward contextmenu item\n this._historyIndex--;\n let prev = history[this._historyIndex];\n // Disable back, reload contextmenu item when at the end of history\n if (this._historyIndex === 0) {\n this._map.contextMenu.toggleContextMenuItem('Back', 'disabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'disabled'); // reload contextmenu item\n this._reloadButton?.disable();\n }\n\n if (prev.zoom !== curr.zoom) {\n this._traversalCall = 2; // allows the next 2 moveends to be ignored from history\n\n let currScale = this._map.options.crs.scale(curr.zoom); // gets the scale of the current zoom level\n let prevScale = this._map.options.crs.scale(prev.zoom); // gets the scale of the previous zoom level\n\n let scale = currScale / prevScale; // used to convert the previous pixel location to be in terms of the current zoom level\n\n this._map.panBy([prev.x * scale - curr.x, prev.y * scale - curr.y], {\n animate: false\n });\n this._map.setZoom(prev.zoom);\n } else {\n this._traversalCall = 1;\n this._map.panBy([prev.x - curr.x, prev.y - curr.y]);\n }\n }\n }\n\n /**\n * Allows user to move forward in history\n */\n forward() {\n let history = this._history;\n let curr = history[this._historyIndex];\n if (this._historyIndex < history.length - 1) {\n this._map.contextMenu.toggleContextMenuItem('Back', 'enabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'enabled'); // reload contextmenu item\n this._reloadButton?.enable();\n this._historyIndex++;\n let next = history[this._historyIndex];\n // disable forward contextmenu item, when at the end of forward history\n if (this._historyIndex + 1 === this._history.length) {\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n }\n\n if (next.zoom !== curr.zoom) {\n this._traversalCall = 2; // allows the next 2 moveends to be ignored from history\n\n let currScale = this._map.options.crs.scale(curr.zoom); // gets the scale of the current zoom level\n let nextScale = this._map.options.crs.scale(next.zoom); // gets the scale of the next zoom level\n\n let scale = currScale / nextScale; // used to convert the next pixel location to be in terms of the current zoom level\n\n this._map.panBy([next.x * scale - curr.x, next.y * scale - curr.y], {\n animate: false\n });\n this._map.setZoom(next.zoom);\n } else {\n this._traversalCall = 1;\n this._map.panBy([next.x - curr.x, next.y - curr.y]);\n }\n }\n }\n\n /**\n * Allows the user to reload/reset the map's location to it's initial location\n */\n reload() {\n let initialLocation = this._history.shift();\n let mapLocation = this._map.getPixelBounds().getCenter();\n let curr = {\n zoom: this._map.getZoom(),\n x: mapLocation.x,\n y: mapLocation.y\n };\n\n this._map.contextMenu.toggleContextMenuItem('Back', 'disabled'); // back contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Forward', 'disabled'); // forward contextmenu item\n this._map.contextMenu.toggleContextMenuItem('Reload', 'disabled'); // reload contextmenu item\n this._reloadButton?.disable();\n\n this._history = [initialLocation];\n this._historyIndex = 0;\n\n if (initialLocation.zoom !== curr.zoom) {\n this._traversalCall = 2; // ignores the next 2 moveend events\n\n let currScale = this._map.options.crs.scale(curr.zoom); // gets the scale of the current zoom level\n let initScale = this._map.options.crs.scale(initialLocation.zoom); // gets the scale of the initial location's zoom\n\n let scale = currScale / initScale;\n\n this._map.panBy(\n [\n initialLocation.x * scale - curr.x,\n initialLocation.y * scale - curr.y\n ],\n { animate: false }\n );\n this._map.setZoom(initialLocation.zoom);\n } else {\n // if it's on the same zoom level as the initial location, no need to calculate scales\n this._traversalCall = 1;\n this._map.panBy([initialLocation.x - curr.x, initialLocation.y - curr.y]);\n }\n this._map.getContainer().focus();\n }\n\n _toggleFullScreen() {\n this._map.toggleFullscreen();\n }\n\n viewSource() {\n let blob = new Blob([this._source], { type: 'text/plain' }),\n url = URL.createObjectURL(blob);\n window.open(url);\n URL.revokeObjectURL(url);\n }\n\n defineCustomProjection(jsonTemplate) {\n let t = JSON.parse(jsonTemplate);\n if (\n t === undefined ||\n !t.proj4string ||\n !t.projection ||\n !t.resolutions ||\n !t.origin ||\n !t.bounds\n )\n throw new Error('Incomplete TCRS Definition');\n if (t.projection.indexOf(':') >= 0)\n throw new Error('\":\" is not permitted in projection name');\n if (M[t.projection.toUpperCase()]) return t.projection.toUpperCase();\n let tileSize = [256, 512, 1024, 2048, 4096].includes(t.tilesize)\n ? t.tilesize\n : M.TILE_SIZE;\n\n M[t.projection] = new L.Proj.CRS(t.projection, t.proj4string, {\n origin: t.origin,\n resolutions: t.resolutions,\n bounds: L.bounds(t.bounds),\n crs: {\n tcrs: {\n horizontal: {\n name: 'x',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.bounds.getSize().x /\n M[t.projection].options.resolutions[zoom]\n )\n },\n vertical: {\n name: 'y',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.bounds.getSize().y /\n M[t.projection].options.resolutions[zoom]\n )\n },\n bounds: (zoom) =>\n L.bounds(\n [\n M[t.projection].options.crs.tcrs.horizontal.min,\n M[t.projection].options.crs.tcrs.vertical.min\n ],\n [\n M[t.projection].options.crs.tcrs.horizontal.max(zoom),\n M[t.projection].options.crs.tcrs.vertical.max(zoom)\n ]\n )\n },\n pcrs: {\n horizontal: {\n name: 'easting',\n get min() {\n return M[t.projection].options.bounds.min.x;\n },\n get max() {\n return M[t.projection].options.bounds.max.x;\n }\n },\n vertical: {\n name: 'northing',\n get min() {\n return M[t.projection].options.bounds.min.y;\n },\n get max() {\n return M[t.projection].options.bounds.max.y;\n }\n },\n get bounds() {\n return M[t.projection].options.bounds;\n }\n },\n gcrs: {\n horizontal: {\n name: 'longitude',\n // set min/max axis values from EPSG registry area of use, retrieved 2019-07-25\n get min() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.min)\n .lng;\n },\n get max() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.max)\n .lng;\n }\n },\n vertical: {\n name: 'latitude',\n // set min/max axis values from EPSG registry area of use, retrieved 2019-07-25\n get min() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.min)\n .lat;\n },\n get max() {\n return M[t.projection].unproject(M.OSMTILE.options.bounds.max)\n .lat;\n }\n },\n get bounds() {\n return L.latLngBounds(\n [\n M[t.projection].options.crs.gcrs.vertical.min,\n M[t.projection].options.crs.gcrs.horizontal.min\n ],\n [\n M[t.projection].options.crs.gcrs.vertical.max,\n M[t.projection].options.crs.gcrs.horizontal.max\n ]\n );\n }\n },\n map: {\n horizontal: {\n name: 'i',\n min: 0,\n max: (map) => map.getSize().x\n },\n vertical: {\n name: 'j',\n min: 0,\n max: (map) => map.getSize().y\n },\n bounds: (map) => L.bounds(L.point([0, 0]), map.getSize())\n },\n tile: {\n horizontal: {\n name: 'i',\n min: 0,\n max: tileSize\n },\n vertical: {\n name: 'j',\n min: 0,\n max: tileSize\n },\n get bounds() {\n return L.bounds(\n [\n M[t.projection].options.crs.tile.horizontal.min,\n M[t.projection].options.crs.tile.vertical.min\n ],\n [\n M[t.projection].options.crs.tile.horizontal.max,\n M[t.projection].options.crs.tile.vertical.max\n ]\n );\n }\n },\n tilematrix: {\n horizontal: {\n name: 'column',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.crs.tcrs.horizontal.max(zoom) /\n M[t.projection].options.crs.tile.bounds.getSize().x\n )\n },\n vertical: {\n name: 'row',\n min: 0,\n max: (zoom) =>\n Math.round(\n M[t.projection].options.crs.tcrs.vertical.max(zoom) /\n M[t.projection].options.crs.tile.bounds.getSize().y\n )\n },\n bounds: (zoom) =>\n L.bounds(\n [\n M[t.projection].options.crs.tilematrix.horizontal.min,\n M[t.projection].options.crs.tilematrix.vertical.min\n ],\n [\n M[t.projection].options.crs.tilematrix.horizontal.max(zoom),\n M[t.projection].options.crs.tilematrix.vertical.max(zoom)\n ]\n )\n }\n }\n }); //creates crs using L.Proj\n M[t.projection.toUpperCase()] = M[t.projection]; //adds the projection uppercase to global M\n return t.projection;\n }\n whenReady() {\n return new Promise((resolve, reject) => {\n let interval, failureTimer;\n if (this._map) {\n resolve();\n } else {\n let viewer = this;\n interval = setInterval(testForMap, 200, viewer);\n failureTimer = setTimeout(mapNotDefined, 5000);\n }\n function testForMap(viewer) {\n if (viewer._map) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n resolve();\n }\n }\n function mapNotDefined() {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Timeout reached waiting for map to be ready');\n }\n });\n }\n whenLayersReady() {\n let layersReady = [];\n // check if all the children elements (map-extent, map-feature) of all layer- are ready\n for (let layer of [...this.layers]) {\n layersReady.push(layer.whenReady());\n }\n return Promise.allSettled(layersReady);\n }\n whenProjectionDefined(projection) {\n return new Promise((resolve, reject) => {\n let interval, failureTimer;\n if (M[projection]) {\n resolve();\n } else {\n interval = setInterval(testForProjection, 200, projection);\n failureTimer = setTimeout(projectionNotDefined, 5000);\n }\n function testForProjection(p) {\n if (M[p]) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n resolve();\n }\n }\n function projectionNotDefined() {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Timeout reached waiting for projection to be defined');\n }\n });\n }\n geojson2mapml(json, options = {}) {\n if (options.projection === undefined) {\n options.projection = this.projection;\n }\n let geojsonLayer = M.geojson2mapml(json, options);\n this.appendChild(geojsonLayer);\n return geojsonLayer;\n }\n\n _ready() {\n if (this.hasAttribute('name')) {\n var name = this.getAttribute('name');\n if (name) {\n this.poster = document.querySelector(\n 'img[usemap=' + '\"#' + name + '\"]'\n );\n // firefox has an issue where the attribution control's use of\n // _container.innerHTML does not work properly if the engine is throwing\n // exceptions because there are no area element children of the image map\n // for firefox only, a workaround is to actually remove the image...\n if (this.poster) {\n if (L.Browser.gecko) {\n this.poster.removeAttribute('usemap');\n }\n this._container.appendChild(this.poster);\n }\n }\n }\n }\n}\n// need to provide options { extends: ... } for custom built-in elements\nwindow.customElements.define('web-map', WebMap, { extends: 'map' });\nwindow.customElements.define('layer-', MapLayer);\nwindow.customElements.define('map-area', MapArea, { extends: 'area' });\nwindow.customElements.define('map-caption', MapCaption);\nwindow.customElements.define('map-feature', MapFeature);\nwindow.customElements.define('map-extent', MapExtent);\nwindow.customElements.define('map-input', MapInput);\nwindow.customElements.define('map-select', MapSelect);\nwindow.customElements.define('map-link', MapLink);\nwindow.customElements.define('map-style', MapStyle);\n"],"names":["MapLayer","MapArea","MapCaption","MapFeature","MapExtent","MapInput","MapSelect","MapLink","MapStyle","WebMap","HTMLMapElement","observedAttributes","controls","this","hasAttribute","value","Boolean","setAttribute","removeAttribute","controlsList","_controlsList","width","window","getComputedStyle","replace","val","height","lat","getAttribute","lon","projection","whenProjectionDefined","then","catch","Error","zoom","parsedVal","parseInt","isNaN","layers","getElementsByTagName","areas","extent","let","map","_map","pcrsBounds","M","pixelToPCRSBounds","getPixelBounds","getZoom","options","formattedExtent","_convertAndFormatPCRS","crs","minZoom","Infinity","maxZoom","i","length","getMinZoom","getMaxZoom","static","constructor","super","_source","outerHTML","_history","_historyIndex","_traversalCall","connectedCallback","_initShadowRoot","DOMTokenList","s","wpx","hpx","w","h","_changeWidth","_changeHeight","_createMap","_toggleStatic","mapcaption","querySelector","setTimeout","innerHTML","mapCaptionObserver","MutationObserver","observe","childList","tmpl","document","createElement","URL","import","meta","url","href","rootDiv","classList","add","shadowRoot","attachShadow","mode","_container","insertAdjacentHTML","mapDefaultCSS","id","shadowRootCSS","hideElementsCSS","appendChild","content","cloneNode","getRootNode","ShadowRoot","getElementById","prepend","head","insertAdjacentElement","name","L","center","LatLng","resolutions","query","contextMenu","announceMovement","featureIndex","mapEl","zoomControl","_addToHistory","_createControls","_toggleControls","_crosshair","crosshair","addTo","featureIndexOverlayOption","_featureIndexOverlay","featureIndexOverlay","poster","Browser","gecko","_setUpEvents","disconnectedCallback","_removeEvents","firstChild","removeChild","remove","_deleteControls","adoptedCallback","attributeChangedCallback","oldValue","newValue","valueSet","_hideControls","_showControls","connect","layersReady","disable","layer","querySelectorAll","reAttach","push","whenReady","Promise","allSettled","zoomTo","enable","dispatchEvent","CustomEvent","bind","_resetHistory","_debug","toggleDebug","mapSize","getSize","y","totalSize","_layerControl","layerControl","collapsed","on","collapse","scaleValue","announceScale","metric","imperial","_scaleBar","scaleBar","_zoomControl","control","_reloadButton","reloadButton","_fullScreenControl","fullscreenButton","_geolocationButton","geolocationButton","toggleContextMenuItem","_setControlsVisibility","forEach","toLowerCase","_layers","hide","container","children","childEl","isStatic","dragging","touchZoom","doubleClickZoom","scrollWheelZoom","boxZoom","keyboard","_dropHandler","event","preventDefault","text","dataTransfer","getData","_pasteLayer","_dragoverHandler","dropEffect","off","removeEventListener","addEventListener","e","target","tagName","details","originalEvent","host","parentElement","keyCode","activeElement","className","detail","ctrlKey","navigator","clipboard","readText","nodeName","fire","latlng","accuracy","error","message","lng","x","containerPoint","_updateMapCenter","setMapMinAndMaxZoom","whenLayersReady","_layerEl","setMaxZoom","setMinZoom","fullscreenElement","setViewFullScreenInnerHTML","reload","altKey","forward","back","locate","stop","setView","undefined","debugOverlay","style","invalidateSize","Number","isInteger","location","getCenter","mapLocation","splice","prev","history","curr","scale","panBy","animate","setZoom","next","initialLocation","shift","getContainer","focus","_toggleFullScreen","toggleFullscreen","viewSource","blob","Blob","type","createObjectURL","open","revokeObjectURL","defineCustomProjection","jsonTemplate","t","JSON","parse","proj4string","origin","bounds","indexOf","toUpperCase","tileSize","includes","tilesize","TILE_SIZE","Proj","CRS","tcrs","horizontal","min","max","Math","round","vertical","pcrs","gcrs","unproject","OSMTILE","latLngBounds","point","tile","tilematrix","resolve","reject","interval","failureTimer","setInterval","viewer","clearInterval","clearTimeout","p","geojson2mapml","json","geojsonLayer","_ready","customElements","define","extends"],"mappings":";;+CAESA,iCACAC,mCACAC,yCACAC,yCACAC,uCACAC,qCACAC,uCACAC,mCACAC,oCAEIC,eAAeC,eAC1BC,gCACE,MAAO,CACL,MACA,MACA,OACA,aACA,QACA,SACA,WACA,SACA,gBAQJC,eACE,OAAOC,KAAKC,aAAa,YAE3BF,aAAaG,GACSC,QAAQD,GAE1BF,KAAKI,aAAa,WAAY,IAE9BJ,KAAKK,gBAAgB,YAGzBC,mBAC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