diff --git a/dist/layer.js b/dist/layer.js index 63d4bf10..4c058f16 100644 --- a/dist/layer.js +++ b/dist/layer.js @@ -1,4 +1,4 @@ -/*! @maps4html/web-map-custom-element 09-11-2023 */ +/*! @maps4html/web-map-custom-element 15-11-2023 */ -import"./leaflet.js";import"./mapml.js";class MapLayer extends HTMLElement{static get observedAttributes(){return["src","label","checked","hidden","opacity"]}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.bounds||this._layer._calculateBounds(),Object.assign(M._convertAndFormatPCRS(this._layer.bounds,this._layer._properties.crs,this._layer._properties.projection),{zoom:this._layer.zoomBounds})}constructor(){super()}disconnectedCallback(){this.hasAttribute("data-moving")||this._onRemove()}_onRemove(){this._layer&&this._layer.off(),this._layer&&this._layer._map&&this._layer._map.removeLayer(this._layer),this._layerControl&&!this.hidden&&this._layerControl.removeLayer(this._layer),delete this._layer,delete this._fetchError,this.shadowRoot&&(this.shadowRoot.innerHTML="")}connectedCallback(){if(!this.hasAttribute("data-moving")){this._createLayerControlHTML=M._createLayerControlHTML.bind(this),this._opacity=+(this.getAttribute("opacity")||1);const e=this._onAdd.bind(this);this.parentElement.whenReady().then(()=>{e()}).catch(()=>{throw new Error("Map never became ready")})}}_onAdd(){this.getAttribute("src")&&!this.shadowRoot&&this.attachShadow({mode:"open"}),new Promise((r,t)=>{this.addEventListener("changestyle",function(e){e.stopPropagation(),this.src=e.detail.src},{once:!0}),this.addEventListener("changeprojection",function(e){e.stopPropagation(),t(e)},{once:!0});let a=this.baseURI||document.baseURI;const e=new Headers;e.append("Accept","text/mapml"),this.src?fetch(this.src,{headers:e}).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 new Error("Parser error");this._layer&&this._onRemove(),this._layer=M.mapMLLayer(new URL(this.src,a).href,this,t,{mapprojection:this.parentElement.projection,opacity:this.opacity}),this._createLayerControlHTML(),this._attachedToMap(),this._validateDisabled(),r()}).catch(e=>{this._fetchError=!0,console.log("Error fetching layer content"+e)}):(this._layer&&this._onRemove(),this._layer=M.mapMLLayer(null,this,null,{mapprojection:this.parentElement.projection,opacity:this.opacity}),this._createLayerControlHTML(),this._attachedToMap(),this._validateDisabled(),r())}).catch(e=>{"changeprojection"===e.type?this.src=e.detail.href:(console.log(e),this.dispatchEvent(new CustomEvent("error",{detail:{target:this}})))})}_attachedToMap(){for(var e=0,t=1,r=this.parentNode.children;e{this._layer.setName(r)}).catch(e=>{console.log(e)});break;case"checked":this.whenReady().then(()=>{"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"))}).catch(e=>{console.log(e)});break;case"hidden":this.parentElement&&this.parentElement._map&&this.parentElement.controls&&("string"==typeof r?this._layer&&this.parentElement._layerControl.removeLayer(this._layer):(this._layerControl=this.parentElement._layerControl,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._layer&&(this._onRemove(),this.isConnected&&this._onAdd())}}_validateDisabled(){setTimeout(()=>{var i=this._layer;if(i?._map){const o=(this.shadowRoot||this).querySelectorAll("map-extent");let t=0,r=0,a=["_staticTileLayer","_imageLayer","_mapmlvectors","_templatedLayer"];if(i.validProjection)for(let e=0;e{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})))}getOuterHTML(){let t=this.cloneNode(!0);if(this.hasAttribute("src")&&(e=this._layer.getHref(),t.setAttribute("src",e)),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(){this.whenElemsReady().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,l=t.zoom.minZoom;e.setView(s,M.getMaxZoom(i,e,l,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.src&&!this.shadowRoot?.childNodes.length?(a=setInterval(function(e){!e._layer||e.src&&!e.shadowRoot?.childNodes.length?e._fetchError&&(clearInterval(a),clearTimeout(i),r("Error fetching layer content")):(clearInterval(a),clearTimeout(i),t())},200,this),i=setTimeout(function(){clearInterval(a),clearTimeout(i),r("Timeout reached waiting for layer to be ready")},5e3)):t()})}whenElemsReady(){let e=[],t=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}; +import"./leaflet.js";import"./mapml.js";class MapLayer extends HTMLElement{static get observedAttributes(){return["src","label","checked","hidden","opacity"]}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.bounds||this._layer._calculateBounds(),Object.assign(M._convertAndFormatPCRS(this._layer.bounds,this._layer._properties.crs,this._layer._properties.projection),{zoom:this._layer.zoomBounds})}constructor(){super()}disconnectedCallback(){this.hasAttribute("data-moving")||this._onRemove()}_onRemove(){this._layer&&this._layer.off(),this._layer&&this._layer._map&&this._layer._map.removeLayer(this._layer),this._layerControl&&!this.hidden&&this._layerControl.removeLayer(this._layer),delete this._layer,delete this._fetchError,this.shadowRoot&&(this.shadowRoot.innerHTML="")}connectedCallback(){if(!this.hasAttribute("data-moving")){this._createLayerControlHTML=M._createLayerControlHTML.bind(this),this._opacity=this.opacity||1;const e=this._onAdd.bind(this);this.parentElement.whenReady().then(()=>{e()}).catch(()=>{throw new Error("Map never became ready")})}}_onAdd(){this.getAttribute("src")&&!this.shadowRoot&&this.attachShadow({mode:"open"}),new Promise((r,t)=>{this.addEventListener("changestyle",function(e){e.stopPropagation(),this.src=e.detail.src},{once:!0}),this.addEventListener("changeprojection",function(e){e.stopPropagation(),t(e)},{once:!0});let a=this.baseURI||document.baseURI;const e=new Headers;e.append("Accept","text/mapml"),this.src?fetch(this.src,{headers:e}).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 new Error("Parser error");this._layer&&this._onRemove(),this._layer=M.mapMLLayer(new URL(this.src,a).href,this,t,{mapprojection:this.parentElement.projection,opacity:this.opacity}),this._createLayerControlHTML(),this._attachedToMap(),this._validateDisabled(),r()}).catch(e=>{this._fetchError=!0,console.log("Error fetching layer content"+e)}):(this._layer&&this._onRemove(),this._layer=M.mapMLLayer(null,this,null,{mapprojection:this.parentElement.projection,opacity:this.opacity}),this._createLayerControlHTML(),this._attachedToMap(),this._validateDisabled(),r())}).catch(e=>{"changeprojection"===e.type?this.src=e.detail.href:(console.log(e),this.dispatchEvent(new CustomEvent("error",{detail:{target:this}})))})}_attachedToMap(){for(var e=0,t=1,r=this.parentNode.children;e{this._layer.setName(r)}).catch(e=>{console.log(e)});break;case"checked":this.whenReady().then(()=>{"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"))}).catch(e=>{console.log(e)});break;case"hidden":this.parentElement&&this.parentElement._map&&this.parentElement.controls&&("string"==typeof r?this._layer&&this.parentElement._layerControl.removeLayer(this._layer):(this._layerControl=this.parentElement._layerControl,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._layer&&(this._onRemove(),this.isConnected&&this._onAdd())}}_validateDisabled(){setTimeout(()=>{var i=this._layer;if(i?._map){const o=(this.shadowRoot||this).querySelectorAll("map-extent");let t=0,r=0,a=["_staticTileLayer","_imageLayer","_mapmlvectors","_templatedLayer"];for(let e=0;e{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})))}getOuterHTML(){let t=this.cloneNode(!0);if(this.hasAttribute("src")&&(e=this._layer.getHref(),t.setAttribute("src",e)),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(){this.whenElemsReady().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,l=t.zoom.minZoom;e.setView(s,M.getMaxZoom(i,e,l,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.src&&!this.shadowRoot?.childNodes.length?(a=setInterval(function(e){!e._layer||e.src&&!e.shadowRoot?.childNodes.length?e._fetchError&&(clearInterval(a),clearTimeout(i),r("Error fetching layer content")):(clearInterval(a),clearTimeout(i),t())},200,this),i=setTimeout(function(){clearInterval(a),clearTimeout(i),r("Timeout reached waiting for layer to be ready")},5e3)):t()})}whenElemsReady(){let e=[],t=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/dist/layer.js.map b/dist/layer.js.map index 426e9117..37bb9ee2 100644 --- a/dist/layer.js.map +++ b/dist/layer.js.map @@ -1 +1 @@ -{"version":3,"file":"layer.js","sources":["../src/layer.js"],"sourcesContent":["import './leaflet.js'; // a lightly modified version of Leaflet for use as browser module\nimport './mapml.js'; // modified URI to make the function a property of window scope (possibly a bad thing to do).\n\nexport class MapLayer extends HTMLElement {\n static get observedAttributes() {\n return ['src', 'label', 'checked', 'hidden', 'opacity'];\n }\n get src() {\n return this.hasAttribute('src') ? this.getAttribute('src') : '';\n }\n\n set src(val) {\n if (val) {\n this.setAttribute('src', val);\n }\n }\n get label() {\n if (this._layer) return this._layer.getName();\n else return this.hasAttribute('label') ? this.getAttribute('label') : '';\n }\n set label(val) {\n if (val) {\n this.setAttribute('label', val);\n }\n }\n get checked() {\n return this.hasAttribute('checked');\n }\n\n set checked(val) {\n if (val) {\n this.setAttribute('checked', '');\n } else {\n this.removeAttribute('checked');\n }\n }\n\n get hidden() {\n return this.hasAttribute('hidden');\n }\n\n set hidden(val) {\n if (val) {\n this.setAttribute('hidden', '');\n } else {\n this.removeAttribute('hidden');\n }\n }\n\n get opacity() {\n // use ?? since 0 is falsy, || would return rhs in that case\n return +(this._opacity ?? this.getAttribute('opacity'));\n }\n\n set opacity(val) {\n if (+val > 1 || +val < 0) return;\n this.setAttribute('opacity', val);\n }\n\n get extent() {\n // calculate the bounds of all content, return it.\n if (!this._layer.bounds) {\n this._layer._calculateBounds();\n }\n return Object.assign(\n M._convertAndFormatPCRS(\n this._layer.bounds,\n this._layer._properties.crs,\n this._layer._properties.projection\n ),\n { zoom: this._layer.zoomBounds }\n );\n }\n\n constructor() {\n // Always call super first in constructor\n super();\n }\n disconnectedCallback() {\n // if the map-layer node is removed from the dom, the layer should be\n // removed from the map and the layer control\n if (this.hasAttribute('data-moving')) return;\n this._onRemove();\n }\n\n _onRemove() {\n if (this._layer) {\n this._layer.off();\n }\n // if this layer has never been connected, it will not have a _layer\n if (this._layer && this._layer._map) {\n this._layer._map.removeLayer(this._layer);\n }\n\n if (this._layerControl && !this.hidden) {\n this._layerControl.removeLayer(this._layer);\n }\n delete this._layer;\n delete this._fetchError;\n\n if (this.shadowRoot) {\n this.shadowRoot.innerHTML = '';\n }\n }\n\n connectedCallback() {\n if (this.hasAttribute('data-moving')) return;\n this._createLayerControlHTML = M._createLayerControlHTML.bind(this);\n // this._opacity is used to record the current opacity value (with or without updates),\n // the initial value of this._opacity should be set as opacity attribute value, if exists, or the default value 1.0\n this._opacity = +(this.getAttribute('opacity') || 1.0);\n const doConnected = this._onAdd.bind(this);\n this.parentElement\n .whenReady()\n .then(() => {\n doConnected();\n })\n .catch(() => {\n throw new Error('Map never became ready');\n });\n }\n\n _onAdd() {\n if (this.getAttribute('src') && !this.shadowRoot) {\n this.attachShadow({ mode: 'open' });\n }\n new Promise((resolve, reject) => {\n this.addEventListener(\n 'changestyle',\n function (e) {\n e.stopPropagation();\n this.src = e.detail.src;\n },\n { once: true }\n );\n this.addEventListener(\n 'changeprojection',\n function (e) {\n e.stopPropagation();\n reject(e);\n },\n { once: true }\n );\n let base = this.baseURI ? this.baseURI : document.baseURI;\n\n const headers = new Headers();\n headers.append('Accept', 'text/mapml');\n if (this.src) {\n fetch(this.src, { headers: headers })\n .then((response) => {\n if (!response.ok) {\n throw new Error(`HTTP error! Status: ${response.status}`);\n }\n return response.text();\n })\n .then((mapml) => {\n let content = new DOMParser().parseFromString(mapml, 'text/xml');\n if (\n content.querySelector('parsererror') ||\n !content.querySelector('mapml-')\n ) {\n throw new Error('Parser error');\n }\n if (this._layer) {\n this._onRemove();\n }\n this._layer = M.mapMLLayer(\n new URL(this.src, base).href,\n this,\n content,\n {\n mapprojection: this.parentElement.projection,\n opacity: this.opacity\n }\n );\n this._createLayerControlHTML();\n this._attachedToMap();\n this._validateDisabled();\n resolve();\n })\n .catch((error) => {\n this._fetchError = true;\n console.log('Error fetching layer content' + error);\n });\n } else {\n if (this._layer) {\n this._onRemove();\n }\n this._layer = M.mapMLLayer(null, this, null, {\n mapprojection: this.parentElement.projection,\n opacity: this.opacity\n });\n this._createLayerControlHTML();\n this._attachedToMap();\n this._validateDisabled();\n resolve();\n }\n }).catch((e) => {\n if (e.type === 'changeprojection') {\n this.src = e.detail.href;\n } else {\n console.log(e);\n this.dispatchEvent(\n new CustomEvent('error', { detail: { target: this } })\n );\n }\n });\n }\n _attachedToMap() {\n // set i to the position of this layer element in the set of layers\n var i = 0,\n position = 1;\n for (var nodes = this.parentNode.children; i < nodes.length; i++) {\n if (this.parentNode.children[i].nodeName === 'LAYER-') {\n if (this.parentNode.children[i] === this) {\n position = i + 1;\n } else if (this.parentNode.children[i]._layer) {\n this.parentNode.children[i]._layer.setZIndex(i + 1);\n }\n }\n }\n var proj = this.parentNode.projection\n ? this.parentNode.projection\n : 'OSMTILE';\n L.setOptions(this._layer, {\n zIndex: position,\n mapprojection: proj,\n opacity: window.getComputedStyle(this).opacity\n });\n // make sure the Leaflet layer has a reference to the map\n this._layer._map = this.parentNode._map;\n\n if (this.checked) {\n this._layer.addTo(this._layer._map);\n }\n\n this._layer.on('add remove', this._validateDisabled, this);\n // toggle the this.disabled attribute depending on whether the layer\n // is: same prj as map, within view/zoom of map\n this._layer._map.on('moveend layeradd', this._validateDisabled, this);\n\n // if controls option is enabled, insert the layer into the overlays array\n if (this.parentNode._layerControl && !this.hidden) {\n this._layerControl = this.parentNode._layerControl;\n this._layerControl.addOrUpdateOverlay(this._layer, this.label);\n }\n\n // the mapml document associated to this layer can in theory contain many\n // link[@rel=legend] elements with different @type or other attributes;\n // currently only support a single link, don't care about type, lang etc.\n // TODO: add support for full LayerLegend object, and > one link.\n if (this._layer._legendUrl) {\n this.legendLinks = [\n {\n type: 'application/octet-stream',\n href: this._layer._legendUrl,\n rel: 'legend',\n lang: null,\n hreflang: null,\n sizes: null\n }\n ];\n }\n // re-use 'loadedmetadata' event from HTMLMediaElement inteface, applied\n // to MapML extent as metadata\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/loadedmetadata_event\n this.dispatchEvent(\n new CustomEvent('loadedmetadata', { detail: { target: this } })\n );\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n switch (name) {\n case 'label':\n this.whenReady()\n .then(() => {\n this._layer.setName(newValue);\n })\n .catch((e) => {\n console.log(e);\n });\n break;\n case 'checked':\n this.whenReady()\n .then(() => {\n if (typeof newValue === 'string') {\n this.parentElement._map.addLayer(this._layer);\n } else {\n this.parentElement._map.removeLayer(this._layer);\n }\n this._layerControlCheckbox.checked = this.checked;\n this.dispatchEvent(new CustomEvent('map-change'));\n })\n .catch((e) => {\n console.log(e);\n });\n break;\n case 'hidden':\n var map = this.parentElement && this.parentElement._map;\n if (map && this.parentElement.controls) {\n if (typeof newValue === 'string') {\n if (this._layer) {\n this.parentElement._layerControl.removeLayer(this._layer);\n }\n } else {\n this._layerControl = this.parentElement._layerControl;\n this._layerControl.addOrUpdateOverlay(this._layer, this.label);\n this._validateDisabled();\n }\n }\n break;\n case 'opacity':\n if (oldValue !== newValue && this._layer) {\n this._opacity = newValue;\n this._layer.changeOpacity(newValue);\n }\n break;\n case 'src':\n if (oldValue !== newValue && this._layer) {\n this._onRemove();\n if (this.isConnected) {\n this._onAdd();\n }\n // the original inline content will not be removed\n // but has NO EFFECT and works as a fallback\n }\n }\n }\n _validateDisabled() {\n // setTimeout is necessary to make the validateDisabled happen later than the moveend operations etc.,\n // to ensure that the validated result is correct\n setTimeout(() => {\n let layer = this._layer,\n map = layer?._map;\n if (map) {\n // prerequisite: no inline and remote mapml elements exists at the same time\n const mapExtents = this.shadowRoot\n ? this.shadowRoot.querySelectorAll('map-extent')\n : this.querySelectorAll('map-extent');\n let disabledExtentCount = 0,\n totalExtentCount = 0,\n layerTypes = [\n '_staticTileLayer',\n '_imageLayer',\n '_mapmlvectors',\n '_templatedLayer'\n ];\n if (layer.validProjection) {\n for (let j = 0; j < layerTypes.length; j++) {\n let type = layerTypes[j];\n if (this.checked) {\n if (type === '_templatedLayer' && mapExtents.length > 0) {\n for (let i = 0; i < mapExtents.length; i++) {\n totalExtentCount++;\n if (mapExtents[i]._validateDisabled()) disabledExtentCount++;\n }\n } else if (layer[type]) {\n // not a templated layer\n totalExtentCount++;\n if (!layer[type].isVisible) disabledExtentCount++;\n }\n }\n }\n } else {\n disabledExtentCount = 1;\n totalExtentCount = 1;\n }\n // if all extents are not visible / disabled, set layer to disabled\n if (\n disabledExtentCount === totalExtentCount &&\n disabledExtentCount !== 0\n ) {\n this.setAttribute('disabled', '');\n this.disabled = true;\n } else {\n this.removeAttribute('disabled');\n this.disabled = false;\n }\n this.toggleLayerControlDisabled();\n }\n }, 0);\n }\n\n // disable/italicize layer control elements based on the layer-.disabled property\n toggleLayerControlDisabled() {\n let input = this._layerControlCheckbox,\n label = this._layerControlLabel,\n opacityControl = this._opacityControl,\n opacitySlider = this._opacitySlider,\n styleControl = this._styles;\n if (this.disabled) {\n input.disabled = true;\n opacitySlider.disabled = true;\n label.style.fontStyle = 'italic';\n opacityControl.style.fontStyle = 'italic';\n if (styleControl) {\n styleControl.style.fontStyle = 'italic';\n styleControl.querySelectorAll('input').forEach((i) => {\n i.disabled = true;\n });\n }\n } else {\n input.disabled = false;\n opacitySlider.disabled = false;\n label.style.fontStyle = 'normal';\n opacityControl.style.fontStyle = 'normal';\n if (styleControl) {\n styleControl.style.fontStyle = 'normal';\n styleControl.querySelectorAll('input').forEach((i) => {\n i.disabled = false;\n });\n }\n }\n }\n\n getOuterHTML() {\n let tempElement = this.cloneNode(true);\n\n if (this.hasAttribute('src')) {\n let newSrc = this._layer.getHref();\n tempElement.setAttribute('src', newSrc);\n }\n if (this.querySelector('map-link')) {\n let mapLinks = tempElement.querySelectorAll('map-link');\n\n mapLinks.forEach((mapLink) => {\n if (mapLink.hasAttribute('href')) {\n mapLink.setAttribute(\n 'href',\n decodeURI(\n new URL(\n mapLink.attributes.href.value,\n this.baseURI ? this.baseURI : document.baseURI\n ).href\n )\n );\n } else if (mapLink.hasAttribute('tref')) {\n mapLink.setAttribute(\n 'tref',\n decodeURI(\n new URL(\n mapLink.attributes.tref.value,\n this.baseURI ? this.baseURI : document.baseURI\n ).href\n )\n );\n }\n });\n }\n\n let outerLayer = tempElement.outerHTML;\n\n tempElement.remove();\n\n return outerLayer;\n }\n\n zoomTo() {\n this.whenElemsReady().then(() => {\n let map = this.parentElement._map,\n extent = this.extent,\n tL = extent.topLeft.pcrs,\n bR = extent.bottomRight.pcrs,\n layerBounds = L.bounds(\n L.point(tL.horizontal, tL.vertical),\n L.point(bR.horizontal, bR.vertical)\n ),\n center = map.options.crs.unproject(layerBounds.getCenter(true));\n\n let maxZoom = extent.zoom.maxZoom,\n minZoom = extent.zoom.minZoom;\n map.setView(center, M.getMaxZoom(layerBounds, map, minZoom, maxZoom), {\n animate: false\n });\n });\n }\n mapml2geojson(options = {}) {\n return M.mapml2geojson(this, options);\n }\n pasteFeature(feature) {\n switch (typeof feature) {\n case 'string':\n feature.trim();\n if (\n feature.slice(0, 12) === ''\n ) {\n this.insertAdjacentHTML('beforeend', feature);\n }\n break;\n case 'object':\n if (feature.nodeName.toUpperCase() === 'MAP-FEATURE') {\n this.appendChild(feature);\n }\n }\n }\n whenReady() {\n return new Promise((resolve, reject) => {\n let interval, failureTimer;\n if (this._layer && (!this.src || this.shadowRoot?.childNodes.length)) {\n resolve();\n } else {\n let layerElement = this;\n interval = setInterval(testForLayer, 200, layerElement);\n failureTimer = setTimeout(layerNotDefined, 5000);\n }\n function testForLayer(layerElement) {\n if (\n layerElement._layer &&\n (!layerElement.src || layerElement.shadowRoot?.childNodes.length)\n ) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n resolve();\n } else if (layerElement._fetchError) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Error fetching layer content');\n }\n }\n function layerNotDefined() {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Timeout reached waiting for layer to be ready');\n }\n });\n }\n // check if all child elements are ready\n whenElemsReady() {\n let elemsReady = [];\n let target = this.shadowRoot || this;\n for (let elem of [\n ...target.querySelectorAll('map-extent'),\n ...target.querySelectorAll('map-feature')\n ]) {\n elemsReady.push(elem.whenReady());\n }\n return Promise.allSettled(elemsReady);\n }\n}\n"],"names":["MapLayer","HTMLElement","observedAttributes","src","this","hasAttribute","getAttribute","val","setAttribute","label","_layer","getName","checked","removeAttribute","hidden","opacity","_opacity","extent","bounds","_calculateBounds","Object","assign","M","_convertAndFormatPCRS","_properties","crs","projection","zoom","zoomBounds","constructor","super","disconnectedCallback","_onRemove","off","_map","removeLayer","_layerControl","_fetchError","shadowRoot","innerHTML","connectedCallback","_createLayerControlHTML","bind","doConnected","_onAdd","parentElement","whenReady","then","catch","Error","attachShadow","mode","Promise","resolve","reject","addEventListener","e","stopPropagation","detail","once","let","base","baseURI","document","headers","Headers","append","fetch","response","ok","status","text","content","DOMParser","parseFromString","mapml","querySelector","mapMLLayer","URL","href","mapprojection","_attachedToMap","_validateDisabled","console","log","error","type","dispatchEvent","CustomEvent","target","i","position","nodes","parentNode","children","length","nodeName","setZIndex","proj","L","setOptions","zIndex","window","getComputedStyle","addTo","on","addOrUpdateOverlay","_legendUrl","legendLinks","rel","lang","hreflang","sizes","attributeChangedCallback","name","oldValue","newValue","setName","addLayer","_layerControlCheckbox","controls","changeOpacity","isConnected","setTimeout","layer","mapExtents","querySelectorAll","disabledExtentCount","totalExtentCount","layerTypes","validProjection","j","isVisible","disabled","toggleLayerControlDisabled","input","_layerControlLabel","opacityControl","_opacityControl","opacitySlider","_opacitySlider","styleControl","_styles","style","fontStyle","forEach","getOuterHTML","tempElement","cloneNode","newSrc","getHref","mapLinks","mapLink","decodeURI","attributes","value","tref","outerLayer","outerHTML","remove","zoomTo","whenElemsReady","map","tL","topLeft","pcrs","bR","bottomRight","layerBounds","point","horizontal","vertical","center","options","unproject","getCenter","maxZoom","minZoom","setView","getMaxZoom","animate","mapml2geojson","pasteFeature","feature","trim","slice","insertAdjacentHTML","toUpperCase","appendChild","interval","failureTimer","childNodes","setInterval","layerElement","clearInterval","clearTimeout","elemsReady","elem","push","allSettled"],"mappings":";;8CAGaA,iBAAiBC,YAC5BC,gCACE,MAAO,CAAC,MAAO,QAAS,UAAW,SAAU,WAE/CC,UACE,OAAOC,KAAKC,aAAa,OAASD,KAAKE,aAAa,OAAS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,IAAIiI,EAAUC,GACV1L,KAAKM,QAAYN,KAAKD,MAAOC,KAAKkC,YAAYyJ,WAAWhG,QAI3D8F,EAAWG,YAGb,SAAsBC,IAElBA,EAAavL,QACXuL,EAAa9L,MAAO8L,EAAa3J,YAAYyJ,WAAWhG,OAKjDkG,EAAa5J,cACtB6J,cAAcL,GACdM,aAAaL,GACbxI,EAAO,kCANP4I,cAAcL,GACdM,aAAaL,GACbzI,MAVmC,IADlBjD,MAEnB0L,EAAenE,WAgBjB,WACEuE,cAAcL,GACdM,aAAaL,GACbxI,EAAO,kDAnBoC,MAJ3CD,MA4BN4G,iBACErG,IAAIwI,EAAa,GACb3G,EAASrF,KAAKkC,YAAclC,KAChC,IAAKwD,IAAIyI,IAAQ,IACZ5G,EAAOqC,iBAAiB,iBACxBrC,EAAOqC,iBAAiB,gBAE3BsE,EAAWE,KAAKD,EAAKvJ,aAEvB,OAAOM,QAAQmJ,WAAWH,WAthBjBpM"} \ No newline at end of file +{"version":3,"file":"layer.js","sources":["../src/layer.js"],"sourcesContent":["import './leaflet.js'; // a lightly modified version of Leaflet for use as browser module\nimport './mapml.js'; // modified URI to make the function a property of window scope (possibly a bad thing to do).\n\nexport class MapLayer extends HTMLElement {\n static get observedAttributes() {\n return ['src', 'label', 'checked', 'hidden', 'opacity'];\n }\n get src() {\n return this.hasAttribute('src') ? this.getAttribute('src') : '';\n }\n\n set src(val) {\n if (val) {\n this.setAttribute('src', val);\n }\n }\n get label() {\n if (this._layer) return this._layer.getName();\n else return this.hasAttribute('label') ? this.getAttribute('label') : '';\n }\n set label(val) {\n if (val) {\n this.setAttribute('label', val);\n }\n }\n get checked() {\n return this.hasAttribute('checked');\n }\n\n set checked(val) {\n if (val) {\n this.setAttribute('checked', '');\n } else {\n this.removeAttribute('checked');\n }\n }\n\n get hidden() {\n return this.hasAttribute('hidden');\n }\n\n set hidden(val) {\n if (val) {\n this.setAttribute('hidden', '');\n } else {\n this.removeAttribute('hidden');\n }\n }\n\n get opacity() {\n // use ?? since 0 is falsy, || would return rhs in that case\n return +(this._opacity ?? this.getAttribute('opacity'));\n }\n\n set opacity(val) {\n if (+val > 1 || +val < 0) return;\n this.setAttribute('opacity', val);\n }\n\n get extent() {\n // calculate the bounds of all content, return it.\n if (!this._layer.bounds) {\n this._layer._calculateBounds();\n }\n return Object.assign(\n M._convertAndFormatPCRS(\n this._layer.bounds,\n this._layer._properties.crs,\n this._layer._properties.projection\n ),\n { zoom: this._layer.zoomBounds }\n );\n }\n\n constructor() {\n // Always call super first in constructor\n super();\n }\n disconnectedCallback() {\n // if the map-layer node is removed from the dom, the layer should be\n // removed from the map and the layer control\n if (this.hasAttribute('data-moving')) return;\n this._onRemove();\n }\n\n _onRemove() {\n if (this._layer) {\n this._layer.off();\n }\n // if this layer has never been connected, it will not have a _layer\n if (this._layer && this._layer._map) {\n this._layer._map.removeLayer(this._layer);\n }\n\n if (this._layerControl && !this.hidden) {\n this._layerControl.removeLayer(this._layer);\n }\n delete this._layer;\n delete this._fetchError;\n\n if (this.shadowRoot) {\n this.shadowRoot.innerHTML = '';\n }\n }\n\n connectedCallback() {\n if (this.hasAttribute('data-moving')) return;\n this._createLayerControlHTML = M._createLayerControlHTML.bind(this);\n // this._opacity is used to record the current opacity value (with or without updates),\n // the initial value of this._opacity should be set as opacity attribute value, if exists, or the default value 1.0\n this._opacity = this.opacity || 1.0;\n const doConnected = this._onAdd.bind(this);\n this.parentElement\n .whenReady()\n .then(() => {\n doConnected();\n })\n .catch(() => {\n throw new Error('Map never became ready');\n });\n }\n\n _onAdd() {\n if (this.getAttribute('src') && !this.shadowRoot) {\n this.attachShadow({ mode: 'open' });\n }\n new Promise((resolve, reject) => {\n this.addEventListener(\n 'changestyle',\n function (e) {\n e.stopPropagation();\n this.src = e.detail.src;\n },\n { once: true }\n );\n this.addEventListener(\n 'changeprojection',\n function (e) {\n e.stopPropagation();\n reject(e);\n },\n { once: true }\n );\n let base = this.baseURI ? this.baseURI : document.baseURI;\n\n const headers = new Headers();\n headers.append('Accept', 'text/mapml');\n if (this.src) {\n fetch(this.src, { headers: headers })\n .then((response) => {\n if (!response.ok) {\n throw new Error(`HTTP error! Status: ${response.status}`);\n }\n return response.text();\n })\n .then((mapml) => {\n let content = new DOMParser().parseFromString(mapml, 'text/xml');\n if (\n content.querySelector('parsererror') ||\n !content.querySelector('mapml-')\n ) {\n throw new Error('Parser error');\n }\n if (this._layer) {\n this._onRemove();\n }\n this._layer = M.mapMLLayer(\n new URL(this.src, base).href,\n this,\n content,\n {\n mapprojection: this.parentElement.projection,\n opacity: this.opacity\n }\n );\n this._createLayerControlHTML();\n this._attachedToMap();\n this._validateDisabled();\n resolve();\n })\n .catch((error) => {\n this._fetchError = true;\n console.log('Error fetching layer content' + error);\n });\n } else {\n if (this._layer) {\n this._onRemove();\n }\n this._layer = M.mapMLLayer(null, this, null, {\n mapprojection: this.parentElement.projection,\n opacity: this.opacity\n });\n this._createLayerControlHTML();\n this._attachedToMap();\n this._validateDisabled();\n resolve();\n }\n }).catch((e) => {\n if (e.type === 'changeprojection') {\n this.src = e.detail.href;\n } else {\n console.log(e);\n this.dispatchEvent(\n new CustomEvent('error', { detail: { target: this } })\n );\n }\n });\n }\n _attachedToMap() {\n // set i to the position of this layer element in the set of layers\n var i = 0,\n position = 1;\n for (var nodes = this.parentNode.children; i < nodes.length; i++) {\n if (this.parentNode.children[i].nodeName === 'LAYER-') {\n if (this.parentNode.children[i] === this) {\n position = i + 1;\n } else if (this.parentNode.children[i]._layer) {\n this.parentNode.children[i]._layer.setZIndex(i + 1);\n }\n }\n }\n var proj = this.parentNode.projection\n ? this.parentNode.projection\n : 'OSMTILE';\n L.setOptions(this._layer, {\n zIndex: position,\n mapprojection: proj,\n opacity: window.getComputedStyle(this).opacity\n });\n // make sure the Leaflet layer has a reference to the map\n this._layer._map = this.parentNode._map;\n\n if (this.checked) {\n this._layer.addTo(this._layer._map);\n }\n\n this._layer.on('add remove', this._validateDisabled, this);\n // toggle the this.disabled attribute depending on whether the layer\n // is: same prj as map, within view/zoom of map\n this._layer._map.on('moveend layeradd', this._validateDisabled, this);\n\n // if controls option is enabled, insert the layer into the overlays array\n if (this.parentNode._layerControl && !this.hidden) {\n this._layerControl = this.parentNode._layerControl;\n this._layerControl.addOrUpdateOverlay(this._layer, this.label);\n }\n\n // the mapml document associated to this layer can in theory contain many\n // link[@rel=legend] elements with different @type or other attributes;\n // currently only support a single link, don't care about type, lang etc.\n // TODO: add support for full LayerLegend object, and > one link.\n if (this._layer._legendUrl) {\n this.legendLinks = [\n {\n type: 'application/octet-stream',\n href: this._layer._legendUrl,\n rel: 'legend',\n lang: null,\n hreflang: null,\n sizes: null\n }\n ];\n }\n // re-use 'loadedmetadata' event from HTMLMediaElement inteface, applied\n // to MapML extent as metadata\n // https://developer.mozilla.org/en-US/docs/Web/API/HTMLMediaElement/loadedmetadata_event\n this.dispatchEvent(\n new CustomEvent('loadedmetadata', { detail: { target: this } })\n );\n }\n\n attributeChangedCallback(name, oldValue, newValue) {\n switch (name) {\n case 'label':\n this.whenReady()\n .then(() => {\n this._layer.setName(newValue);\n })\n .catch((e) => {\n console.log(e);\n });\n break;\n case 'checked':\n this.whenReady()\n .then(() => {\n if (typeof newValue === 'string') {\n this.parentElement._map.addLayer(this._layer);\n } else {\n this.parentElement._map.removeLayer(this._layer);\n }\n this._layerControlCheckbox.checked = this.checked;\n this.dispatchEvent(new CustomEvent('map-change'));\n })\n .catch((e) => {\n console.log(e);\n });\n break;\n case 'hidden':\n var map = this.parentElement && this.parentElement._map;\n if (map && this.parentElement.controls) {\n if (typeof newValue === 'string') {\n if (this._layer) {\n this.parentElement._layerControl.removeLayer(this._layer);\n }\n } else {\n this._layerControl = this.parentElement._layerControl;\n this._layerControl.addOrUpdateOverlay(this._layer, this.label);\n this._validateDisabled();\n }\n }\n break;\n case 'opacity':\n if (oldValue !== newValue && this._layer) {\n this._opacity = newValue;\n this._layer.changeOpacity(newValue);\n }\n break;\n case 'src':\n if (oldValue !== newValue && this._layer) {\n this._onRemove();\n if (this.isConnected) {\n this._onAdd();\n }\n // the original inline content will not be removed\n // but has NO EFFECT and works as a fallback\n }\n }\n }\n _validateDisabled() {\n // setTimeout is necessary to make the validateDisabled happen later than the moveend operations etc.,\n // to ensure that the validated result is correct\n setTimeout(() => {\n let layer = this._layer,\n map = layer?._map;\n if (map) {\n // prerequisite: no inline and remote mapml elements exists at the same time\n const mapExtents = this.shadowRoot\n ? this.shadowRoot.querySelectorAll('map-extent')\n : this.querySelectorAll('map-extent');\n let disabledExtentCount = 0,\n totalExtentCount = 0,\n layerTypes = [\n '_staticTileLayer',\n '_imageLayer',\n '_mapmlvectors',\n '_templatedLayer'\n ];\n for (let j = 0; j < layerTypes.length; j++) {\n let type = layerTypes[j];\n if (this.checked) {\n if (type === '_templatedLayer' && mapExtents.length > 0) {\n for (let i = 0; i < mapExtents.length; i++) {\n totalExtentCount++;\n if (mapExtents[i]._validateDisabled()) disabledExtentCount++;\n }\n } else if (layer[type]) {\n // not a templated layer\n totalExtentCount++;\n if (!layer[type].isVisible) disabledExtentCount++;\n }\n }\n }\n // if all extents are not visible / disabled, set layer to disabled\n if (\n disabledExtentCount === totalExtentCount &&\n disabledExtentCount !== 0\n ) {\n this.setAttribute('disabled', '');\n this.disabled = true;\n } else {\n this.removeAttribute('disabled');\n this.disabled = false;\n }\n this.toggleLayerControlDisabled();\n }\n }, 0);\n }\n\n // disable/italicize layer control elements based on the layer-.disabled property\n toggleLayerControlDisabled() {\n let input = this._layerControlCheckbox,\n label = this._layerControlLabel,\n opacityControl = this._opacityControl,\n opacitySlider = this._opacitySlider,\n styleControl = this._styles;\n if (this.disabled) {\n input.disabled = true;\n opacitySlider.disabled = true;\n label.style.fontStyle = 'italic';\n opacityControl.style.fontStyle = 'italic';\n if (styleControl) {\n styleControl.style.fontStyle = 'italic';\n styleControl.querySelectorAll('input').forEach((i) => {\n i.disabled = true;\n });\n }\n } else {\n input.disabled = false;\n opacitySlider.disabled = false;\n label.style.fontStyle = 'normal';\n opacityControl.style.fontStyle = 'normal';\n if (styleControl) {\n styleControl.style.fontStyle = 'normal';\n styleControl.querySelectorAll('input').forEach((i) => {\n i.disabled = false;\n });\n }\n }\n }\n\n getOuterHTML() {\n let tempElement = this.cloneNode(true);\n\n if (this.hasAttribute('src')) {\n let newSrc = this._layer.getHref();\n tempElement.setAttribute('src', newSrc);\n }\n if (this.querySelector('map-link')) {\n let mapLinks = tempElement.querySelectorAll('map-link');\n\n mapLinks.forEach((mapLink) => {\n if (mapLink.hasAttribute('href')) {\n mapLink.setAttribute(\n 'href',\n decodeURI(\n new URL(\n mapLink.attributes.href.value,\n this.baseURI ? this.baseURI : document.baseURI\n ).href\n )\n );\n } else if (mapLink.hasAttribute('tref')) {\n mapLink.setAttribute(\n 'tref',\n decodeURI(\n new URL(\n mapLink.attributes.tref.value,\n this.baseURI ? this.baseURI : document.baseURI\n ).href\n )\n );\n }\n });\n }\n\n let outerLayer = tempElement.outerHTML;\n\n tempElement.remove();\n\n return outerLayer;\n }\n\n zoomTo() {\n this.whenElemsReady().then(() => {\n let map = this.parentElement._map,\n extent = this.extent,\n tL = extent.topLeft.pcrs,\n bR = extent.bottomRight.pcrs,\n layerBounds = L.bounds(\n L.point(tL.horizontal, tL.vertical),\n L.point(bR.horizontal, bR.vertical)\n ),\n center = map.options.crs.unproject(layerBounds.getCenter(true));\n\n let maxZoom = extent.zoom.maxZoom,\n minZoom = extent.zoom.minZoom;\n map.setView(center, M.getMaxZoom(layerBounds, map, minZoom, maxZoom), {\n animate: false\n });\n });\n }\n mapml2geojson(options = {}) {\n return M.mapml2geojson(this, options);\n }\n pasteFeature(feature) {\n switch (typeof feature) {\n case 'string':\n feature.trim();\n if (\n feature.slice(0, 12) === ''\n ) {\n this.insertAdjacentHTML('beforeend', feature);\n }\n break;\n case 'object':\n if (feature.nodeName.toUpperCase() === 'MAP-FEATURE') {\n this.appendChild(feature);\n }\n }\n }\n whenReady() {\n return new Promise((resolve, reject) => {\n let interval, failureTimer;\n if (this._layer && (!this.src || this.shadowRoot?.childNodes.length)) {\n resolve();\n } else {\n let layerElement = this;\n interval = setInterval(testForLayer, 200, layerElement);\n failureTimer = setTimeout(layerNotDefined, 5000);\n }\n function testForLayer(layerElement) {\n if (\n layerElement._layer &&\n (!layerElement.src || layerElement.shadowRoot?.childNodes.length)\n ) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n resolve();\n } else if (layerElement._fetchError) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Error fetching layer content');\n }\n }\n function layerNotDefined() {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Timeout reached waiting for layer to be ready');\n }\n });\n }\n // check if all child elements are ready\n whenElemsReady() {\n let elemsReady = [];\n let target = this.shadowRoot || this;\n for (let elem of [\n ...target.querySelectorAll('map-extent'),\n ...target.querySelectorAll('map-feature')\n ]) {\n elemsReady.push(elem.whenReady());\n }\n return Promise.allSettled(elemsReady);\n }\n}\n"],"names":["MapLayer","HTMLElement","observedAttributes","src","this","hasAttribute","getAttribute","val","setAttribute","label","_layer","getName","checked","removeAttribute","hidden","opacity","_opacity","extent","bounds","_calculateBounds","Object","assign","M","_convertAndFormatPCRS","_properties","crs","projection","zoom","zoomBounds","constructor","super","disconnectedCallback","_onRemove","off","_map","removeLayer","_layerControl","_fetchError","shadowRoot","innerHTML","connectedCallback","_createLayerControlHTML","bind","doConnected","_onAdd","parentElement","whenReady","then","catch","Error","attachShadow","mode","Promise","resolve","reject","addEventListener","e","stopPropagation","detail","once","let","base","baseURI","document","headers","Headers","append","fetch","response","ok","status","text","content","DOMParser","parseFromString","mapml","querySelector","mapMLLayer","URL","href","mapprojection","_attachedToMap","_validateDisabled","console","log","error","type","dispatchEvent","CustomEvent","target","i","position","nodes","parentNode","children","length","nodeName","setZIndex","proj","L","setOptions","zIndex","window","getComputedStyle","addTo","on","addOrUpdateOverlay","_legendUrl","legendLinks","rel","lang","hreflang","sizes","attributeChangedCallback","name","oldValue","newValue","setName","addLayer","_layerControlCheckbox","controls","changeOpacity","isConnected","setTimeout","layer","mapExtents","querySelectorAll","disabledExtentCount","totalExtentCount","layerTypes","j","isVisible","disabled","toggleLayerControlDisabled","input","_layerControlLabel","opacityControl","_opacityControl","opacitySlider","_opacitySlider","styleControl","_styles","style","fontStyle","forEach","getOuterHTML","tempElement","cloneNode","newSrc","getHref","mapLinks","mapLink","decodeURI","attributes","value","tref","outerLayer","outerHTML","remove","zoomTo","whenElemsReady","map","tL","topLeft","pcrs","bR","bottomRight","layerBounds","point","horizontal","vertical","center","options","unproject","getCenter","maxZoom","minZoom","setView","getMaxZoom","animate","mapml2geojson","pasteFeature","feature","trim","slice","insertAdjacentHTML","toUpperCase","appendChild","interval","failureTimer","childNodes","setInterval","layerElement","clearInterval","clearTimeout","elemsReady","elem","push","allSettled"],"mappings":";;8CAGaA,iBAAiBC,YAC5BC,gCACE,MAAO,CAAC,MAAO,QAAS,UAAW,SAAU,WAE/CC,UACE,OAAOC,KAAKC,aAAa,OAASD,KAAKE,aAAa,OAAS,GAG/DH,QAAQI,GACFA,GACFH,KAAKI,aAAa,MAAOD,GAG7BE,YACE,OAAIL,KAAKM,OAAeN,KAAKM,OAAOC,UACxBP,KAAKC,aAAa,SAAWD,KAAKE,aAAa,SAAW,GAExEG,UAAUF,GACJA,GACFH,KAAKI,aAAa,QAASD,GAG/BK,cACE,OAAOR,KAAKC,aAAa,WAG3BO,YAAYL,GACNA,EACFH,KAAKI,aAAa,UAAW,IAE7BJ,KAAKS,gBAAgB,WAIzBC,aACE,OAAOV,KAAKC,aAAa,UAG3BS,WAAWP,GACLA,EACFH,KAAKI,aAAa,SAAU,IAE5BJ,KAAKS,gBAAgB,UAIzBE,cAEE,QAASX,KAAKY,UAAYZ,KAAKE,aAAa,YAG9CS,YAAYR,GACC,GAANA,IAAYA,EAAM,GACvBH,KAAKI,aAAa,UAAWD,GAG/BU,aAKE,OAHKb,KAAKM,OAAOQ,QACfd,KAAKM,OAAOS,mBAEPC,OAAOC,OACZC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a/dist/leaflet.js +++ b/dist/leaflet.js @@ -1,4 +1,4 @@ -/*! @maps4html/web-map-custom-element 09-11-2023 */ +/*! @maps4html/web-map-custom-element 15-11-2023 */ !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/dist/map-area.js b/dist/map-area.js index 72b1123c..dec21998 100644 --- a/dist/map-area.js +++ b/dist/map-area.js @@ -1,4 +1,4 @@ -/*! @maps4html/web-map-custom-element 09-11-2023 */ +/*! @maps4html/web-map-custom-element 15-11-2023 */ 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/dist/map-extent.js b/dist/map-extent.js index 8b420c9a..1b8c306a 100644 --- a/dist/map-extent.js +++ b/dist/map-extent.js @@ -1,5 +1,5 @@ -/*! @maps4html/web-map-custom-element 09-11-2023 */ +/*! @maps4html/web-map-custom-element 15-11-2023 */ class MapExtent extends HTMLElement{static get observedAttributes(){return["checked","label","opacity","hidden"]}get units(){return this.getAttribute("units")}get checked(){return this.hasAttribute("checked")}set checked(t){t?this.setAttribute("checked",""):this.removeAttribute("checked")}get label(){return this.hasAttribute("label")?this.getAttribute("label"):M.options.locale.dfExtent}set label(t){t&&this.setAttribute("label",t)}get opacity(){return+(this._opacity??this.getAttribute("opacity"))}set opacity(t){1<+t||+t<0||this.setAttribute("opacity",t)}get hidden(){return this.hasAttribute("hidden")}set hidden(t){t?this.setAttribute("hidden",""):this.removeAttribute("hidden")}attributeChangedCallback(a,t,r){this.whenReady().then(()=>{switch(a){case"units":break;case"label":t!==r&&(this._layerControlHTML.querySelector(".mapml-layer-item-name").innerHTML=r||M.options.locale.dfExtent);break;case"checked":this._handleChange(),this._calculateBounds(),this._layerControlCheckbox.checked=null!==r;break;case"opacity":t!==r&&(this._opacity=r,this._templatedLayer&&this._templatedLayer.changeOpacity(r));break;case"hidden":if(t!==r){let t=this.parentLayer._propertiesGroupAnatomy;var e=Array.from(this.parentNode.querySelectorAll("map-extent:not([hidden])")).indexOf(this);null!==r?this._layerControlHTML.remove():0===e?t.insertAdjacentElement("afterbegin",this._layerControlHTML):0{console.log(t,` -in mapExtent.attributeChangeCallback when changing attribute `+a)})}constructor(){super()}async connectedCallback(){this._createLayerControlExtentHTML=M._createLayerControlExtentHTML.bind(this),this.parentLayer="LAYER-"===this.parentNode.nodeName.toUpperCase()?this.parentNode:this.parentNode.host,this.hasAttribute("data-moving")||this.parentLayer.hasAttribute("data-moving")||(this.querySelector("map-link[rel=query], map-link[rel=features]")&&!this.shadowRoot&&this.attachShadow({mode:"open"}),await this.parentLayer.whenReady(),this.isConnected&&(this._layer=this.parentLayer._layer,this._map=this._layer._map,delete this.parentLayer.bounds,this._templateVars=this._initTemplateVars(this.parentLayer.shadowRoot?this.parentLayer.shadowRoot.querySelector("map-extent > map-meta[name=extent]")||this.parentLayer.shadowRoot.querySelector("map-meta[name=extent]"):this.parentLayer.querySelector("map-extent > map-meta[name=extent]")||this.parentLayer.querySelector("map-meta[name=extent]"),this.units,this._layer._content,this._layer.getBase(),this.units===this._layer.options.mapprojection),this._changeHandler=this._handleChange.bind(this),this.parentLayer.addEventListener("map-change",this._changeHandler),this._opacity=+(this.getAttribute("opacity")||1),this._templatedLayer=M.templatedLayer(this._templateVars,{pane:this._layer._container,opacity:this.opacity,_leafletLayer:this._layer,crs:this._layer._properties.crs,extentZIndex:Array.from(this.parentLayer.querySelectorAll("map-extent")).indexOf(this),extentEl:this._DOMnode||this}),this._layerControlHTML=this._createLayerControlExtentHTML(),this.hidden||this._layer.addExtentToLayerControl(this._layerControlHTML),this._validateLayerControlContainerHidden(),this._templatedLayer._queries&&(this._layer._properties._queries||(this._layer._properties._queries=[]),this._layer._properties._queries=this._layer._properties._queries.concat(this._templatedLayer._queries)),this._calculateBounds()))}getLayerControlHTML(){return this._layerControlHTML}_projectionMatch(){return this.units.toUpperCase()===this._layer.options.mapprojection.toUpperCase()}_validateDisabled(){if(this._templatedLayer){var t=()=>{let t=this._templatedLayer._templates.length,e=0;for(let t=0;t{t.querySelectorAll("select").forEach(t=>{t.disabled=!0,t.style.fontStyle="italic"}),t.style.fontStyle="italic"})):(t.disabled=!1,r.disabled=!1,e.style.fontStyle="normal",a.style.fontStyle="normal",i&&i.forEach(t=>{t.querySelectorAll("select").forEach(t=>{t.disabled=!1,t.style.fontStyle="normal"}),t.style.fontStyle="normal"}))}_initTemplateVars(r,i,t,e,a){var s=[],o=this.querySelectorAll("map-link[rel=tile],map-link[rel=image],map-link[rel=features],map-link[rel=query]"),n=new RegExp("(?:{)(.*?)(?:})","g"),l=this.querySelector('map-input[type="zoom" i]'),h=!1,m={zoom:0};if(r){let t=M._metaContentToObject(r.getAttribute("content")),e;m.zoom=t.zoom||m.zoom;let a=Object.keys(t);for(let t=0;t{let r,i;this._templatedLayer?e():(r=setInterval(function(t){t._templatedLayer?(clearInterval(r),clearTimeout(i),e()):t.isConnected||(clearInterval(r),clearTimeout(i),a("map-extent was disconnected while waiting to be ready"))},300,this),i=setTimeout(function(){clearInterval(r),clearTimeout(i),a("Timeout reached waiting for extent to be ready")},1e4))})}}export{MapExtent}; +in mapExtent.attributeChangeCallback when changing attribute `+a)})}constructor(){super()}async connectedCallback(){this._createLayerControlExtentHTML=M._createLayerControlExtentHTML.bind(this),this.parentLayer="LAYER-"===this.parentNode.nodeName.toUpperCase()?this.parentNode:this.parentNode.host,this.hasAttribute("data-moving")||this.parentLayer.hasAttribute("data-moving")||(this.querySelector("map-link[rel=query], map-link[rel=features]")&&!this.shadowRoot&&this.attachShadow({mode:"open"}),await this.parentLayer.whenReady(),this.mapEl=this.parentLayer.closest("mapml-viewer,map[is=web-map]"),await this.mapEl.whenProjectionDefined(this.units).catch(()=>{throw new Error("Undefined projection:"+this.units)}),this.isConnected&&(this._layer=this.parentLayer._layer,this._map=this._layer._map,delete this.parentLayer.bounds,this._templateVars=this._initTemplateVars(this.parentLayer.shadowRoot?this.parentLayer.shadowRoot.querySelector("map-extent > map-meta[name=extent]")||this.parentLayer.shadowRoot.querySelector("map-meta[name=extent]"):this.parentLayer.querySelector("map-extent > map-meta[name=extent]")||this.parentLayer.querySelector("map-meta[name=extent]"),this.units,this._layer._content,this._layer.getBase(),this.units===this._layer.options.mapprojection),this._changeHandler=this._handleChange.bind(this),this.parentLayer.addEventListener("map-change",this._changeHandler),this.mapEl.addEventListener("map-projectionchange",this._changeHandler),this._opacity=this.opacity||1,this._templatedLayer=M.templatedLayer(this._templateVars,{pane:this._layer._container,opacity:this.opacity,_leafletLayer:this._layer,crs:this._layer._properties.crs,extentZIndex:Array.from(this.parentLayer.querySelectorAll("map-extent")).indexOf(this),extentEl:this._DOMnode||this}),this._layerControlHTML=this._createLayerControlExtentHTML(),this.hidden||this._layer.addExtentToLayerControl(this._layerControlHTML),this._validateLayerControlContainerHidden(),this._templatedLayer._queries&&(this._layer._properties._queries||(this._layer._properties._queries=[]),this._layer._properties._queries=this._layer._properties._queries.concat(this._templatedLayer._queries)),this._calculateBounds()))}getLayerControlHTML(){return this._layerControlHTML}_projectionMatch(){return this.units.toUpperCase()===this._layer.options.mapprojection.toUpperCase()}_validateDisabled(){if(this._templatedLayer){var t=()=>{let t=this._templatedLayer._templates.length,e=0;for(let t=0;t{t.querySelectorAll("select").forEach(t=>{t.disabled=!0,t.style.fontStyle="italic"}),t.style.fontStyle="italic"})):(t.disabled=!1,r.disabled=!1,e.style.fontStyle="normal",a.style.fontStyle="normal",i&&i.forEach(t=>{t.querySelectorAll("select").forEach(t=>{t.disabled=!1,t.style.fontStyle="normal"}),t.style.fontStyle="normal"}))}_initTemplateVars(r,i,t,e,a){var s=[],n=this.querySelectorAll("map-link[rel=tile],map-link[rel=image],map-link[rel=features],map-link[rel=query]"),o=new RegExp("(?:{)(.*?)(?:})","g"),l=this.querySelector('map-input[type="zoom" i]'),h=!1,m={zoom:0};if(r){let t=M._metaContentToObject(r.getAttribute("content")),e;m.zoom=t.zoom||m.zoom;let a=Object.keys(t);for(let t=0;t{let r,i;this._templatedLayer?e():(r=setInterval(function(t){t._templatedLayer?(clearInterval(r),clearTimeout(i),e()):t.isConnected||(clearInterval(r),clearTimeout(i),a("map-extent was disconnected while waiting to be ready"))},300,this),i=setTimeout(function(){clearInterval(r),clearTimeout(i),a("Timeout reached waiting for extent to be ready")},1e4))})}}export{MapExtent}; //# sourceMappingURL=map-extent.js.map \ No newline at end of file diff --git a/dist/map-extent.js.map b/dist/map-extent.js.map index 150a7917..7f61ee6b 100644 --- a/dist/map-extent.js.map +++ b/dist/map-extent.js.map @@ -1 +1 @@ -{"version":3,"file":"map-extent.js","sources":["../src/map-extent.js"],"sourcesContent":["/* global M */\nexport class MapExtent extends HTMLElement {\n static get observedAttributes() {\n return ['checked', 'label', 'opacity', 'hidden'];\n }\n get units() {\n return this.getAttribute('units');\n }\n\n get checked() {\n return this.hasAttribute('checked');\n }\n\n set checked(val) {\n if (val) {\n this.setAttribute('checked', '');\n } else {\n this.removeAttribute('checked');\n }\n }\n get label() {\n return this.hasAttribute('label')\n ? this.getAttribute('label')\n : M.options.locale.dfExtent;\n }\n set label(val) {\n if (val) {\n this.setAttribute('label', val);\n }\n }\n get opacity() {\n // use ?? since 0 is falsy, || would return rhs in that case\n return +(this._opacity ?? this.getAttribute('opacity'));\n }\n\n set opacity(val) {\n if (+val > 1 || +val < 0) return;\n this.setAttribute('opacity', val);\n }\n get hidden() {\n return this.hasAttribute('hidden');\n }\n\n set hidden(val) {\n if (val) {\n this.setAttribute('hidden', '');\n } else {\n this.removeAttribute('hidden');\n }\n }\n attributeChangedCallback(name, oldValue, newValue) {\n this.whenReady()\n .then(() => {\n switch (name) {\n case 'units':\n if (oldValue !== newValue) {\n // handle side effects\n }\n break;\n case 'label':\n if (oldValue !== newValue) {\n this._layerControlHTML.querySelector(\n '.mapml-layer-item-name'\n ).innerHTML = newValue || M.options.locale.dfExtent;\n }\n break;\n case 'checked':\n this._handleChange();\n this._calculateBounds();\n this._layerControlCheckbox.checked = newValue !== null;\n break;\n case 'opacity':\n if (oldValue !== newValue) {\n this._opacity = newValue;\n if (this._templatedLayer)\n this._templatedLayer.changeOpacity(newValue);\n }\n break;\n case 'hidden':\n if (oldValue !== newValue) {\n let extentsRootFieldset =\n this.parentLayer._propertiesGroupAnatomy;\n let position = Array.from(\n this.parentNode.querySelectorAll('map-extent:not([hidden])')\n ).indexOf(this);\n if (newValue !== null) {\n // remove from layer control (hide from user)\n this._layerControlHTML.remove();\n } else {\n // insert the extent fieldset into the layer control container in\n // the calculated position\n if (position === 0) {\n extentsRootFieldset.insertAdjacentElement(\n 'afterbegin',\n this._layerControlHTML\n );\n } else if (position > 0) {\n this.parentNode\n .querySelectorAll('map-extent:not([hidden])')\n [position - 1]._layerControlHTML.insertAdjacentElement(\n 'afterend',\n this._layerControlHTML\n );\n }\n }\n this._validateLayerControlContainerHidden();\n }\n break;\n }\n })\n .catch((reason) => {\n console.log(\n reason,\n `\\nin mapExtent.attributeChangeCallback when changing attribute ${name}`\n );\n });\n }\n constructor() {\n // Always call super first in constructor\n super();\n }\n async connectedCallback() {\n // this.parentNode.host returns the layer- element when parentNode is\n // the shadow root\n this._createLayerControlExtentHTML =\n M._createLayerControlExtentHTML.bind(this);\n this.parentLayer =\n this.parentNode.nodeName.toUpperCase() === 'LAYER-'\n ? this.parentNode\n : this.parentNode.host;\n if (\n this.hasAttribute('data-moving') ||\n this.parentLayer.hasAttribute('data-moving')\n )\n return;\n if (\n this.querySelector('map-link[rel=query], map-link[rel=features]') &&\n !this.shadowRoot\n ) {\n this.attachShadow({ mode: 'open' });\n }\n await this.parentLayer.whenReady();\n // when projection is changed, the parent layer-._layer is created (so whenReady is fulfilled) but then removed,\n // then the map-extent disconnectedCallback will be triggered by layer-._onRemove() (clear the shadowRoot)\n // even before connectedCallback is finished\n // in this case, the microtasks triggered by the fulfillment of the removed MapMLLayer should be stopped as well\n // !this.isConnected <=> the disconnectedCallback has run before\n if (!this.isConnected) return;\n this._layer = this.parentLayer._layer;\n this._map = this._layer._map;\n // reset the layer extent\n delete this.parentLayer.bounds;\n this._templateVars = this._initTemplateVars(\n // read map-meta[name=extent] from shadowroot or layer-\n // querySelector / querySelectorAll on layer- cannot get elements inside its shadowroot\n this.parentLayer.shadowRoot\n ? this.parentLayer.shadowRoot.querySelector(\n 'map-extent > map-meta[name=extent]'\n ) ||\n this.parentLayer.shadowRoot.querySelector('map-meta[name=extent]')\n : this.parentLayer.querySelector(\n 'map-extent > map-meta[name=extent]'\n ) || this.parentLayer.querySelector('map-meta[name=extent]'),\n this.units,\n this._layer._content,\n this._layer.getBase(),\n this.units === this._layer.options.mapprojection\n );\n this._changeHandler = this._handleChange.bind(this);\n this.parentLayer.addEventListener('map-change', this._changeHandler);\n // this._opacity is used to record the current opacity value (with or without updates),\n // the initial value of this._opacity should be set as opacity attribute value, if exists, or the default value 1.0\n this._opacity = +(this.getAttribute('opacity') || 1.0);\n this._templatedLayer = M.templatedLayer(this._templateVars, {\n pane: this._layer._container,\n opacity: this.opacity,\n _leafletLayer: this._layer,\n crs: this._layer._properties.crs,\n extentZIndex: Array.from(\n this.parentLayer.querySelectorAll('map-extent')\n ).indexOf(this),\n // when a migrates from a remote mapml file and attaches to the shadow of \n // this._properties._mapExtents[i] refers to the in remote mapml\n extentEl: this._DOMnode || this\n });\n // this._layerControlHTML is the fieldset for the extent in the LayerControl\n this._layerControlHTML = this._createLayerControlExtentHTML();\n if (!this.hidden)\n this._layer.addExtentToLayerControl(this._layerControlHTML);\n this._validateLayerControlContainerHidden();\n if (this._templatedLayer._queries) {\n if (!this._layer._properties._queries)\n this._layer._properties._queries = [];\n this._layer._properties._queries =\n this._layer._properties._queries.concat(this._templatedLayer._queries);\n }\n this._calculateBounds();\n }\n getLayerControlHTML() {\n return this._layerControlHTML;\n }\n _projectionMatch() {\n return (\n this.units.toUpperCase() ===\n this._layer.options.mapprojection.toUpperCase()\n );\n }\n _validateDisabled() {\n if (!this._templatedLayer) return;\n const noTemplateVisible = () => {\n let totalTemplateCount = this._templatedLayer._templates.length,\n disabledTemplateCount = 0;\n for (let j = 0; j < this._templatedLayer._templates.length; j++) {\n if (this._templatedLayer._templates[j].rel === 'query') {\n continue;\n }\n if (!this._templatedLayer._templates[j].layer.isVisible) {\n disabledTemplateCount++;\n }\n }\n return disabledTemplateCount === totalTemplateCount;\n };\n if (!this._projectionMatch() || noTemplateVisible()) {\n this.setAttribute('disabled', '');\n this.disabled = true;\n } else {\n this.removeAttribute('disabled');\n this.disabled = false;\n }\n this.toggleLayerControlDisabled();\n return this.disabled;\n }\n\n // disable/italicize layer control elements based on the map-extent.disabled property\n toggleLayerControlDisabled() {\n let input = this._layerControlCheckbox,\n label = this._layerControlLabel, // access to the label for the specific map-extent\n opacityControl = this._opacityControl,\n opacitySlider = this._opacitySlider,\n selectDetails = this._selectdetails;\n if (this.disabled) {\n // update the status of layerControl\n input.disabled = true;\n opacitySlider.disabled = true;\n label.style.fontStyle = 'italic';\n opacityControl.style.fontStyle = 'italic';\n if (selectDetails) {\n selectDetails.forEach((i) => {\n i.querySelectorAll('select').forEach((j) => {\n j.disabled = true;\n j.style.fontStyle = 'italic';\n });\n i.style.fontStyle = 'italic';\n });\n }\n } else {\n input.disabled = false;\n opacitySlider.disabled = false;\n label.style.fontStyle = 'normal';\n opacityControl.style.fontStyle = 'normal';\n if (selectDetails) {\n selectDetails.forEach((i) => {\n i.querySelectorAll('select').forEach((j) => {\n j.disabled = false;\n j.style.fontStyle = 'normal';\n });\n i.style.fontStyle = 'normal';\n });\n }\n }\n }\n\n _initTemplateVars(metaExtent, projection, mapml, base, projectionMatch) {\n function transcribe(element) {\n var select = document.createElement('select');\n var elementAttrNames = element.getAttributeNames();\n\n for (let i = 0; i < elementAttrNames.length; i++) {\n select.setAttribute(\n elementAttrNames[i],\n element.getAttribute(elementAttrNames[i])\n );\n }\n\n var options = element.children;\n\n for (let i = 0; i < options.length; i++) {\n var option = document.createElement('option');\n var optionAttrNames = options[i].getAttributeNames();\n\n for (let j = 0; j < optionAttrNames.length; j++) {\n option.setAttribute(\n optionAttrNames[j],\n options[i].getAttribute(optionAttrNames[j])\n );\n }\n\n option.innerHTML = options[i].innerHTML;\n select.appendChild(option);\n }\n return select;\n }\n var templateVars = [];\n // set up the URL template and associated inputs (which yield variable values when processed)\n var tlist = this.querySelectorAll(\n 'map-link[rel=tile],map-link[rel=image],map-link[rel=features],map-link[rel=query]'\n ),\n varNamesRe = new RegExp('(?:{)(.*?)(?:})', 'g'),\n zoomInput = this.querySelector('map-input[type=\"zoom\" i]'),\n includesZoom = false,\n boundsFallback = {};\n\n boundsFallback.zoom = 0;\n if (metaExtent) {\n let content = M._metaContentToObject(metaExtent.getAttribute('content')),\n cs;\n\n boundsFallback.zoom = content.zoom || boundsFallback.zoom;\n\n let metaKeys = Object.keys(content);\n for (let i = 0; i < metaKeys.length; i++) {\n if (!metaKeys[i].includes('zoom')) {\n cs = M.axisToCS(metaKeys[i].split('-')[2]);\n break;\n }\n }\n let axes = M.csToAxes(cs);\n boundsFallback.bounds = M.boundsToPCRSBounds(\n L.bounds(\n L.point(\n +content[`top-left-${axes[0]}`],\n +content[`top-left-${axes[1]}`]\n ),\n L.point(\n +content[`bottom-right-${axes[0]}`],\n +content[`bottom-right-${axes[1]}`]\n )\n ),\n boundsFallback.zoom,\n projection,\n cs\n );\n } else {\n // for custom projections, M[projection] may not be loaded, so uses M['OSMTILE'] as backup, this code will need to get rerun once projection is changed and M[projection] is available\n // TODO: This is a temporary fix, _initTemplateVars (or processinitialextent) should not be called when projection of the layer and map do not match, this should be called/reinitialized once the layer projection matches with the map projection\n let fallbackProjection = M[projection] || M.OSMTILE;\n boundsFallback.bounds = fallbackProjection.options.crs.pcrs.bounds;\n }\n\n for (var i = 0; i < tlist.length; i++) {\n var t = tlist[i],\n template = t.getAttribute('tref');\n t.zoomInput = zoomInput;\n if (!template) {\n template = M.BLANK_TT_TREF;\n let blankInputs = mapml.querySelectorAll('map-input');\n for (let i of blankInputs) {\n template += `{${i.getAttribute('name')}}`;\n }\n }\n\n var v,\n title = t.hasAttribute('title')\n ? t.getAttribute('title')\n : 'Query this layer',\n vcount = template.match(varNamesRe),\n trel =\n !t.hasAttribute('rel') ||\n t.getAttribute('rel').toLowerCase() === 'tile'\n ? 'tile'\n : t.getAttribute('rel').toLowerCase(),\n ttype = !t.hasAttribute('type')\n ? 'image/*'\n : t.getAttribute('type').toLowerCase(),\n inputs = [],\n tms = t && t.hasAttribute('tms');\n var zoomBounds = mapml.querySelector('map-meta[name=zoom]')\n ? M._metaContentToObject(\n mapml.querySelector('map-meta[name=zoom]').getAttribute('content')\n )\n : undefined;\n while ((v = varNamesRe.exec(template)) !== null) {\n var varName = v[1],\n inp = this.querySelector(\n 'map-input[name=' + varName + '],map-select[name=' + varName + ']'\n );\n if (inp) {\n if (\n inp.hasAttribute('type') &&\n inp.getAttribute('type') === 'location' &&\n (!inp.hasAttribute('min') || !inp.hasAttribute('max')) &&\n inp.hasAttribute('axis') &&\n !['i', 'j'].includes(inp.getAttribute('axis').toLowerCase())\n ) {\n if (\n zoomInput &&\n template.includes(`{${zoomInput.getAttribute('name')}}`)\n ) {\n zoomInput.setAttribute('value', boundsFallback.zoom);\n }\n let axis = inp.getAttribute('axis'),\n axisBounds = M.convertPCRSBounds(\n boundsFallback.bounds,\n boundsFallback.zoom,\n projection,\n M.axisToCS(axis)\n );\n inp.setAttribute('min', axisBounds.min[M.axisToXY(axis)]);\n inp.setAttribute('max', axisBounds.max[M.axisToXY(axis)]);\n }\n\n inputs.push(inp);\n includesZoom =\n includesZoom ||\n (inp.hasAttribute('type') &&\n inp.getAttribute('type').toLowerCase() === 'zoom');\n if (inp.tagName.toLowerCase() === 'map-select') {\n // use a throwaway div to parse the input from MapML into HTML\n var div = document.createElement('div');\n div.insertAdjacentHTML('afterbegin', inp.outerHTML);\n // parse\n inp.htmlselect = div.querySelector('map-select');\n inp.htmlselect = transcribe(inp.htmlselect);\n\n // this goes into the layer control, so add a listener\n L.DomEvent.on(inp.htmlselect, 'change', this.redraw, this);\n\n if (!this._userInputs) {\n this._userInputs = [];\n }\n this._userInputs.push(inp.htmlselect);\n }\n // TODO: if this is an input@type=location\n // get the TCRS min,max attribute values at the identified zoom level\n // save this information as properties of the mapExtent,\n // perhaps as a bounds object so that it can be easily used\n // later by the layer control to determine when to enable\n // disable the layer for drawing.\n } else {\n console.log(\n 'input with name=' +\n varName +\n ' not found for template variable of same name'\n );\n // no match found, template won't be used\n break;\n }\n }\n if (\n (template && vcount.length === inputs.length) ||\n template === M.BLANK_TT_TREF\n ) {\n if (trel === 'query') {\n this._layer.queryable = true;\n }\n if (!includesZoom && zoomInput) {\n inputs.push(zoomInput);\n }\n let step = zoomInput ? zoomInput.getAttribute('step') : 1;\n if (!step || step === '0' || isNaN(step)) step = 1;\n // template has a matching input for every variable reference {varref}\n templateVars.push({\n template: decodeURI(new URL(template, base)),\n linkEl: t,\n title: title,\n rel: trel,\n type: ttype,\n values: inputs,\n zoomBounds: zoomBounds,\n boundsFallbackPCRS: { bounds: boundsFallback.bounds },\n projectionMatch: projectionMatch,\n projection: this.units || M.FALLBACK_PROJECTION,\n tms: tms,\n step: step\n });\n }\n }\n return templateVars;\n }\n redraw() {\n this._templatedLayer.redraw();\n }\n\n _handleChange() {\n // if the parent layer- is checked, add _templatedLayer to map if map-extent is checked, otherwise remove it\n if (this.checked && this.parentLayer.checked && !this.disabled) {\n this._templatedLayer.addTo(this._layer._map);\n this._templatedLayer.setZIndex(\n Array.from(this.parentLayer.querySelectorAll('map-extent')).indexOf(\n this\n )\n );\n } else {\n this._map.removeLayer(this._templatedLayer);\n }\n // change the checkbox in the layer control to match map-extent.checked\n // doesn't trigger the event handler because it's not user-caused AFAICT\n }\n _validateLayerControlContainerHidden() {\n let extentsFieldset = this.parentLayer._propertiesGroupAnatomy;\n let nodeToSearch = this.parentLayer.shadowRoot || this.parentLayer;\n if (\n nodeToSearch.querySelectorAll('map-extent:not([hidden])').length === 0\n ) {\n extentsFieldset.setAttribute('hidden', '');\n } else {\n extentsFieldset.removeAttribute('hidden');\n }\n }\n disconnectedCallback() {\n // in case of projection change, the disconnectedcallback will be triggered by removing layer-._layer even before\n // map-extent.connectedcallback is finished (because it will wait for the layer- to be ready)\n // !this._templatedLayer <=> this.connectedCallback has not yet been finished before disconnectedCallback is triggered\n if (\n this.hasAttribute('data-moving') ||\n this.parentLayer.hasAttribute('data-moving') ||\n !this._templatedLayer\n )\n return;\n this._validateLayerControlContainerHidden();\n // remove layer control for map-extent from layer control DOM\n this._layerControlHTML.remove();\n this._map.removeLayer(this._templatedLayer);\n this.parentLayer.removeEventListener('map-change', this._changeHandler);\n delete this._templatedLayer;\n delete this.parentLayer.bounds;\n }\n _calculateBounds() {\n let bounds = null,\n zoomMax = 0,\n zoomMin = 0,\n maxNativeZoom = 0,\n minNativeZoom = 0;\n // bounds should be able to be calculated unconditionally, not depend on map-extent.checked\n for (let j = 0; j < this._templateVars.length; j++) {\n let inputData = M._extractInputBounds(this._templateVars[j]);\n this._templateVars[j].tempExtentBounds = inputData.bounds;\n this._templateVars[j].extentZoomBounds = inputData.zoomBounds;\n if (!bounds) {\n bounds = this._templateVars[j].tempExtentBounds;\n zoomMax = this._templateVars[j].extentZoomBounds.maxZoom;\n zoomMin = this._templateVars[j].extentZoomBounds.minZoom;\n maxNativeZoom = this._templateVars[j].extentZoomBounds.maxNativeZoom;\n minNativeZoom = this._templateVars[j].extentZoomBounds.minNativeZoom;\n } else {\n bounds.extend(this._templateVars[j].tempExtentBounds.min);\n bounds.extend(this._templateVars[j].tempExtentBounds.max);\n zoomMax = Math.max(\n zoomMax,\n this._templateVars[j].extentZoomBounds.maxZoom\n );\n zoomMin = Math.min(\n zoomMin,\n this._templateVars[j].extentZoomBounds.minZoom\n );\n maxNativeZoom = Math.max(\n maxNativeZoom,\n this._templateVars[j].extentZoomBounds.maxNativeZoom\n );\n minNativeZoom = Math.min(\n minNativeZoom,\n this._templateVars[j].extentZoomBounds.minNativeZoom\n );\n }\n }\n // cannot be named as layerBounds if we decide to keep the debugoverlay logic\n this._templatedLayer.bounds = bounds;\n this._templatedLayer.zoomBounds = {\n minZoom: zoomMin,\n maxZoom: zoomMax,\n maxNativeZoom,\n minNativeZoom\n };\n }\n\n whenReady() {\n return new Promise((resolve, reject) => {\n let interval, failureTimer;\n if (this._templatedLayer) {\n resolve();\n } else {\n let extentElement = this;\n interval = setInterval(testForExtent, 300, extentElement);\n failureTimer = setTimeout(extentNotDefined, 10000);\n }\n function testForExtent(extentElement) {\n if (extentElement._templatedLayer) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n resolve();\n } else if (!extentElement.isConnected) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('map-extent was disconnected while waiting to be ready');\n }\n }\n function extentNotDefined() {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Timeout reached waiting for extent to be ready');\n }\n });\n }\n}\n"],"names":["MapExtent","HTMLElement","observedAttributes","units","this","getAttribute","checked","hasAttribute","val","setAttribute","removeAttribute","label","M","options","locale","dfExtent","opacity","_opacity","hidden","attributeChangedCallback","name","oldValue","newValue","whenReady","then","_layerControlHTML","querySelector","innerHTML","_handleChange","_calculateBounds","_layerControlCheckbox","_templatedLayer","changeOpacity","let","extentsRootFieldset","parentLayer","_propertiesGroupAnatomy","position","Array","from","parentNode","querySelectorAll","indexOf","remove","insertAdjacentElement","_validateLayerControlContainerHidden","catch","console","log","reason","constructor","super","connectedCallback","_createLayerControlExtentHTML","bind","nodeName","toUpperCase","host","shadowRoot","attachShadow","mode","isConnected","_layer","_map","bounds","_templateVars","_initTemplateVars","_content","getBase","mapprojection","_changeHandler","addEventListener","templatedLayer","pane","_container","_leafletLayer","crs","_properties","extentZIndex","extentEl","_DOMnode","addExtentToLayerControl","_queries","concat","getLayerControlHTML","_projectionMatch","_validateDisabled","noTemplateVisible","totalTemplateCount","_templates","length","disabledTemplateCount","j","rel","layer","isVisible","disabled","toggleLayerControlDisabled","input","_layerControlLabel","opacityControl","_opacityControl","opacitySlider","_opacitySlider","selectDetails","_selectdetails","style","fontStyle","forEach","i","metaExtent","projection","mapml","base","projectionMatch","templateVars","tlist","varNamesRe","RegExp","zoomInput","includesZoom","boundsFallback","zoom","content","_metaContentToObject","cs","metaKeys","Object","keys","includes","axisToCS","split","axes","csToAxes","boundsToPCRSBounds","L","point","fallbackProjection","OSMTILE","pcrs","t","template","BLANK_TT_TREF","title","vcount","match","trel","toLowerCase","ttype","inputs","tms","zoomBounds","undefined","v","exec","div","varName","inp","axis","axisBounds","convertPCRSBounds","min","axisToXY","max","push","tagName","document","createElement","insertAdjacentHTML","outerHTML","htmlselect","element","select","elementAttrNames","getAttributeNames","children","option","optionAttrNames","appendChild","transcribe","DomEvent","on","redraw","_userInputs","queryable","step","isNaN","decodeURI","URL","linkEl","type","values","boundsFallbackPCRS","FALLBACK_PROJECTION","addTo","setZIndex","removeLayer","extentsFieldset","nodeToSearch","disconnectedCallback","removeEventListener","zoomMax","zoomMin","maxNativeZoom","minNativeZoom","inputData","_extractInputBounds","tempExtentBounds","extentZoomBounds","extend","Math","maxZoom","minZoom","Promise","resolve","reject","interval","failureTimer","setInterval","extentElement","clearInterval","clearTimeout","setTimeout"],"mappings":";;MAC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C9B5D,KAAK2B,gBAAgBwH,WAAa,CAChC6D,QAASV,EACTS,QAASV,EACTE,cAAAA,EACAC,cAAAA,GAIJrL,YACE,OAAO,IAAI8L,QAAQ,CAACC,EAASC,KAC3BtL,IAAIuL,EAAUC,EACVrN,KAAK2B,gBACPuL,KAGAE,EAAWE,YAGb,SAAuBC,GACjBA,EAAc5L,iBAChB6L,cAAcJ,GACdK,aAAaJ,GACbH,KACUK,EAAc9J,cACxB+J,cAAcJ,GACdK,aAAaJ,GACbF,EAAO,2DAX6B,IADlBnN,MAEpBqN,EAAeK,WAajB,WACEF,cAAcJ,GACdK,aAAaJ,GACbF,EAAO,mDAhBqC,gBAtkBvCvN"} \ No newline at end of file +{"version":3,"file":"map-extent.js","sources":["../src/map-extent.js"],"sourcesContent":["/* global M */\nexport class MapExtent extends HTMLElement {\n static get observedAttributes() {\n return ['checked', 'label', 'opacity', 'hidden'];\n }\n get units() {\n return this.getAttribute('units');\n }\n\n get checked() {\n return this.hasAttribute('checked');\n }\n\n set checked(val) {\n if (val) {\n this.setAttribute('checked', '');\n } else {\n this.removeAttribute('checked');\n }\n }\n get label() {\n return this.hasAttribute('label')\n ? this.getAttribute('label')\n : M.options.locale.dfExtent;\n }\n set label(val) {\n if (val) {\n this.setAttribute('label', val);\n }\n }\n get opacity() {\n // use ?? since 0 is falsy, || would return rhs in that case\n return +(this._opacity ?? this.getAttribute('opacity'));\n }\n\n set opacity(val) {\n if (+val > 1 || +val < 0) return;\n this.setAttribute('opacity', val);\n }\n get hidden() {\n return this.hasAttribute('hidden');\n }\n\n set hidden(val) {\n if (val) {\n this.setAttribute('hidden', '');\n } else {\n this.removeAttribute('hidden');\n }\n }\n attributeChangedCallback(name, oldValue, newValue) {\n this.whenReady()\n .then(() => {\n switch (name) {\n case 'units':\n if (oldValue !== newValue) {\n // handle side effects\n }\n break;\n case 'label':\n if (oldValue !== newValue) {\n this._layerControlHTML.querySelector(\n '.mapml-layer-item-name'\n ).innerHTML = newValue || M.options.locale.dfExtent;\n }\n break;\n case 'checked':\n this._handleChange();\n this._calculateBounds();\n this._layerControlCheckbox.checked = newValue !== null;\n break;\n case 'opacity':\n if (oldValue !== newValue) {\n this._opacity = newValue;\n if (this._templatedLayer)\n this._templatedLayer.changeOpacity(newValue);\n }\n break;\n case 'hidden':\n if (oldValue !== newValue) {\n let extentsRootFieldset =\n this.parentLayer._propertiesGroupAnatomy;\n let position = Array.from(\n this.parentNode.querySelectorAll('map-extent:not([hidden])')\n ).indexOf(this);\n if (newValue !== null) {\n // remove from layer control (hide from user)\n this._layerControlHTML.remove();\n } else {\n // insert the extent fieldset into the layer control container in\n // the calculated position\n if (position === 0) {\n extentsRootFieldset.insertAdjacentElement(\n 'afterbegin',\n this._layerControlHTML\n );\n } else if (position > 0) {\n this.parentNode\n .querySelectorAll('map-extent:not([hidden])')\n [position - 1]._layerControlHTML.insertAdjacentElement(\n 'afterend',\n this._layerControlHTML\n );\n }\n }\n this._validateLayerControlContainerHidden();\n }\n break;\n }\n })\n .catch((reason) => {\n console.log(\n reason,\n `\\nin mapExtent.attributeChangeCallback when changing attribute ${name}`\n );\n });\n }\n constructor() {\n // Always call super first in constructor\n super();\n }\n async connectedCallback() {\n // this.parentNode.host returns the layer- element when parentNode is\n // the shadow root\n this._createLayerControlExtentHTML =\n M._createLayerControlExtentHTML.bind(this);\n this.parentLayer =\n this.parentNode.nodeName.toUpperCase() === 'LAYER-'\n ? this.parentNode\n : this.parentNode.host;\n if (\n this.hasAttribute('data-moving') ||\n this.parentLayer.hasAttribute('data-moving')\n )\n return;\n if (\n this.querySelector('map-link[rel=query], map-link[rel=features]') &&\n !this.shadowRoot\n ) {\n this.attachShadow({ mode: 'open' });\n }\n await this.parentLayer.whenReady();\n this.mapEl = this.parentLayer.closest('mapml-viewer,map[is=web-map]');\n await this.mapEl.whenProjectionDefined(this.units).catch(() => {\n throw new Error('Undefined projection:' + this.units);\n });\n // when projection is changed, the parent layer-._layer is created (so whenReady is fulfilled) but then removed,\n // then the map-extent disconnectedCallback will be triggered by layer-._onRemove() (clear the shadowRoot)\n // even before connectedCallback is finished\n // in this case, the microtasks triggered by the fulfillment of the removed MapMLLayer should be stopped as well\n // !this.isConnected <=> the disconnectedCallback has run before\n if (!this.isConnected) return;\n this._layer = this.parentLayer._layer;\n this._map = this._layer._map;\n // reset the layer extent\n delete this.parentLayer.bounds;\n this._templateVars = this._initTemplateVars(\n // read map-meta[name=extent] from shadowroot or layer-\n // querySelector / querySelectorAll on layer- cannot get elements inside its shadowroot\n this.parentLayer.shadowRoot\n ? this.parentLayer.shadowRoot.querySelector(\n 'map-extent > map-meta[name=extent]'\n ) ||\n this.parentLayer.shadowRoot.querySelector('map-meta[name=extent]')\n : this.parentLayer.querySelector(\n 'map-extent > map-meta[name=extent]'\n ) || this.parentLayer.querySelector('map-meta[name=extent]'),\n this.units,\n this._layer._content,\n this._layer.getBase(),\n this.units === this._layer.options.mapprojection\n );\n this._changeHandler = this._handleChange.bind(this);\n this.parentLayer.addEventListener('map-change', this._changeHandler);\n this.mapEl.addEventListener('map-projectionchange', this._changeHandler);\n // this._opacity is used to record the current opacity value (with or without updates),\n // the initial value of this._opacity should be set as opacity attribute value, if exists, or the default value 1.0\n this._opacity = this.opacity || 1.0;\n this._templatedLayer = M.templatedLayer(this._templateVars, {\n pane: this._layer._container,\n opacity: this.opacity,\n _leafletLayer: this._layer,\n crs: this._layer._properties.crs,\n extentZIndex: Array.from(\n this.parentLayer.querySelectorAll('map-extent')\n ).indexOf(this),\n // when a migrates from a remote mapml file and attaches to the shadow of \n // this._properties._mapExtents[i] refers to the in remote mapml\n extentEl: this._DOMnode || this\n });\n // this._layerControlHTML is the fieldset for the extent in the LayerControl\n this._layerControlHTML = this._createLayerControlExtentHTML();\n if (!this.hidden)\n this._layer.addExtentToLayerControl(this._layerControlHTML);\n this._validateLayerControlContainerHidden();\n if (this._templatedLayer._queries) {\n if (!this._layer._properties._queries)\n this._layer._properties._queries = [];\n this._layer._properties._queries =\n this._layer._properties._queries.concat(this._templatedLayer._queries);\n }\n this._calculateBounds();\n }\n getLayerControlHTML() {\n return this._layerControlHTML;\n }\n _projectionMatch() {\n return (\n this.units.toUpperCase() ===\n this._layer.options.mapprojection.toUpperCase()\n );\n }\n _validateDisabled() {\n if (!this._templatedLayer) return;\n const noTemplateVisible = () => {\n let totalTemplateCount = this._templatedLayer._templates.length,\n disabledTemplateCount = 0;\n for (let j = 0; j < this._templatedLayer._templates.length; j++) {\n if (this._templatedLayer._templates[j].rel === 'query') {\n continue;\n }\n if (!this._templatedLayer._templates[j].layer.isVisible) {\n disabledTemplateCount++;\n }\n }\n return disabledTemplateCount === totalTemplateCount;\n };\n if (!this._projectionMatch() || noTemplateVisible()) {\n this.setAttribute('disabled', '');\n this.disabled = true;\n } else {\n this.removeAttribute('disabled');\n this.disabled = false;\n }\n this.toggleLayerControlDisabled();\n return this.disabled;\n }\n\n // disable/italicize layer control elements based on the map-extent.disabled property\n toggleLayerControlDisabled() {\n let input = this._layerControlCheckbox,\n label = this._layerControlLabel, // access to the label for the specific map-extent\n opacityControl = this._opacityControl,\n opacitySlider = this._opacitySlider,\n selectDetails = this._selectdetails;\n if (this.disabled) {\n // update the status of layerControl\n input.disabled = true;\n opacitySlider.disabled = true;\n label.style.fontStyle = 'italic';\n opacityControl.style.fontStyle = 'italic';\n if (selectDetails) {\n selectDetails.forEach((i) => {\n i.querySelectorAll('select').forEach((j) => {\n j.disabled = true;\n j.style.fontStyle = 'italic';\n });\n i.style.fontStyle = 'italic';\n });\n }\n } else {\n input.disabled = false;\n opacitySlider.disabled = false;\n label.style.fontStyle = 'normal';\n opacityControl.style.fontStyle = 'normal';\n if (selectDetails) {\n selectDetails.forEach((i) => {\n i.querySelectorAll('select').forEach((j) => {\n j.disabled = false;\n j.style.fontStyle = 'normal';\n });\n i.style.fontStyle = 'normal';\n });\n }\n }\n }\n\n _initTemplateVars(metaExtent, projection, mapml, base, projectionMatch) {\n function transcribe(element) {\n var select = document.createElement('select');\n var elementAttrNames = element.getAttributeNames();\n\n for (let i = 0; i < elementAttrNames.length; i++) {\n select.setAttribute(\n elementAttrNames[i],\n element.getAttribute(elementAttrNames[i])\n );\n }\n\n var options = element.children;\n\n for (let i = 0; i < options.length; i++) {\n var option = document.createElement('option');\n var optionAttrNames = options[i].getAttributeNames();\n\n for (let j = 0; j < optionAttrNames.length; j++) {\n option.setAttribute(\n optionAttrNames[j],\n options[i].getAttribute(optionAttrNames[j])\n );\n }\n\n option.innerHTML = options[i].innerHTML;\n select.appendChild(option);\n }\n return select;\n }\n var templateVars = [];\n // set up the URL template and associated inputs (which yield variable values when processed)\n var tlist = this.querySelectorAll(\n 'map-link[rel=tile],map-link[rel=image],map-link[rel=features],map-link[rel=query]'\n ),\n varNamesRe = new RegExp('(?:{)(.*?)(?:})', 'g'),\n zoomInput = this.querySelector('map-input[type=\"zoom\" i]'),\n includesZoom = false,\n boundsFallback = {};\n\n boundsFallback.zoom = 0;\n if (metaExtent) {\n let content = M._metaContentToObject(metaExtent.getAttribute('content')),\n cs;\n\n boundsFallback.zoom = content.zoom || boundsFallback.zoom;\n\n let metaKeys = Object.keys(content);\n for (let i = 0; i < metaKeys.length; i++) {\n if (!metaKeys[i].includes('zoom')) {\n cs = M.axisToCS(metaKeys[i].split('-')[2]);\n break;\n }\n }\n let axes = M.csToAxes(cs);\n boundsFallback.bounds = M.boundsToPCRSBounds(\n L.bounds(\n L.point(\n +content[`top-left-${axes[0]}`],\n +content[`top-left-${axes[1]}`]\n ),\n L.point(\n +content[`bottom-right-${axes[0]}`],\n +content[`bottom-right-${axes[1]}`]\n )\n ),\n boundsFallback.zoom,\n projection,\n cs\n );\n } else {\n // for custom projections, M[projection] may not be loaded, so uses M['OSMTILE'] as backup, this code will need to get rerun once projection is changed and M[projection] is available\n // TODO: This is a temporary fix, _initTemplateVars (or processinitialextent) should not be called when projection of the layer and map do not match, this should be called/reinitialized once the layer projection matches with the map projection\n let fallbackProjection = M[projection] || M.OSMTILE;\n boundsFallback.bounds = fallbackProjection.options.crs.pcrs.bounds;\n }\n\n for (var i = 0; i < tlist.length; i++) {\n var t = tlist[i],\n template = t.getAttribute('tref');\n t.zoomInput = zoomInput;\n if (!template) {\n template = M.BLANK_TT_TREF;\n let blankInputs = mapml.querySelectorAll('map-input');\n for (let i of blankInputs) {\n template += `{${i.getAttribute('name')}}`;\n }\n }\n\n var v,\n title = t.hasAttribute('title')\n ? t.getAttribute('title')\n : 'Query this layer',\n vcount = template.match(varNamesRe),\n trel =\n !t.hasAttribute('rel') ||\n t.getAttribute('rel').toLowerCase() === 'tile'\n ? 'tile'\n : t.getAttribute('rel').toLowerCase(),\n ttype = !t.hasAttribute('type')\n ? 'image/*'\n : t.getAttribute('type').toLowerCase(),\n inputs = [],\n tms = t && t.hasAttribute('tms');\n var zoomBounds = mapml.querySelector('map-meta[name=zoom]')\n ? M._metaContentToObject(\n mapml.querySelector('map-meta[name=zoom]').getAttribute('content')\n )\n : undefined;\n while ((v = varNamesRe.exec(template)) !== null) {\n var varName = v[1],\n inp = this.querySelector(\n 'map-input[name=' + varName + '],map-select[name=' + varName + ']'\n );\n if (inp) {\n if (\n inp.hasAttribute('type') &&\n inp.getAttribute('type') === 'location' &&\n (!inp.hasAttribute('min') || !inp.hasAttribute('max')) &&\n inp.hasAttribute('axis') &&\n !['i', 'j'].includes(inp.getAttribute('axis').toLowerCase())\n ) {\n if (\n zoomInput &&\n template.includes(`{${zoomInput.getAttribute('name')}}`)\n ) {\n zoomInput.setAttribute('value', boundsFallback.zoom);\n }\n let axis = inp.getAttribute('axis'),\n axisBounds = M.convertPCRSBounds(\n boundsFallback.bounds,\n boundsFallback.zoom,\n projection,\n M.axisToCS(axis)\n );\n inp.setAttribute('min', axisBounds.min[M.axisToXY(axis)]);\n inp.setAttribute('max', axisBounds.max[M.axisToXY(axis)]);\n }\n\n inputs.push(inp);\n includesZoom =\n includesZoom ||\n (inp.hasAttribute('type') &&\n inp.getAttribute('type').toLowerCase() === 'zoom');\n if (inp.tagName.toLowerCase() === 'map-select') {\n // use a throwaway div to parse the input from MapML into HTML\n var div = document.createElement('div');\n div.insertAdjacentHTML('afterbegin', inp.outerHTML);\n // parse\n inp.htmlselect = div.querySelector('map-select');\n inp.htmlselect = transcribe(inp.htmlselect);\n\n // this goes into the layer control, so add a listener\n L.DomEvent.on(inp.htmlselect, 'change', this.redraw, this);\n\n if (!this._userInputs) {\n this._userInputs = [];\n }\n this._userInputs.push(inp.htmlselect);\n }\n // TODO: if this is an input@type=location\n // get the TCRS min,max attribute values at the identified zoom level\n // save this information as properties of the mapExtent,\n // perhaps as a bounds object so that it can be easily used\n // later by the layer control to determine when to enable\n // disable the layer for drawing.\n } else {\n console.log(\n 'input with name=' +\n varName +\n ' not found for template variable of same name'\n );\n // no match found, template won't be used\n break;\n }\n }\n if (\n (template && vcount.length === inputs.length) ||\n template === M.BLANK_TT_TREF\n ) {\n if (trel === 'query') {\n this._layer.queryable = true;\n }\n if (!includesZoom && zoomInput) {\n inputs.push(zoomInput);\n }\n let step = zoomInput ? zoomInput.getAttribute('step') : 1;\n if (!step || step === '0' || isNaN(step)) step = 1;\n // template has a matching input for every variable reference {varref}\n templateVars.push({\n template: decodeURI(new URL(template, base)),\n linkEl: t,\n title: title,\n rel: trel,\n type: ttype,\n values: inputs,\n zoomBounds: zoomBounds,\n boundsFallbackPCRS: { bounds: boundsFallback.bounds },\n projectionMatch: projectionMatch,\n projection: this.units || M.FALLBACK_PROJECTION,\n tms: tms,\n step: step\n });\n }\n }\n return templateVars;\n }\n redraw() {\n this._templatedLayer.redraw();\n }\n\n _handleChange() {\n // if the parent layer- is checked, add _templatedLayer to map if map-extent is checked, otherwise remove it\n if (this.checked && this.parentLayer.checked && !this.disabled) {\n this._templatedLayer.addTo(this._layer._map);\n this._templatedLayer.setZIndex(\n Array.from(this.parentLayer.querySelectorAll('map-extent')).indexOf(\n this\n )\n );\n } else {\n this._map.removeLayer(this._templatedLayer);\n }\n // change the checkbox in the layer control to match map-extent.checked\n // doesn't trigger the event handler because it's not user-caused AFAICT\n }\n _validateLayerControlContainerHidden() {\n let extentsFieldset = this.parentLayer._propertiesGroupAnatomy;\n let nodeToSearch = this.parentLayer.shadowRoot || this.parentLayer;\n if (\n nodeToSearch.querySelectorAll('map-extent:not([hidden])').length === 0\n ) {\n extentsFieldset.setAttribute('hidden', '');\n } else {\n extentsFieldset.removeAttribute('hidden');\n }\n }\n disconnectedCallback() {\n // in case of projection change, the disconnectedcallback will be triggered by removing layer-._layer even before\n // map-extent.connectedcallback is finished (because it will wait for the layer- to be ready)\n // !this._templatedLayer <=> this.connectedCallback has not yet been finished before disconnectedCallback is triggered\n if (\n this.hasAttribute('data-moving') ||\n this.parentLayer.hasAttribute('data-moving') ||\n !this._templatedLayer\n )\n return;\n this._validateLayerControlContainerHidden();\n // remove layer control for map-extent from layer control DOM\n this._layerControlHTML.remove();\n this._map.removeLayer(this._templatedLayer);\n this.parentLayer.removeEventListener('map-change', this._changeHandler);\n this.mapEl.removeEventListener('map-projectionchange', this._changeHandler);\n delete this._templatedLayer;\n delete this.parentLayer.bounds;\n }\n _calculateBounds() {\n let bounds = null,\n zoomMax = 0,\n zoomMin = 0,\n maxNativeZoom = 0,\n minNativeZoom = 0;\n // bounds should be able to be calculated unconditionally, not depend on map-extent.checked\n for (let j = 0; j < this._templateVars.length; j++) {\n let inputData = M._extractInputBounds(this._templateVars[j]);\n this._templateVars[j].tempExtentBounds = inputData.bounds;\n this._templateVars[j].extentZoomBounds = inputData.zoomBounds;\n if (!bounds) {\n bounds = this._templateVars[j].tempExtentBounds;\n zoomMax = this._templateVars[j].extentZoomBounds.maxZoom;\n zoomMin = this._templateVars[j].extentZoomBounds.minZoom;\n maxNativeZoom = this._templateVars[j].extentZoomBounds.maxNativeZoom;\n minNativeZoom = this._templateVars[j].extentZoomBounds.minNativeZoom;\n } else {\n bounds.extend(this._templateVars[j].tempExtentBounds.min);\n bounds.extend(this._templateVars[j].tempExtentBounds.max);\n zoomMax = Math.max(\n zoomMax,\n this._templateVars[j].extentZoomBounds.maxZoom\n );\n zoomMin = Math.min(\n zoomMin,\n this._templateVars[j].extentZoomBounds.minZoom\n );\n maxNativeZoom = Math.max(\n maxNativeZoom,\n this._templateVars[j].extentZoomBounds.maxNativeZoom\n );\n minNativeZoom = Math.min(\n minNativeZoom,\n this._templateVars[j].extentZoomBounds.minNativeZoom\n );\n }\n }\n // cannot be named as layerBounds if we decide to keep the debugoverlay logic\n this._templatedLayer.bounds = bounds;\n this._templatedLayer.zoomBounds = {\n minZoom: zoomMin,\n maxZoom: zoomMax,\n maxNativeZoom,\n minNativeZoom\n };\n }\n\n whenReady() {\n return new Promise((resolve, reject) => {\n let interval, failureTimer;\n if (this._templatedLayer) {\n resolve();\n } else {\n let extentElement = this;\n interval = setInterval(testForExtent, 300, extentElement);\n failureTimer = setTimeout(extentNotDefined, 10000);\n }\n function testForExtent(extentElement) {\n if (extentElement._templatedLayer) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n resolve();\n } else if (!extentElement.isConnected) {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('map-extent was disconnected while waiting to be ready');\n }\n }\n function extentNotDefined() {\n clearInterval(interval);\n clearTimeout(failureTimer);\n reject('Timeout reached waiting for extent to be ready');\n }\n });\n }\n}\n"],"names":["MapExtent","HTMLElement","observedAttributes","units","this","getAttribute","checked","hasAttribute","val","setAttribute","removeAttribute","label","M","options","locale","dfExtent","opacity","_opacity","hidden","attributeChangedCallback","name","oldValue","newValue","whenReady","then","_layerControlHTML","querySelector","innerHTML","_handleChange","_calculateBounds","_layerControlCheckbox","_templatedLayer","changeOpacity","let","extentsRootFieldset","parentLayer","_propertiesGroupAnatomy","position","Array","from","parentNode","querySelectorAll","indexOf","remove","insertAdjacentElement","_validateLayerControlContainerHidden","catch","console","log","reason","constructor","super","connectedCallback","_createLayerControlExtentHTML","bind","nodeName","toUpperCase","host","shadowRoot","attachShadow","mode","mapEl","closest","whenProjectionDefined","Error","isConnected","_layer","_map","bounds","_templateVars","_initTemplateVars","_content","getBase","mapprojection","_changeHandler","addEventListener","templatedLayer","pane","_container","_leafletLayer","crs","_properties","extentZIndex","extentEl","_DOMnode","addExtentToLayerControl","_queries","concat","getLayerControlHTML","_projectionMatch","_validateDisabled","noTemplateVisible","totalTemplateCount","_templates","length","disabledTemplateCount","j","rel","layer","isVisible","disabled","toggleLayerControlDisabled","input","_layerControlLabel","opacityControl","_opacityControl","opacitySlider","_opacitySlider","selectDetails","_selectdetails","style","fontStyle","forEach","i","metaExtent","projection","mapml","base","projectionMatch","templateVars","tlist","varNamesRe","RegExp","zoomInput","includesZoom","boundsFallback","zoom","content","_metaContentToObject","cs","metaKeys","Object","keys","includes","axisToCS","split","axes","csToAxes","boundsToPCRSBounds","L","point","fallbackProjection","OSMTILE","pcrs","t","template","BLANK_TT_TREF","title","vcount","match","trel","toLowerCase","ttype","inputs","tms","zoomBounds","undefined","v","exec","div","varName","inp","axis","axisBounds","convertPCRSBounds","min","axisToXY","max","push","tagName","document","createElement","insertAdjacentHTML","outerHTML","htmlselect","element","select","elementAttrNames","getAttributeNames","children","option","optionAttrNames","appendChild","transcribe","DomEvent","on","redraw","_userInputs","queryable","step","isNaN","decodeURI","URL","linkEl","type","values","boundsFallbackPCRS","FALLBACK_PROJECTION","addTo","setZIndex","removeLayer","extentsFieldset","nodeToSearch","disconnectedCallback","removeEventListener","zoomMax","zoomMin","maxNativeZoom","minNativeZoom","inputData","_extractInputBounds","tempExtentBounds","extentZoomBounds","extend","Math","maxZoom","minZoom","Promise","resolve","reject","interval","failureTimer","setInterval","extentElement","clearInterval","clearTimeout","setTimeout"],"mappings":";;MACaA,kBAAkBC,YAC7BC,gCACE,MAAO,CAAC,UAAW,QAAS,UAAW,UAEzCC,YACE,OAAOC,KAAKC,aAAa,SAG3BC,cACE,OAAOF,KAAKG,aAAa,WAG3BD,YAAYE,GACNA,EACFJ,KAAKK,aAAa,UAAW,IAE7BL,KAAKM,gBAAgB,WAGzBC,YACE,OAAOP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2B,gBAAgBqC,OAASA,EAC9BhE,KAAK2B,gBAAgB4H,WAAa,CAChC6D,QAASV,EACTS,QAASV,EACTE,cAAAA,EACAC,cAAAA,GAIJzL,YACE,OAAO,IAAIkM,QAAQ,CAACC,EAASC,KAC3B1L,IAAI2L,EAAUC,EACVzN,KAAK2B,gBACP2L,KAGAE,EAAWE,YAGb,SAAuBC,GACjBA,EAAchM,iBAChBiM,cAAcJ,GACdK,aAAaJ,GACbH,KACUK,EAAc9J,cACxB+J,cAAcJ,GACdK,aAAaJ,GACbF,EAAO,2DAX6B,IADlBvN,MAEpByN,EAAeK,WAajB,WACEF,cAAcJ,GACdK,aAAaJ,GACbF,EAAO,mDAhBqC,gBA5kBvC3N"} \ No newline at end of file diff --git a/dist/map-feature.js b/dist/map-feature.js index d4db865b..00872f67 100644 --- a/dist/map-feature.js +++ b/dist/map-feature.js @@ -1,4 +1,4 @@ -/*! @maps4html/web-map-custom-element 09-11-2023 */ +/*! @maps4html/web-map-custom-element 15-11-2023 */ class MapFeature extends HTMLElement{static get observedAttributes(){return["zoom","min","max"]}get zoom(){return+(this.hasAttribute("zoom")?this.getAttribute("zoom"):0)}set zoom(e){e=parseInt(e,10);!isNaN(e)&&e>=this.min&&e<=this.max&&this.setAttribute("zoom",e)}get min(){return+(this.hasAttribute("min")?this.getAttribute("min"):this._layer._layerEl.extent.zoom.minZoom)}set min(e){e=parseInt(e,10);isNaN(e)||(e>=this._layer._layerEl.extent.zoom.minZoom&&e<=this._layer._layerEl.extent.zoom.maxZoom?this.setAttribute("min",e):this.setAttribute("min",this._layer._layerEl.extent.zoom.minZoom))}get max(){return+(this.hasAttribute("max")?this.getAttribute("max"):this._layer._layerEl.extent.zoom.maxZoom)}set max(e){e=parseInt(e,10);isNaN(e)||(e>=this._layer._layerEl.extent.zoom.minZoom&&e<=this._layer._layerEl.extent.zoom.maxZoom?this.setAttribute("max",e):this.setAttribute("max",this._layer._layerEl.extent.zoom.maxZoom))}get extent(){if(this.isConnected)return this._getFeatureExtent||(this._getFeatureExtent=this._memoizeExtent()),this._getFeatureExtent()}attributeChangedCallback(e,r,i){if("zoom"===e)if(r!==i&&this._layer){let e=this._layer,t=i,o=e._mapmlvectors;o._staticFeature&&(this._removeInFeatureList(r),t in o._features?o._features[t].push(this._featureGroup):o._features[t]=[this._featureGroup],r=this._getNativeZoomAndCS(e._content),o.zoomBounds=M.getZoomBounds(e._content,r.zoom))}}constructor(){super()}connectedCallback(){this.closest("mapml-")||(this._parentEl="LAYER-"===this.parentNode.nodeName.toUpperCase()||"MAP-EXTENT"===this.parentNode.nodeName.toUpperCase()?this.parentNode:this.parentNode.host,this._parentEl.whenReady().then(()=>{this._layer=this._parentEl._layer,delete this._parentEl.bounds,this._layer._layerEl.hasAttribute("data-moving")||this._parentEl.hasAttribute("data-moving")||this.parentNode.nodeType!==document.DOCUMENT_FRAGMENT_NODE&&"layer-"!==this.parentNode.nodeName.toLowerCase()||this.parentNode.nodeType===document.DOCUMENT_FRAGMENT_NODE&&this.parentNode.host.hasAttribute("data-moving")||"layer-"===this.parentNode.nodeName.toLowerCase()&&this.parentNode.hasAttribute("data-moving")||(this._addFeature(),this._observer=new MutationObserver(e=>{for(var t of e){if("attributes"===t.type&&t.target===this)return;this._reRender(),delete this._parentEl.bounds}}),this._observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeOldValue:!0,characterData:!0}))}))}disconnectedCallback(){this._layer&&(this._layer._layerEl.hasAttribute("data-moving")||(this._removeFeature(),this._observer.disconnect(),delete this._parentEl.bounds))}_reRender(){if(this._groupEl.isConnected){var t=this._getNativeZoomAndCS(this._layer._content);let e=document.createElement("span");this._groupEl.insertAdjacentElement("beforebegin",e),this._featureGroup._map.removeLayer(this._featureGroup),this._featureGroup=this._layer._mapmlvectors.addData(this,t.cs,t.zoom).addTo(this._map),e.replaceWith(this._featureGroup.options.group),delete this._getFeatureExtent,this._setUpEvents()}}_removeFeature(){if(this._groupEl?.isConnected&&this._groupEl.remove(),this._featureGroup?._map){this._featureGroup._map.removeLayer(this._featureGroup);let e=this._layer._mapmlvectors;e&&(e._staticFeature&&(e._features[this.zoom]&&this._removeInFeatureList(this.zoom),e.zoomBounds=M.getZoomBounds(this._layer._content,this._getNativeZoomAndCS(this._layer._content).zoom)),e.options.properties=null,delete e._layers[this._featureGroup._leaflet_id])}delete this._featureGroup,delete this._groupEl,this._getFeatureExtent&&delete this._getFeatureExtent}_addFeature(){this._parentEl.whenReady().then(()=>{var e,t="LAYER-"===this._parentEl.nodeName.toUpperCase()?this._parentEl:this._parentEl.parentElement||this._parentEl.parentNode.host;this._map=this._layer._map;let o=this._layer._mapmlvectors;this.querySelector("map-geometry")&&(this._extentEl||(e=this._getNativeZoomAndCS(this._layer._content),this._featureGroup=o.addData(this,e.cs,e.zoom),t.checked&&this._featureGroup.addTo(this._map),o._layers[this._featureGroup._leaflet_id]=this._featureGroup,o._staticFeature&&!this._extentEl&&(o.zoomBounds=M.getZoomBounds(this._layer._content,this._getNativeZoomAndCS(this._layer._content).zoom),o.layerBounds=M.getBounds(this._layer._content),L.extend(o.options,o.zoomBounds),this._map._addZoomLimit(o),o._resetFeatures())),this._setUpEvents())})}_setUpEvents(){["click","focus","blur","keyup","keydown"].forEach(o=>{this._groupEl.addEventListener(o,t=>{if("click"===o){let e=new PointerEvent(o,{cancelable:!0});e.originalEvent=t,this.dispatchEvent(e)}else if("keyup"===o||"keydown"===o){let e=new KeyboardEvent(o,{cancelable:!0});e.originalEvent=t,this.dispatchEvent(e)}else{let e=new FocusEvent(o,{cancelable:!0});e.originalEvent=t,this.dispatchEvent(e)}})})}_getNativeZoomAndCS(o){let r,i;if(this._extentEl){if(this._extentEl.querySelector("map-link[rel=query]")){let e,t;o&&(e=M._metaContentToObject(Array.prototype.filter.call(o,function(e){return e.matches("map-meta[name=zoom]")})[0]?.getAttribute("content")).content,t=M._metaContentToObject(Array.prototype.filter.call(o,function(e){return e.matches("map-meta[name=cs]")})[0]?.getAttribute("content")).content),r=e||this._map.getZoom(),i=t||"gcrs"}else this._extentEl.querySelector("map-link[rel=features]")&&(r=this._extentEl._nativeZoom,i=this._extentEl._nativeCS);return{zoom:r,cs:i}}return M.getNativeVariables(o)}_memoizeExtent(){let h;return function(){if(h&&this._getFeatureExtent)return h;{let i=this._map,e=this.querySelector("map-geometry"),t=this._getNativeZoomAndCS(this._layer.queryMetas?.length?this._layer.queryMetas:this._layer._content),o=e.getAttribute("cs")||t.cs,r=this.zoom||t.zoom,a=e.querySelectorAll("map-point, map-linestring, map-polygon, map-multipoint, map-multilinestring"),s=[1/0,1/0,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY];for(var l of a){var m=l.querySelectorAll("map-coordinates");for(let e=0;e]+>/g,"").replace(/\s+/g," ").split(/[<>\ ]/g);switch(e.tagName){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 e=0;ei&&(i=this.min)),ir&&(i=r),i}mapml2geojson(e){e=Object.assign({},{propertyFunction:null,transform:!0},e);let t={type:"Feature",properties:{},geometry:{}},o=this.querySelector("map-properties");o?"function"==typeof e.propertyFunction?t.properties=e.propertyFunction(o):o.querySelector("table")?(s=o.querySelector("table").cloneNode(!0),t.properties=M._table2properties(s)):t.properties={prop0:o.innerHTML.replace(/(<([^>]+)>)/gi,"").replace(/\s/g,"")}:t.properties=null;let r=null,i=null;e.transform&&(r=new proj4.Proj(this._map.options.crs.code),i=new proj4.Proj("EPSG:4326"),"EPSG:3857"!==this._map.options.crs.code&&"EPSG:4326"!==this._map.options.crs.code||(e.transform=!1));var a=this.querySelector("map-geometry").querySelector("map-geometrycollection"),s=this.querySelector("map-geometry").querySelectorAll("map-point, map-polygon, map-linestring, map-multipoint, map-multipolygon, map-multilinestring");if(a){t.geometry.type="GeometryCollection",t.geometry.geometries=[];for(var n of s)t.geometry.geometries.push(M._geometry2geojson(n,r,i,e.transform))}else t.geometry=M._geometry2geojson(s[0],r,i,e.transform);return t}click(){let e=this._groupEl,t=e.getBoundingClientRect();var o=new MouseEvent("click",{clientX:t.x+t.width/2,clientY:t.y+t.height/2,button:0}),r=this.querySelector("map-properties");if("link"===e.getAttribute("role"))for(var i of e.children)i.mousedown.call(this._featureGroup,o),i.mouseup.call(this._featureGroup,o);let a=new PointerEvent("click",{cancelable:!0});if(a.originalEvent=o,this.dispatchEvent(a),r&&this.isConnected){let e=this._featureGroup,t=e._layers;for(var s in t)t[s].isPopupOpen()&&t[s].closePopup();e.isPopupOpen()?e.closePopup():a.originalEvent.cancelBubble||e.openPopup()}}focus(e){this._groupEl.focus(e)}blur(){document.activeElement.shadowRoot?.activeElement!==this._groupEl&&document.activeElement.shadowRoot?.activeElement.parentNode!==this._groupEl||(this._groupEl.blur(),this._map._container.focus())}zoomTo(){let e=this.extent,t=this._map,o=e.topLeft.pcrs,r=e.bottomRight.pcrs,i=L.bounds(L.point(o.horizontal,o.vertical),L.point(r.horizontal,r.vertical)),a=t.options.crs.unproject(i.getCenter(!0));t.setView(a,this.getMaxZoom(),{animate:!1})}whenReady(){return this._parentEl.whenReady().then(()=>new Promise((t,e)=>{let o,r;this._featureGroup?t():(o=setInterval(function(e){e._featureGroup&&(clearInterval(o),clearTimeout(r),t())},200,this),r=setTimeout(function(){clearInterval(o),clearTimeout(r),e("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/dist/map-input.js b/dist/map-input.js index 6daeb350..7d456b6c 100644 --- a/dist/map-input.js +++ b/dist/map-input.js @@ -1,4 +1,4 @@ -/*! @maps4html/web-map-custom-element 09-11-2023 */ +/*! @maps4html/web-map-custom-element 15-11-2023 */ 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(){return"height"===this.type||"width"===this.type||"hidden"===this.type?null:this.getAttribute("min")?this.getAttribute("min"):this._layer._layerEl.querySelector("map-meta[name=zoom]")?M._metaContentToObject(this._layer._layerEl.querySelector("map-meta[name=zoom]").getAttribute("content")).min:this._layer._layerEl.extent.zoom.minZoom.toString()}set min(t){t&&this.setAttribute("min",t)}get max(){return"height"===this.type||"width"===this.type||"hidden"===this.type?null:this.getAttribute("max")?this.getAttribute("max"):this._layer._layerEl.querySelector("map-meta[name=zoom]")?M._metaContentToObject(this._layer._layerEl.querySelector("map-meta[name=zoom]").getAttribute("content")).max:this._layer._layerEl.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)}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:this.initialValue=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.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/dist/map-link.js b/dist/map-link.js index d17c6243..4e50a27c 100644 --- a/dist/map-link.js +++ b/dist/map-link.js @@ -1,4 +1,4 @@ -/*! @maps4html/web-map-custom-element 09-11-2023 */ +/*! @maps4html/web-map-custom-element 15-11-2023 */ class MapLink extends HTMLElement{static get observedAttributes(){return["type","rel","title","href","hreflang","tref","tms","projection"]}get type(){return this.getAttribute("type")}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 title(){return this.getAttribute("title")}set title(t){t&&this.setAttribute("title",t)}get href(){return this.getAttribute("href")}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.getAttribute("tref")}set tref(t){t&&this.setAttribute("tref",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)}attributeChangedCallback(t,e,r){t}constructor(){super()}connectedCallback(){}disconnectedCallback(){}resolve(){if(this.tref){let e={};var r=this.parentElement.querySelectorAll("map-input");if("image"===this.rel){for(let t=0;t{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);return t.getMaxZoom()!==1/0&&(o.zoom={minZoom:t.getMinZoom(),maxZoom: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),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.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){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())}Promise.allSettled(i).then(()=>{this.zoomTo(t,e,o),M.options.announceMovement&&this._map.announceMovement.enable(),this.querySelectorAll("layer-").forEach(t=>{t.dispatchEvent(new CustomEvent("map-change"))})})}}).bind(this);new Promise((t,e)=>{o(),t()}).then(()=>{if(this._map&&this._map.options.projection!==e&&(this.zoomTo(this.lat,this.lon,this.zoom+1),this.zoomTo(this.lat,this.lon,this.zoom-1),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);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),this.parentElement.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}))}),this.parentElement.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._updateMapCenter(),this.dispatchEvent(new CustomEvent("movestart",{detail:{target:this}}))},this),this._map.on("move",function(){this._updateMapCenter(),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._updateMapCenter(),this.dispatchEvent(new CustomEvent("zoomstart",{detail:{target:this}}))},this),this._map.on("zoom",function(){this._updateMapCenter(),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),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.whenElemsReady());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-link",MapLink);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{MapLink}from"./map-link.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);return t.getMaxZoom()!==1/0&&(o.zoom={minZoom:t.getMinZoom(),maxZoom: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),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.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){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())}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);new Promise((t,e)=>{o(),t()}).then(()=>{if(this._map&&this._map.options.projection!==e&&(this.zoomTo(this.lat,this.lon,this.zoom+1),this.zoomTo(this.lat,this.lon,this.zoom-1),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);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),this.parentElement.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}))}),this.parentElement.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._updateMapCenter(),this.dispatchEvent(new CustomEvent("movestart",{detail:{target:this}}))},this),this._map.on("move",function(){this._updateMapCenter(),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._updateMapCenter(),this.dispatchEvent(new CustomEvent("zoomstart",{detail:{target:this}}))},this),this._map.on("zoom",function(){this._updateMapCenter(),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),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.whenElemsReady());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-link",MapLink);export{MapViewer}; //# sourceMappingURL=mapml-viewer.js.map \ No newline at end of file diff --git a/dist/mapml-viewer.js.map b/dist/mapml-viewer.js.map index 76cc56f6..a88a42c9 100644 --- a/dist/mapml-viewer.js.map +++ b/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 { MapLink } from './map-link.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 if (map.getMaxZoom() !== Infinity) {\n formattedExtent.zoom = {\n minZoom: map.getMinZoom(),\n maxZoom: map.getMaxZoom()\n };\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/Web-Map-Custom-Element/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/Web-Map-Custom-Element/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/Web-Map-Custom-Element/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 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 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 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 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 this.querySelectorAll('layer-').forEach((layer) => {\n layer.dispatchEvent(new CustomEvent('map-change'));\n });\n });\n }\n };\n if (newValue) {\n const connect = reconnectLayers.bind(this);\n new Promise((resolve, reject) => {\n connect();\n resolve();\n }).then(() => {\n if (this._map && this._map.options.projection !== oldValue) {\n // this awful hack is brought to you by a leaflet bug/ feature request\n // https://github.com/Leaflet/Leaflet/issues/2553\n this.zoomTo(this.lat, this.lon, this.zoom + 1);\n this.zoomTo(this.lat, this.lon, this.zoom - 1);\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\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 this.parentElement.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 this.parentElement.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._updateMapCenter();\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._updateMapCenter();\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._updateMapCenter();\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._updateMapCenter();\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 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.whenElemsReady());\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-link', MapLink);\n"],"names":["MapLayer","MapCaption","MapFeature","MapExtent","MapInput","MapLink","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","getMaxZoom","Infinity","minZoom","getMinZoom","maxZoom","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","query","contextMenu","announceMovement","featureIndex","mapEl","zoomControl","_addToHistory","_createControls","_toggleControls","_crosshair","crosshair","addTo","featureIndexOverlayOption","_featureIndexOverlay","featureIndexOverlay","_setUpEvents","disconnectedCallback","firstChild","removeChild","_deleteControls","adoptedCallback","attributeChangedCallback","name","oldValue","newValue","valueSet","_hideControls","_showControls","connect","layersReady","disable","layer","querySelectorAll","reAttach","push","whenReady","Promise","allSettled","zoomTo","enable","forEach","dispatchEvent","CustomEvent","bind","resolve","reject","_resetHistory","_debug","i","toggleDebug","mapSize","getSize","y","totalSize","_layerControl","layerControl","collapsed","scaleValue","announceScale","metric","imperial","_scaleBar","scaleBar","_zoomControl","control","_reloadButton","reloadButton","_fullScreenControl","fullscreenButton","_geolocationButton","geolocationButton","toggleContextMenuItem","_setControlsVisibility","toLowerCase","_layers","length","hide","container","children","childEl","isStatic","dragging","touchZoom","doubleClickZoom","scrollWheelZoom","boxZoom","keyboard","_dropHandler","event","preventDefault","text","dataTransfer","getData","_pasteLayer","_dragoverHandler","dropEffect","_removeEvents","off","removeEventListener","addEventListener","e","target","tagName","details","originalEvent","parentElement","keyCode","activeElement","nodeName","detail","ctrlKey","navigator","clipboard","readText","fire","on","latlng","accuracy","error","message","lng","x","containerPoint","_updateMapCenter","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","resolutions","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","interval","failureTimer","setInterval","viewer","clearInterval","clearTimeout","whenLayersReady","whenElemsReady","p","geojson2mapml","json","geojsonLayer","customElements","define"],"mappings":";;+CAESA,iCACAC,yCACAC,yCACAC,uCACAC,qCACAC,kCAEIC,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,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AO,gDAZkC,QAgB/CgK,kBACE/Q,IAAI+F,EAAc,GAElB,IAAK/F,IAAIiG,IAAS,IAAI9H,KAAK0B,QACzBkG,EAAYK,KAAKH,EAAM+K,kBAEzB,OAAO1K,QAAQC,WAAWR,GAE5B1G,sBAAsBD,GACpB,OAAO,IAAIkH,QAAQ,CAACQ,EAASC,KAC3B/G,IAAIyQ,EAAUC,EACVtQ,EAAEhB,GACJ0H,KAEA2J,EAAWE,YAGb,SAA2BM,GACrB7Q,EAAE6Q,KACJJ,cAAcJ,GACdK,aAAaJ,GACb5J,MAPwC,IAAK1H,GAC/CsR,EAAenO,WASjB,WACEsO,cAAcJ,GACdK,aAAaJ,GACb3J,EAAO,yDAZyC,QAgBtDmK,cAAcC,EAAM3Q,EAAU,SACDgM,IAAvBhM,EAAQpB,aACVoB,EAAQpB,WAAajB,KAAKiB,YAExBgS,EAAehR,EAAE8Q,cAAcC,EAAM3Q,GAEzC,OADArC,KAAKyF,YAAYwN,GACVA,GAIXxS,OAAOyS,eAAeC,OAAO,eAAgBvT,WAC7Ca,OAAOyS,eAAeC,OAAO,SAAU7T,UACvCmB,OAAOyS,eAAeC,OAAO,cAAe5T,YAC5CkB,OAAOyS,eAAeC,OAAO,cAAe3T,YAC5CiB,OAAOyS,eAAeC,OAAO,aAAc1T,WAC3CgB,OAAOyS,eAAeC,OAAO,YAAazT,UAC1Ce,OAAOyS,eAAeC,OAAO,WAAYxT,gBAt3C5BC"} \ 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 { MapLink } from './map-link.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 if (map.getMaxZoom() !== Infinity) {\n formattedExtent.zoom = {\n minZoom: map.getMinZoom(),\n maxZoom: map.getMaxZoom()\n };\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/Web-Map-Custom-Element/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/Web-Map-Custom-Element/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/Web-Map-Custom-Element/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 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 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 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 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 (newValue) {\n const connect = reconnectLayers.bind(this);\n new Promise((resolve, reject) => {\n connect();\n resolve();\n }).then(() => {\n if (this._map && this._map.options.projection !== oldValue) {\n // this awful hack is brought to you by a leaflet bug/ feature request\n // https://github.com/Leaflet/Leaflet/issues/2553\n this.zoomTo(this.lat, this.lon, this.zoom + 1);\n this.zoomTo(this.lat, this.lon, this.zoom - 1);\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\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 this.parentElement.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 this.parentElement.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._updateMapCenter();\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._updateMapCenter();\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._updateMapCenter();\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._updateMapCenter();\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 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.whenElemsReady());\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-link', MapLink);\n"],"names":["MapLayer","MapCaption","MapFeature","MapExtent","MapInput","MapLink","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","getMaxZoom","Infinity","minZoom","getMinZoom","maxZoom","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","query","contextMenu","announceMovement","featureIndex","mapEl","zoomControl","_addToHistory","_createControls","_toggleControls","_crosshair","crosshair","addTo","featureIndexOverlayOption","_featureIndexOverlay","featureIndexOverlay","_setUpEvents","disconnectedCallback","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","resolve","reject","_resetHistory","_debug","i","toggleDebug","mapSize","getSize","y","totalSize","_layerControl","layerControl","collapsed","scaleValue","announceScale","metric","imperial","_scaleBar","scaleBar","_zoomControl","control","_reloadButton","reloadButton","_fullScreenControl","fullscreenButton","_geolocationButton","geolocationButton","toggleContextMenuItem","_setControlsVisibility","forEach","toLowerCase","_layers","length","hide","container","children","childEl","isStatic","dragging","touchZoom","doubleClickZoom","scrollWheelZoom","boxZoom","keyboard","_dropHandler","event","preventDefault","text","dataTransfer","getData","_pasteLayer","_dragoverHandler","dropEffect","_removeEvents","off","removeEventListener","addEventListener","e","target","tagName","details","originalEvent","parentElement","keyCode","activeElement","nodeName","detail","ctrlKey","navigator","clipboard","readText","fire","on","latlng","accuracy","error","message","lng","x","containerPoint","_updateMapCenter","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","resolutions","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","interval","failureTimer","setInterval","viewer","clearInterval","clearTimeout","whenLayersReady","whenElemsReady","p","geojson2mapml","json","geojsonLayer","customElements","define"],"mappings":";;+CAESA,iCACAC,yCACAC,yCACAC,uCACAC,qCACAC,kCAEIC,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,M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gDAZkC,QAgB/CiK,kBACE/Q,IAAI+F,EAAc,GAElB,IAAK/F,IAAIiG,IAAS,IAAI9H,KAAK0B,QACzBkG,EAAYK,KAAKH,EAAM+K,kBAEzB,OAAO1K,QAAQC,WAAWR,GAE5B1G,sBAAsBD,GACpB,OAAO,IAAIkH,QAAQ,CAACO,EAASC,KAC3B9G,IAAIyQ,EAAUC,EACVtQ,EAAEhB,GACJyH,KAEA4J,EAAWE,YAGb,SAA2BM,GACrB7Q,EAAE6Q,KACJJ,cAAcJ,GACdK,aAAaJ,GACb7J,MAPwC,IAAKzH,GAC/CsR,EAAenO,WASjB,WACEsO,cAAcJ,GACdK,aAAaJ,GACb5J,EAAO,yDAZyC,QAgBtDoK,cAAcC,EAAM3Q,EAAU,SACDgM,IAAvBhM,EAAQpB,aACVoB,EAAQpB,WAAajB,KAAKiB,YAExBgS,EAAehR,EAAE8Q,cAAcC,EAAM3Q,GAEzC,OADArC,KAAKyF,YAAYwN,GACVA,GAIXxS,OAAOyS,eAAeC,OAAO,eAAgBvT,WAC7Ca,OAAOyS,eAAeC,OAAO,SAAU7T,UACvCmB,OAAOyS,eAAeC,OAAO,cAAe5T,YAC5CkB,OAAOyS,eAAeC,OAAO,cAAe3T,YAC5CiB,OAAOyS,eAAeC,OAAO,aAAc1T,WAC3CgB,OAAOyS,eAAeC,OAAO,YAAazT,UAC1Ce,OAAOyS,eAAeC,OAAO,WAAYxT,gBA13C5BC"} \ No newline at end of file diff --git a/dist/mapml.js b/dist/mapml.js index 774663fc..f92cc46c 100644 --- a/dist/mapml.js +++ b/dist/mapml.js @@ -1,6 +1,6 @@ -/*! @maps4html/web-map-custom-element 09-11-2023 */ +/*! @maps4html/web-map-custom-element 15-11-2023 */ -!function(){"use strict";function t(t){return new m(t)}function e(t,e){return new c(t,e)}function o(t,e){return new p(t,e)}function i(t,e){return new h(t,e)}function n(t,e){return new d(t,e)}function a(t,e){return new _(t,e)}function r(t,e){return new y(t,e)}function s(t,e,o,i,n,a){return new f(t,e,o,i,n,a)}function l(t,e,o,i){return t||e?new g(t,e,o,i):null}function u(){return new b}var m=L.GridLayer.extend({initialize:function(t){L.setOptions(this,t),this.zoomBounds=this._getZoomBounds(t.tileContainer,t.maxZoomBound),L.extend(this.options,this.zoomBounds),this._groups=this._groupTiles(this.options.tileContainer.getElementsByTagName("map-tile")),this._bounds=this._getLayerBounds(this._groups,this.options.projection),this.layerBounds=this._bounds[Object.keys(this._bounds)[0]];for(var e of Object.keys(this._bounds))this.layerBounds.extend(this._bounds[e].min),this.layerBounds.extend(this._bounds[e].max)},onAdd:function(t){this._map=t,L.GridLayer.prototype.onAdd.call(this,this._map),this._handleMoveEnd()},getEvents:function(){let t=L.GridLayer.prototype.getEvents.call(this,this._map);return this._parentOnMoveEnd=t.moveend,t.moveend=this._handleMoveEnd,t.move=()=>{},t},_handleMoveEnd:function(t){var e=this._map.getZoom();let o=e;o=o>this.options.maxNativeZoom?this.options.maxNativeZoom:o,o=o=this.zoomBounds.minZoom&&this._bounds[o]&&this._bounds[o].overlaps(M.pixelToPCRSBounds(this._map.getPixelBounds(),this._map.getZoom(),this._map.options.projection)),this.isVisible&&this._parentOnMoveEnd()},_isValidTile(t){return this._groups[this._tileCoordsToKey(t)]},createTile:function(t){let o=this._groups[this._tileCoordsToKey(t)]||[],i=document.createElement("map-tile"),n=this.getTileSize();i.setAttribute("col",t.x),i.setAttribute("row",t.y),i.setAttribute("zoom",t.z);for(let e=0;ee.options.zIndex?1:0}},initialize:function(t,e){for(var o in L.setOptions(this,e),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,t)this._addLayer(t[o],o,!0)},onAdd:function(){return this._initLayout(),L.DomEvent.on(this._container.getElementsByTagName("a")[0],"keydown",this._focusFirstLayer,this._container),L.DomEvent.on(this._container,"contextmenu",this._preventDefaultContextMenu,this),this._update(),this._layers.length<1&&!this._map._showControls?this._container.setAttribute("hidden",""):this._map._showControls=!0,this._container},onRemove:function(t){L.DomEvent.off(this._container.getElementsByTagName("a")[0],"keydown",this._focusFirstLayer,this._container)},addOrUpdateOverlay:function(t,e){for(var o=!1,i=0;ie.focus(),0)},_withinZoomBounds:function(t,e){return e.min<=t&&t<=e.max},_addItem:function(t){var e=t.layer._layerEl._layerControlHTML;return t.input=e.querySelector("input.leaflet-control-layers-selector"),this._layerControlInputs.push(t.input),t.input.layerId=L.stamp(t.layer),this._overlaysList.appendChild(e),e},collapse:function(t){return"SELECT"===t.target.tagName||t.relatedTarget&&t.relatedTarget.parentElement&&("mapml-contextmenu mapml-layer-menu"===t.relatedTarget.className||"mapml-contextmenu mapml-layer-menu"===t.relatedTarget.parentElement.className)||this._map&&"block"===this._map.contextMenu._layerMenu.style.display||(L.DomUtil.removeClass(this._container,"leaflet-control-layers-expanded"),"touch"===t.originalEvent?.pointerType&&(this._container._isExpanded=!1)),this},_preventDefaultContextMenu:function(t){var e=this._map.mouseEventToLatLng(t),o=this._map.mouseEventToContainerPoint(t);t.preventDefault(),this._container._isExpanded||"touch"!==t.pointerType?this._map.fire("contextmenu",{originalEvent:t,containerPoint:o,latlng:e}):this._container._isExpanded=!0}}),p=L.FeatureGroup.extend({initialize:function(t,e){var o;L.setOptions(this,e),this.options.static&&(this._container=L.DomUtil.create("div","leaflet-layer",this.options.pane),L.DomUtil.addClass(this._container,"leaflet-pane mapml-vector-container"),L.setOptions(this.options.renderer,{pane:this._container})),this._layers={},this.options.query?(this._mapmlFeatures=t.features||t,this.isVisible=!0,o=M.getNativeVariables(t),this.options.nativeZoom=o.zoom,this.options.nativeCS=o.cs):t?(o=M.getNativeVariables(t),this.addData(t,o.cs,o.zoom)):(this.isVisible=!1,this.options._leafletLayer&&(this._features={},this._staticFeature=!0))},onAdd:function(t){this._map=t,L.FeatureGroup.prototype.onAdd.call(this,t),this._staticFeature&&(this._resetFeatures(),this.options._leafletLayer._map._addZoomLimit(this)),this._mapmlFeatures&&t.on("featurepagination",this.showPaginationFeature,this)},onRemove:function(t){this._mapmlFeatures&&(t.off("featurepagination",this.showPaginationFeature,this),delete this._mapmlFeatures,L.DomUtil.remove(this._container)),L.FeatureGroup.prototype.onRemove.call(this,t),this._map.featureIndex.cleanIndex()},removeLayer:function(t){L.FeatureGroup.prototype.removeLayer.call(this,t),delete this._layers[t._leaflet_id]},getEvents:function(){return this._staticFeature?{moveend:this._handleMoveEnd,zoomend:this._handleZoomEnd}:{}},showPaginationFeature:function(o){if(this.options.query&&this._mapmlFeatures[o.i]){let e=this._mapmlFeatures[o.i];if("featurepagination"===o.type?e._extentEl.shadowRoot.querySelector("map-feature")?.remove():e._extentEl.shadowRoot.replaceChildren(),this.clearLayers(),e._featureGroup=this.addData(e,this.options.nativeCS,this.options.nativeZoom),o.meta)for(let t=0;t=this.zoomBounds.minZoom);this.isVisible=e&&this._layers&&this.layerBounds&&this.layerBounds.overlaps(M.pixelToPCRSBounds(this._map.getPixelBounds(),t,this._map.options.projection)),this._removeCSS()},_handleZoomEnd:function(t){this.zoomBounds&&this._resetFeatures()},_resetFeatures:function(){this._map&&this._map.featureIndex.cleanIndex();let i=this._map||this.options._leafletLayer._map;if(this._features)for(var n in this._features)for(let o=0;o=this.options.minZoom&&this.extentBounds.overlaps(o),this.isVisible&&this._parentOnMoveEnd()},createTile:function(e){let o=document.createElement("DIV"),i=this.getTileSize();if(L.DomUtil.addClass(o,"mapml-tile-group"),L.DomUtil.addClass(o,"leaflet-tile"),this._template.linkEl.dispatchEvent(new CustomEvent("tileloadstart",{detail:{x:e.x,y:e.y,zoom:e.z,appendTile:t=>{o.appendChild(t)}}})),this._template.type.startsWith("image/")){let t=L.TileLayer.prototype.createTile.call(this,e,function(){});t.width=i.x,t.height=i.y,o.appendChild(t)}else this._url.includes(M.BLANK_TT_TREF)||this._fetchTile(e,o);return o},_mapmlTileReady:function(t){L.DomUtil.addClass(t,"leaflet-tile-loaded")},getPane:function(){return this.options.pane},_fetchTile:function(e,o){fetch(this.getTileUrl(e),{redirect:"follow"}).then(function(t){return 200<=t.status&&t.status<300?Promise.resolve(t):(console.log("Looks like there was a problem. Status Code: "+t.status),Promise.reject(t))}).then(function(t){return t.text()}).then(t=>{return(new DOMParser).parseFromString(t,"application/xml")}).then(t=>{this._createFeatures(t,e,o),this._mapmlTileReady(o)}).catch(t=>{console.log("Error Creating Tile")})},_createFeatures:function(t,e,o){var i;t.querySelector("map-link[rel=stylesheet],map-style")&&(i=t.querySelector("map-base")&&t.querySelector("map-base").hasAttribute("href")?new URL(t.querySelector("map-base").getAttribute("href")).href:t.URL,M._parseStylesheetAsHTML(t,i,o));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;var u,m=M.featureLayer(t,{projection:this._map.options.projection,static:!1,layerBounds:this.extentBounds,zoomBounds:this.zoomBounds,interactive:!1});for(u in m._layers)for(var c in m._layers[u]._layers){let t=m._layers[u]._layers[c];M.FeatureRenderer.prototype._initPath(t,!1),t._project(this._map,L.point([s,l]),e.z),M.FeatureRenderer.prototype._addPath(t,a,!1),M.FeatureRenderer.prototype._updateFeature(t)}n.setAttribute("width",r.toString()),n.setAttribute("height",r.toString()),n.appendChild(a),o.appendChild(n)},getTileUrl:function(t){if(t.z>=this._template.tilematrix.bounds.length||!this._template.tilematrix.bounds[t.z].contains(t))return"";var e,o={},i=this._template.linkEl,n=i.zoomInput;for(e in o[this._template.tilematrix.col.name]=t.x,o[this._template.tilematrix.row.name]=t.y,n&&i.hasAttribute("tref")&&i.getAttribute("tref").includes(`{${n.getAttribute("name")}}`)&&(o[this._template.zoom.name]=this._getZoomForUrl()),o[this._template.pcrs.easting.left]=this._tileMatrixToPCRSPosition(t,"top-left").x,o[this._template.pcrs.easting.right]=this._tileMatrixToPCRSPosition(t,"top-right").x,o[this._template.pcrs.northing.top]=this._tileMatrixToPCRSPosition(t,"top-left").y,o[this._template.pcrs.northing.bottom]=this._tileMatrixToPCRSPosition(t,"bottom-left").y,this._template.tile)["row","col","zoom","left","right","top","bottom"].indexOf(e)<0&&(o[e]=this._template.tile[e]);return this._map&&!this._map.options.crs.infinite&&(t=this._globalTileRange.max.y-t.y,this.options.tms&&(o[this._template.tilematrix.row.name]=t)),o.r=this.options.detectRetina&&L.Browser.retina&&0=e.min&&Number.parseInt(_,10)<=e.max?e.value=Number.parseInt(_,10):e.value=e.max,!isNaN(Number.parseInt(y,10))&&Number.parseInt(y,10)>=e.min&&Number.parseInt(y,10)<=e.max&&(e.min=Number.parseInt(y,10)),!isNaN(Number.parseInt(f,10))&&Number.parseInt(f,10)>=e.min&&Number.parseInt(f,10)<=e.max&&(e.max=Number.parseInt(f,10)),t.zoom=e;else if(d){const A=r[l].htmlselect;t.tile[p]=function(){return A.value}}else{const I=r[l];t.tile[p]=function(){return I.getAttribute("value")}}}function g(t,e){return b.transform(t,v(e)).divideBy(x).floor()}var b=this.options.crs.transformation,x=this.options.crs.options.crs.tile.bounds.max.x,v=L.bind(this.options.crs.scale,this.options.crs);o&&i?(t.pcrs={},t.pcrs.bounds=L.bounds([o.min,i.min],[o.max,i.max]),t.pcrs.easting=o,t.pcrs.northing=i):a&&n&&!isNaN(e.value)?(t.pcrs||(t.pcrs={},t.pcrs.easting="",t.pcrs.northing=""),t.pcrs.bounds=M.boundsToPCRSBounds(L.bounds(L.point([a.min,n.min]),L.point([a.max,n.max])),e.value,this.options.crs,M.axisToCS("column")),t.tilematrix={},t.tilematrix.col=a,t.tilematrix.row=n):console.log("Unable to determine bounds for tile template: "+t.template),t.tilematrix||(t.tilematrix={},t.tilematrix.col={},t.tilematrix.row={}),t.tilematrix.bounds=[];for(var C=t.pcrs.bounds,E=t.zoom?t.zoom.min:0,S=t.zoom?t.zoom.max:s.resolutions.length,T=0;T<=S;T++)t.tilematrix.bounds[T]=E<=T?L.bounds(g(C.min,T),g(C.max,T)):L.bounds(L.point([-1,-1]),L.point([-1,-1]))},_clampZoom:function(t){var e=L.GridLayer.prototype._clampZoom.call(this,t);return this._template.step>this.zoomBounds.maxNativeZoom&&(this._template.step=this.zoomBounds.maxNativeZoom),t!==e?t=e:t%this._template.step!=0&&(t=Math.floor(t/this._template.step)*this._template.step),t}}),d=L.Layer.extend({initialize:function(t,e){this._templates=t,L.setOptions(this,e),this._container=L.DomUtil.create("div","leaflet-layer"),this._extentEl=this.options.extentEl,this.changeOpacity(this.options.opacity),L.DomUtil.addClass(this._container,"mapml-templatedlayer-container");for(var o,i=0;i=this.zoomBounds.minZoom&&this.extentBounds.overlaps(i);var a,r,s,l,u,m,c,p,o=this._getfeaturesUrl(n,o);o!==this._url&&(this._features.clearLayers(),this._extentEl.shadowRoot&&(this._extentEl.shadowRoot.innerHTML=""),this._removeCSS(),this.isVisible||n!==t?(r=new Headers({Accept:"text/mapml;q=0.9,application/geo+json;q=0.8"}),s=new DOMParser,l=this._features,u=this._extentEl,m=this._map,p=function(i,n){return fetch(i,{redirect:"follow",headers:r}).then(function(t){return t.text()}).then(function(t){a=s.parseFromString(t,"application/xml");var e=new URL(a.querySelector("map-base")?a.querySelector("map-base").getAttribute("href"):i).href;i=(i=a.querySelector("map-link[rel=next]")?a.querySelector("map-link[rel=next]").getAttribute("href"):null)?new URL(i,e).href:null;var o,t=u._nativeZoom=a.querySelector("map-meta[name=zoom]")&&+M._metaContentToObject(a.querySelector("map-meta[name=zoom]").getAttribute("content")).value||0,e=u._nativeCS=a.querySelector("map-meta[name=cs]")&&M._metaContentToObject(a.querySelector("map-meta[name=cs]").getAttribute("content")).content||"GCRS";l.addData(a,e,t);for(o of a.querySelector("map-body").children)u.shadowRoot.append(o._DOMnode),o._DOMnode._extentEl=u;if(i&&--n)return p(i,n)})},(c=this)._url=o,p(o,10).then(function(){m.addLayer(l),m.fire("templatedfeatureslayeradd"),M.TemplatedFeaturesLayer.prototype._updateTabIndex(c)}).catch(function(t){console.log(t)})):this._url="")},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},_updateTabIndex:function(t){var o,i=t||this;for(o in i._features._layers){let e=i._features._layers[o];if(e._path&&("M0 0"!==e._path.getAttribute("d")?e._path.setAttribute("tabindex",0):e._path.removeAttribute("tabindex"),0===e._path.childElementCount)){let t=document.createElement("title");t.innerText="Feature",e._path.appendChild(t)}}},_updateZIndex:function(){this._container&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._container.style.zIndex=this.options.zIndex)},_getfeaturesUrl:function(t,e){void 0===t&&(t=this._map.getZoom()),void 0===e&&(e=this._map.getPixelBounds());var o,i={};for(o in this.options.feature.zoom&&(i[this.options.feature.zoom]=t),this.options.feature.width&&(i[this.options.feature.width]=this._map.getSize().x),this.options.feature.height&&(i[this.options.feature.height]=this._map.getSize().y),this.options.feature.bottom&&(i[this.options.feature.bottom]=this._TCRSToPCRS(e.max,t).y),this.options.feature.left&&(i[this.options.feature.left]=this._TCRSToPCRS(e.min,t).x),this.options.feature.top&&(i[this.options.feature.top]=this._TCRSToPCRS(e.min,t).y),this.options.feature.right&&(i[this.options.feature.right]=this._TCRSToPCRS(e.max,t).x),this.options.feature)["width","height","left","right","top","bottom","zoom"].indexOf(o)<0&&(i[o]=this.options.feature[o]);return L.Util.template(this._template.template,i)},_TCRSToPCRS:function(t,e){var o=this._map.options.crs;return o.transformation.untransform(t,o.scale(e))},_setUpFeaturesTemplateVars:function(t){var e={feature:{}},o=t.values;e.feature.hidden=[];for(var i=0;i=this.zoomBounds.minZoom&&this.extentBounds.overlaps(o),this.isVisible?(o=(a=this._map).getPixelBounds().min.subtract(a.getPixelOrigin()),this._addImage(a.getPixelBounds(),e,o),this._pixelOrigins[e]=a.getPixelOrigin()):this._clearLayer())},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(t){L.DomUtil.remove(this._container),this._clearLayer(),t._removeZoomLimit(this)},getImageUrl:function(t,e){var o,i={};for(o in i[this.options.extent.width]=this._map.getSize().x,i[this.options.extent.height]=this._map.getSize().y,i[this.options.extent.bottom]=this._TCRSToPCRS(t.max,e).y,i[this.options.extent.left]=this._TCRSToPCRS(t.min,e).x,i[this.options.extent.top]=this._TCRSToPCRS(t.min,e).y,i[this.options.extent.right]=this._TCRSToPCRS(t.max,e).x,this.options.extent)["width","height","left","right","top","bottom"].indexOf(o)<0&&(i[o]=this.options.extent[o]);return L.Util.template(this._template.template,i)},_TCRSToPCRS:function(t,e){var o=this._map.options.crs;return o.transformation.untransform(t,o.scale(e))},_setUpExtentTemplateVars:function(t){for(var e={extent:{}},o=t.values,i=0;i{if("_templatedLayer"===t&&l.length){let e=s.maxZoom,o=s.minZoom,i=s.maxNativeZoom,n=s.minNativeZoom;for(let t=0;t{var o=e[0].attributes.units.value;let i=!0;for(let t=0;t'+e+"");L.setOptions(m,{attribution:e});var e=l.querySelector("map-link[rel=legend]");e&&(m._legendUrl=e.getAttribute("href"));m._map&&m._map.hasLayer(m)&&m._map.attributionControl.addAttribution(m.getAttribution())}(),l.querySelector("map-title")?(m._title=l.querySelector("map-title").textContent.trim(),m._titleIsReadOnly=!0):l instanceof Element&&l.hasAttribute("label")&&(m._title=l.getAttribute("label").trim()),function(){var t=l.querySelector("map-link[rel=zoomin]"),e=l.querySelector("map-link[rel=zoomout]");t&&(m._properties.zoomin=new URL(t.getAttribute("href"),u).href);e&&(m._properties.zoomout=new URL(e.getAttribute("href"),u).href)}(),m._properties.crs&&function(){if(l.querySelector("map-tile")){var t=document.createElement("map-tiles"),e=l.querySelector("map-meta[name=zoom][content]")||l.querySelector("map-input[type=zoom][value]");t.setAttribute("zoom",e&&e.getAttribute("content")||e&&e.getAttribute("value")||"0");for(var o=l.getElementsByTagName("map-tile"),i=0;i{L.DomEvent.stop(t),a.featureIndex._sortIndex(),a.closePopup(),a._container.focus()},n);let s=L.DomUtil.create("button","mapml-popup-button",t);s.type="button",s.title="Previous Feature",s.innerHTML="",L.DomEvent.on(s,"click",e._previousFeature,n);let l=L.DomUtil.create("p","mapml-feature-count",t),u=this._totalFeatureCount||1;l.innerText=n._count+1+"/"+u;let m=L.DomUtil.create("button","mapml-popup-button",t);m.type="button",m.title="Next Feature",m.innerHTML="",L.DomEvent.on(m,"click",e._nextFeature,n);let c=L.DomUtil.create("button","mapml-popup-button",t);c.type="button",c.title="Focus Controls",c.innerHTML="",L.DomEvent.on(c,"click",t=>{a.featureIndex._sortIndex(),a.featureIndex.currentIndex=a.featureIndex.inBoundFeatures.length-1,a.featureIndex.inBoundFeatures[0].path.setAttribute("tabindex",-1),a.featureIndex.inBoundFeatures[a.featureIndex.currentIndex].path.setAttribute("tabindex",0),L.DomEvent.stop(t),a.closePopup(),a._controlContainer.querySelector("A:not([hidden])").focus()},n);var p=L.DomUtil.create("hr","mapml-popup-divider");function h(t){let e=t.originalEvent.path||t.originalEvent.composedPath();var o=9===t.originalEvent.keyCode,i=t.originalEvent.shiftKey;(e[0].classList.contains("leaflet-popup-close-button")&&o&&!i||27===t.originalEvent.keyCode||e[0].classList.contains("leaflet-popup-close-button")&&13===t.originalEvent.keyCode||e[0].classList.contains("mapml-popup-content")&&o&&i||e[0]===n._content.querySelector("a")&&o&&i)&&setTimeout(()=>{a.closePopup(n),r.focus(),L.DomEvent.stop(t)},0)}function d(t){let e=t.originalEvent.path||t.originalEvent.composedPath();var o=9===t.originalEvent.keyCode,i=t.originalEvent.shiftKey;13===t.originalEvent.keyCode&&e[0].classList.contains("leaflet-popup-close-button")||27===t.originalEvent.keyCode?(L.DomEvent.stopPropagation(t),a.closePopup(n),a._container.focus(),27!==t.originalEvent.keyCode&&(a._popupClosed=!0)):o&&e[0].classList.contains("leaflet-popup-close-button")?a.closePopup(n):(e[0].classList.contains("mapml-popup-content")&&o&&i||e[0]===n._content.querySelector("a")&&o&&i)&&(a.closePopup(n),setTimeout(()=>{L.DomEvent.stop(t),a._container.focus()},0))}function _(t){let n=this._content,a=t?t.currFeature:this._source._groupLayer._featureEl;n.querySelector("a.mapml-zoom-link")&&n.querySelector("a.mapml-zoom-link").remove(),a.querySelector("map-geometry")&&a.whenReady().then(()=>{var t=a.extent.topLeft.gcrs,e=a.extent.bottomRight.gcrs,e=L.latLngBounds(L.latLng(t.horizontal,t.vertical),L.latLng(e.horizontal,e.vertical)).getCenter(!0);let o=document.createElement("a");o.href=`#${a.getMaxZoom()},${e.lng},`+e.lat,o.innerHTML=""+M.options.locale.popupZoom,o.className="mapml-zoom-link",o.onclick=o.onkeydown=function(t){(t instanceof MouseEvent||13===t.keyCode)&&(t.preventDefault(),a.zoomTo(),a._map.closePopup(),a._map.getContainer().focus())};let i=n.querySelector(".mapml-zoom-link");i&&i.remove(),n.insertBefore(o,n.querySelector("hr.mapml-popup-divider"))})}n._navigationBar=t,n._content.appendChild(p),n._content.appendChild(t),o.focus(),r&&!M.options.featureIndexOverlayOption?(r.setAttribute("aria-expanded","true"),a.on("keydown",h)):a.on("keydown",d),a.on("popupclose",function t(e){e.popup===n&&(a.off("keydown",h),a.off("keydown",d),a.off("popupopen",_),a.off("popupclose",t),r&&r.setAttribute("aria-expanded","false"))})}}),b=L.Layer.extend({onAdd:function(t){var e=t.getSize();(400{},t},_handleMoveEnd:function(t){var e=this._map.getZoom();let o=e;o=o>this.options.maxNativeZoom?this.options.maxNativeZoom:o,o=o=this.zoomBounds.minZoom&&this._bounds[o]&&this._bounds[o].overlaps(M.pixelToPCRSBounds(this._map.getPixelBounds(),this._map.getZoom(),this._map.options.projection)),this.isVisible&&this._parentOnMoveEnd()},_isValidTile(t){return this._groups[this._tileCoordsToKey(t)]},createTile:function(t){let o=this._groups[this._tileCoordsToKey(t)]||[],i=document.createElement("map-tile"),n=this.getTileSize();i.setAttribute("col",t.x),i.setAttribute("row",t.y),i.setAttribute("zoom",t.z);for(let e=0;ee.options.zIndex?1:0}},initialize:function(t,e){for(var o in L.setOptions(this,e),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,t)this._addLayer(t[o],o,!0)},onAdd:function(){return this._initLayout(),L.DomEvent.on(this._container.getElementsByTagName("a")[0],"keydown",this._focusFirstLayer,this._container),L.DomEvent.on(this._container,"contextmenu",this._preventDefaultContextMenu,this),this._update(),this._layers.length<1&&!this._map._showControls?this._container.setAttribute("hidden",""):this._map._showControls=!0,this._container},onRemove:function(t){L.DomEvent.off(this._container.getElementsByTagName("a")[0],"keydown",this._focusFirstLayer,this._container)},addOrUpdateOverlay:function(t,e){for(var o=!1,i=0;ie.focus(),0)},_withinZoomBounds:function(t,e){return e.min<=t&&t<=e.max},_addItem:function(t){var e=t.layer._layerEl._layerControlHTML;return t.input=e.querySelector("input.leaflet-control-layers-selector"),this._layerControlInputs.push(t.input),t.input.layerId=L.stamp(t.layer),this._overlaysList.appendChild(e),e},collapse:function(t){return"SELECT"===t.target.tagName||t.relatedTarget&&t.relatedTarget.parentElement&&("mapml-contextmenu mapml-layer-menu"===t.relatedTarget.className||"mapml-contextmenu mapml-layer-menu"===t.relatedTarget.parentElement.className)||this._map&&"block"===this._map.contextMenu._layerMenu.style.display||(L.DomUtil.removeClass(this._container,"leaflet-control-layers-expanded"),"touch"===t.originalEvent?.pointerType&&(this._container._isExpanded=!1)),this},_preventDefaultContextMenu:function(t){var e=this._map.mouseEventToLatLng(t),o=this._map.mouseEventToContainerPoint(t);t.preventDefault(),this._container._isExpanded||"touch"!==t.pointerType?this._map.fire("contextmenu",{originalEvent:t,containerPoint:o,latlng:e}):this._container._isExpanded=!0}}),p=L.FeatureGroup.extend({initialize:function(t,e){var o;L.setOptions(this,e),this.options.static&&(this._container=L.DomUtil.create("div","leaflet-layer",this.options.pane),L.DomUtil.addClass(this._container,"leaflet-pane mapml-vector-container"),L.setOptions(this.options.renderer,{pane:this._container})),this._layers={},this.options.query?(this._mapmlFeatures=t.features||t,this.isVisible=!0,o=M.getNativeVariables(t),this.options.nativeZoom=o.zoom,this.options.nativeCS=o.cs):t?(o=M.getNativeVariables(t),this.addData(t,o.cs,o.zoom)):(this.isVisible=!1,this.options._leafletLayer&&(this._features={},this._staticFeature=!0))},onAdd:function(t){this._map=t,L.FeatureGroup.prototype.onAdd.call(this,t),this._staticFeature&&(this._resetFeatures(),this.options._leafletLayer._map._addZoomLimit(this)),this._mapmlFeatures&&t.on("featurepagination",this.showPaginationFeature,this)},onRemove:function(t){this._mapmlFeatures&&(t.off("featurepagination",this.showPaginationFeature,this),delete this._mapmlFeatures,L.DomUtil.remove(this._container)),L.FeatureGroup.prototype.onRemove.call(this,t),this._map.featureIndex.cleanIndex()},removeLayer:function(t){L.FeatureGroup.prototype.removeLayer.call(this,t),delete this._layers[t._leaflet_id]},getEvents:function(){return this._staticFeature?{moveend:this._handleMoveEnd,zoomend:this._handleZoomEnd}:{}},showPaginationFeature:function(o){if(this.options.query&&this._mapmlFeatures[o.i]){let e=this._mapmlFeatures[o.i];if("featurepagination"===o.type?e._extentEl.shadowRoot.querySelector("map-feature")?.remove():e._extentEl.shadowRoot.replaceChildren(),this.clearLayers(),e._featureGroup=this.addData(e,this.options.nativeCS,this.options.nativeZoom),o.meta)for(let t=0;t=this.zoomBounds.minZoom);this.isVisible=e&&this._layers&&this.layerBounds&&this.layerBounds.overlaps(M.pixelToPCRSBounds(this._map.getPixelBounds(),t,this._map.options.projection)),this._removeCSS()},_handleZoomEnd:function(t){this.zoomBounds&&this._resetFeatures()},_resetFeatures:function(){this._map&&this._map.featureIndex.cleanIndex();let i=this._map||this.options._leafletLayer._map;if(this._features)for(var n in this._features)for(let o=0;o=this.options.minZoom&&this.extentBounds.overlaps(o),this.isVisible&&this._parentOnMoveEnd()},createTile:function(e){let o=document.createElement("DIV"),i=this.getTileSize();if(L.DomUtil.addClass(o,"mapml-tile-group"),L.DomUtil.addClass(o,"leaflet-tile"),this._template.linkEl.dispatchEvent(new CustomEvent("tileloadstart",{detail:{x:e.x,y:e.y,zoom:e.z,appendTile:t=>{o.appendChild(t)}}})),this._template.type.startsWith("image/")){let t=L.TileLayer.prototype.createTile.call(this,e,function(){});t.width=i.x,t.height=i.y,o.appendChild(t)}else this._url.includes(M.BLANK_TT_TREF)||this._fetchTile(e,o);return o},_mapmlTileReady:function(t){L.DomUtil.addClass(t,"leaflet-tile-loaded")},getPane:function(){return this.options.pane},_fetchTile:function(e,o){fetch(this.getTileUrl(e),{redirect:"follow"}).then(function(t){return 200<=t.status&&t.status<300?Promise.resolve(t):(console.log("Looks like there was a problem. Status Code: "+t.status),Promise.reject(t))}).then(function(t){return t.text()}).then(t=>{return(new DOMParser).parseFromString(t,"application/xml")}).then(t=>{this._createFeatures(t,e,o),this._mapmlTileReady(o)}).catch(t=>{console.log("Error Creating Tile")})},_createFeatures:function(t,e,o){var i;t.querySelector("map-link[rel=stylesheet],map-style")&&(i=t.querySelector("map-base")&&t.querySelector("map-base").hasAttribute("href")?new URL(t.querySelector("map-base").getAttribute("href")).href:t.URL,M._parseStylesheetAsHTML(t,i,o));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;var u,m=M.featureLayer(t,{projection:this._map.options.projection,static:!1,layerBounds:this.extentBounds,zoomBounds:this.zoomBounds,interactive:!1});for(u in m._layers)for(var c in m._layers[u]._layers){let t=m._layers[u]._layers[c];M.FeatureRenderer.prototype._initPath(t,!1),t._project(this._map,L.point([s,l]),e.z),M.FeatureRenderer.prototype._addPath(t,a,!1),M.FeatureRenderer.prototype._updateFeature(t)}n.setAttribute("width",r.toString()),n.setAttribute("height",r.toString()),n.appendChild(a),o.appendChild(n)},getTileUrl:function(t){if(t.z>=this._template.tilematrix.bounds.length||!this._template.tilematrix.bounds[t.z].contains(t))return"";var e,o={},i=this._template.linkEl,n=i.zoomInput;for(e in o[this._template.tilematrix.col.name]=t.x,o[this._template.tilematrix.row.name]=t.y,n&&i.hasAttribute("tref")&&i.getAttribute("tref").includes(`{${n.getAttribute("name")}}`)&&(o[this._template.zoom.name]=this._getZoomForUrl()),o[this._template.pcrs.easting.left]=this._tileMatrixToPCRSPosition(t,"top-left").x,o[this._template.pcrs.easting.right]=this._tileMatrixToPCRSPosition(t,"top-right").x,o[this._template.pcrs.northing.top]=this._tileMatrixToPCRSPosition(t,"top-left").y,o[this._template.pcrs.northing.bottom]=this._tileMatrixToPCRSPosition(t,"bottom-left").y,this._template.tile)["row","col","zoom","left","right","top","bottom"].indexOf(e)<0&&(o[e]=this._template.tile[e]);return this._map&&!this._map.options.crs.infinite&&(t=this._globalTileRange.max.y-t.y,this.options.tms&&(o[this._template.tilematrix.row.name]=t)),o.r=this.options.detectRetina&&L.Browser.retina&&0=e.min&&Number.parseInt(_,10)<=e.max?e.value=Number.parseInt(_,10):e.value=e.max,!isNaN(Number.parseInt(y,10))&&Number.parseInt(y,10)>=e.min&&Number.parseInt(y,10)<=e.max&&(e.min=Number.parseInt(y,10)),!isNaN(Number.parseInt(f,10))&&Number.parseInt(f,10)>=e.min&&Number.parseInt(f,10)<=e.max&&(e.max=Number.parseInt(f,10)),t.zoom=e;else if(d){const A=r[l].htmlselect;t.tile[p]=function(){return A.value}}else{const I=r[l];t.tile[p]=function(){return I.getAttribute("value")}}}function g(t,e){return b.transform(t,v(e)).divideBy(x).floor()}var b=this.options.crs.transformation,x=this.options.crs.options.crs.tile.bounds.max.x,v=L.bind(this.options.crs.scale,this.options.crs);o&&i?(t.pcrs={},t.pcrs.bounds=L.bounds([o.min,i.min],[o.max,i.max]),t.pcrs.easting=o,t.pcrs.northing=i):a&&n&&!isNaN(e.value)?(t.pcrs||(t.pcrs={},t.pcrs.easting="",t.pcrs.northing=""),t.pcrs.bounds=M.boundsToPCRSBounds(L.bounds(L.point([a.min,n.min]),L.point([a.max,n.max])),e.value,this.options.crs,M.axisToCS("column")),t.tilematrix={},t.tilematrix.col=a,t.tilematrix.row=n):console.log("Unable to determine bounds for tile template: "+t.template),t.tilematrix||(t.tilematrix={},t.tilematrix.col={},t.tilematrix.row={}),t.tilematrix.bounds=[];for(var C=t.pcrs.bounds,E=t.zoom?t.zoom.min:0,S=t.zoom?t.zoom.max:s.resolutions.length,T=0;T<=S;T++)t.tilematrix.bounds[T]=E<=T?L.bounds(g(C.min,T),g(C.max,T)):L.bounds(L.point([-1,-1]),L.point([-1,-1]))},_clampZoom:function(t){var e=L.GridLayer.prototype._clampZoom.call(this,t);return this._template.step>this.zoomBounds.maxNativeZoom&&(this._template.step=this.zoomBounds.maxNativeZoom),t!==e?t=e:t%this._template.step!=0&&(t=Math.floor(t/this._template.step)*this._template.step),t}}),d=L.Layer.extend({initialize:function(t,e){this._templates=t,L.setOptions(this,e),this._container=L.DomUtil.create("div","leaflet-layer"),this._extentEl=this.options.extentEl,this.changeOpacity(this.options.opacity),L.DomUtil.addClass(this._container,"mapml-templatedlayer-container");for(var o,i=0;i=this.zoomBounds.minZoom&&this.extentBounds.overlaps(i);var a,r,s,l,u,m,c,p,o=this._getfeaturesUrl(n,o);o!==this._url&&(this._features.clearLayers(),this._extentEl.shadowRoot&&(this._extentEl.shadowRoot.innerHTML=""),this._removeCSS(),this.isVisible||n!==t?(r=new Headers({Accept:"text/mapml;q=0.9,application/geo+json;q=0.8"}),s=new DOMParser,l=this._features,u=this._extentEl,m=this._map,p=function(i,n){return fetch(i,{redirect:"follow",headers:r}).then(function(t){return t.text()}).then(function(t){a=s.parseFromString(t,"application/xml");var e=new URL(a.querySelector("map-base")?a.querySelector("map-base").getAttribute("href"):i).href;i=(i=a.querySelector("map-link[rel=next]")?a.querySelector("map-link[rel=next]").getAttribute("href"):null)?new URL(i,e).href:null;var o,t=u._nativeZoom=a.querySelector("map-meta[name=zoom]")&&+M._metaContentToObject(a.querySelector("map-meta[name=zoom]").getAttribute("content")).value||0,e=u._nativeCS=a.querySelector("map-meta[name=cs]")&&M._metaContentToObject(a.querySelector("map-meta[name=cs]").getAttribute("content")).content||"GCRS";l.addData(a,e,t);for(o of a.querySelector("map-body").children)u.shadowRoot.append(o._DOMnode),o._DOMnode._extentEl=u;if(i&&--n)return p(i,n)})},(c=this)._url=o,p(o,10).then(function(){m.addLayer(l),m.fire("templatedfeatureslayeradd"),M.TemplatedFeaturesLayer.prototype._updateTabIndex(c)}).catch(function(t){console.log(t)})):this._url="")},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},_updateTabIndex:function(t){var o,i=t||this;for(o in i._features._layers){let e=i._features._layers[o];if(e._path&&("M0 0"!==e._path.getAttribute("d")?e._path.setAttribute("tabindex",0):e._path.removeAttribute("tabindex"),0===e._path.childElementCount)){let t=document.createElement("title");t.innerText="Feature",e._path.appendChild(t)}}},_updateZIndex:function(){this._container&&void 0!==this.options.zIndex&&null!==this.options.zIndex&&(this._container.style.zIndex=this.options.zIndex)},_getfeaturesUrl:function(t,e){void 0===t&&(t=this._map.getZoom()),void 0===e&&(e=this._map.getPixelBounds());var o,i={};for(o in this.options.feature.zoom&&(i[this.options.feature.zoom]=t),this.options.feature.width&&(i[this.options.feature.width]=this._map.getSize().x),this.options.feature.height&&(i[this.options.feature.height]=this._map.getSize().y),this.options.feature.bottom&&(i[this.options.feature.bottom]=this._TCRSToPCRS(e.max,t).y),this.options.feature.left&&(i[this.options.feature.left]=this._TCRSToPCRS(e.min,t).x),this.options.feature.top&&(i[this.options.feature.top]=this._TCRSToPCRS(e.min,t).y),this.options.feature.right&&(i[this.options.feature.right]=this._TCRSToPCRS(e.max,t).x),this.options.feature)["width","height","left","right","top","bottom","zoom"].indexOf(o)<0&&(i[o]=this.options.feature[o]);return L.Util.template(this._template.template,i)},_TCRSToPCRS:function(t,e){var o=this._map.options.crs;return o.transformation.untransform(t,o.scale(e))},_setUpFeaturesTemplateVars:function(t){var e={feature:{}},o=t.values;e.feature.hidden=[];for(var i=0;i=this.zoomBounds.minZoom&&this.extentBounds.overlaps(o),this.isVisible?(o=(a=this._map).getPixelBounds().min.subtract(a.getPixelOrigin()),this._addImage(a.getPixelBounds(),e,o),this._pixelOrigins[e]=a.getPixelOrigin()):this._clearLayer())},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(t){L.DomUtil.remove(this._container),this._clearLayer(),t._removeZoomLimit(this)},getImageUrl:function(t,e){var o,i={};for(o in i[this.options.extent.width]=this._map.getSize().x,i[this.options.extent.height]=this._map.getSize().y,i[this.options.extent.bottom]=this._TCRSToPCRS(t.max,e).y,i[this.options.extent.left]=this._TCRSToPCRS(t.min,e).x,i[this.options.extent.top]=this._TCRSToPCRS(t.min,e).y,i[this.options.extent.right]=this._TCRSToPCRS(t.max,e).x,this.options.extent)["width","height","left","right","top","bottom"].indexOf(o)<0&&(i[o]=this.options.extent[o]);return L.Util.template(this._template.template,i)},_TCRSToPCRS:function(t,e){var o=this._map.options.crs;return o.transformation.untransform(t,o.scale(e))},_setUpExtentTemplateVars:function(t){for(var e={extent:{}},o=t.values,i=0;i{if("_templatedLayer"===t&&l.length){let e=s.maxZoom,o=s.minZoom,i=s.maxNativeZoom,n=s.minNativeZoom;for(let t=0;t{var o=e[0].attributes.units.value;let i=!0;for(let t=0;t'+e+"");L.setOptions(m,{attribution:e});var e=l.querySelector("map-link[rel=legend]");e&&(m._legendUrl=e.getAttribute("href"));m._map&&m._map.hasLayer(m)&&m._map.attributionControl.addAttribution(m.getAttribution())}(),l.querySelector("map-title")?(m._title=l.querySelector("map-title").textContent.trim(),m._titleIsReadOnly=!0):l instanceof Element&&l.hasAttribute("label")&&(m._title=l.getAttribute("label").trim()),function(){var t=l.querySelector("map-link[rel=zoomin]"),e=l.querySelector("map-link[rel=zoomout]");t&&(m._properties.zoomin=new URL(t.getAttribute("href"),u).href);e&&(m._properties.zoomout=new URL(e.getAttribute("href"),u).href)}(),m._properties.crs&&function(){if(l.querySelector("map-tile")){var t=document.createElement("map-tiles"),e=l.querySelector("map-meta[name=zoom][content]")||l.querySelector("map-input[type=zoom][value]");t.setAttribute("zoom",e&&e.getAttribute("content")||e&&e.getAttribute("value")||"0");for(var o=l.getElementsByTagName("map-tile"),i=0;i{L.DomEvent.stop(t),a.featureIndex._sortIndex(),a.closePopup(),a._container.focus()},n);let s=L.DomUtil.create("button","mapml-popup-button",t);s.type="button",s.title="Previous Feature",s.innerHTML="",L.DomEvent.on(s,"click",e._previousFeature,n);let l=L.DomUtil.create("p","mapml-feature-count",t),u=this._totalFeatureCount||1;l.innerText=n._count+1+"/"+u;let m=L.DomUtil.create("button","mapml-popup-button",t);m.type="button",m.title="Next Feature",m.innerHTML="",L.DomEvent.on(m,"click",e._nextFeature,n);let c=L.DomUtil.create("button","mapml-popup-button",t);c.type="button",c.title="Focus Controls",c.innerHTML="",L.DomEvent.on(c,"click",t=>{a.featureIndex._sortIndex(),a.featureIndex.currentIndex=a.featureIndex.inBoundFeatures.length-1,a.featureIndex.inBoundFeatures[0].path.setAttribute("tabindex",-1),a.featureIndex.inBoundFeatures[a.featureIndex.currentIndex].path.setAttribute("tabindex",0),L.DomEvent.stop(t),a.closePopup(),a._controlContainer.querySelector("A:not([hidden])").focus()},n);var p=L.DomUtil.create("hr","mapml-popup-divider");function h(t){let e=t.originalEvent.path||t.originalEvent.composedPath();var o=9===t.originalEvent.keyCode,i=t.originalEvent.shiftKey;(e[0].classList.contains("leaflet-popup-close-button")&&o&&!i||27===t.originalEvent.keyCode||e[0].classList.contains("leaflet-popup-close-button")&&13===t.originalEvent.keyCode||e[0].classList.contains("mapml-popup-content")&&o&&i||e[0]===n._content.querySelector("a")&&o&&i)&&setTimeout(()=>{a.closePopup(n),r.focus(),L.DomEvent.stop(t)},0)}function d(t){let e=t.originalEvent.path||t.originalEvent.composedPath();var o=9===t.originalEvent.keyCode,i=t.originalEvent.shiftKey;13===t.originalEvent.keyCode&&e[0].classList.contains("leaflet-popup-close-button")||27===t.originalEvent.keyCode?(L.DomEvent.stopPropagation(t),a.closePopup(n),a._container.focus(),27!==t.originalEvent.keyCode&&(a._popupClosed=!0)):o&&e[0].classList.contains("leaflet-popup-close-button")?a.closePopup(n):(e[0].classList.contains("mapml-popup-content")&&o&&i||e[0]===n._content.querySelector("a")&&o&&i)&&(a.closePopup(n),setTimeout(()=>{L.DomEvent.stop(t),a._container.focus()},0))}function _(t){let n=this._content,a=t?t.currFeature:this._source._groupLayer._featureEl;n.querySelector("a.mapml-zoom-link")&&n.querySelector("a.mapml-zoom-link").remove(),a.querySelector("map-geometry")&&a.whenReady().then(()=>{var t=a.extent.topLeft.gcrs,e=a.extent.bottomRight.gcrs,e=L.latLngBounds(L.latLng(t.horizontal,t.vertical),L.latLng(e.horizontal,e.vertical)).getCenter(!0);let o=document.createElement("a");o.href=`#${a.getMaxZoom()},${e.lng},`+e.lat,o.innerHTML=""+M.options.locale.popupZoom,o.className="mapml-zoom-link",o.onclick=o.onkeydown=function(t){(t instanceof MouseEvent||13===t.keyCode)&&(t.preventDefault(),a.zoomTo(),a._map.closePopup(),a._map.getContainer().focus())};let i=n.querySelector(".mapml-zoom-link");i&&i.remove(),n.insertBefore(o,n.querySelector("hr.mapml-popup-divider"))})}n._navigationBar=t,n._content.appendChild(p),n._content.appendChild(t),o.focus(),r&&!M.options.featureIndexOverlayOption?(r.setAttribute("aria-expanded","true"),a.on("keydown",h)):a.on("keydown",d),a.on("popupclose",function t(e){e.popup===n&&(a.off("keydown",h),a.off("keydown",d),a.off("popupopen",_),a.off("popupclose",t),r&&r.setAttribute("aria-expanded","false"))})}}),b=L.Layer.extend({onAdd:function(t){var e=t.getSize();(400tile: i: ${Math.trunc(a)}, j: ${Math.trunc(r)} @@ -41,6 +41,6 @@ `,u+=`map: i:${Math.trunc(o.containerPoint.x)}, j:${Math.trunc(o.containerPoint.y)} `,u+=`tcrs: x:${Math.trunc(i.x)}, y:${Math.trunc(i.y)} `,u+=`pcrs: easting:${l.x.toFixed(2)}, northing:${l.y.toFixed(2)} -`,u+=`gcrs: lon :${o.latlng.lng.toFixed(6)}, lat:`+o.latlng.lat.toFixed(6),this.contextMenu._copyData(u)},_createItem:function(t,e,o){if(e.spacer)return this._createSeparator(t,o);t=this._insertElementAt("button","mapml-contextmenu-item",t,o),o=this._createEventHandler(t,e.callback,e.context,e.hideOnSelect);return t.innerHTML=""+e.text,t.setAttribute("type","button"),t.classList.add("mapml-button"),e.popup&&(t.setAttribute("aria-haspopup","true"),t.setAttribute("aria-expanded","false"),t.setAttribute("aria-controls","mapml-copy-submenu")),L.DomEvent.on(t,"mouseover",this._onItemMouseOver,this).on(t,"mouseout",this._onItemMouseOut,this).on(t,"mousedown",L.DomEvent.stopPropagation).on(t,"click",o),L.Browser.touch&&L.DomEvent.on(t,this._touchstart,L.DomEvent.stopPropagation),L.Browser.pointer||L.DomEvent.on(t,"click",this._onItemMouseOut,this),{id:L.Util.stamp(t),el:t,callback:o}},_createSeparator:function(t,e){e=this._insertElementAt("div","mapml-contextmenu-separator",t,e);return{id:L.Util.stamp(e),el:e}},_createEventHandler:function(s,l,u,m){let c=this;return m=void 0===m||m,function(t){let e=c._map,o=c._showLocation.containerPoint,i=e.containerPointToLayerPoint(o),n=e.layerPointToLatLng(i),a=c._showLocation.relatedTarget,r={containerPoint:o,layerPoint:i,latlng:n,relatedTarget:a};m&&c._hide(),l&&l.call(u||e,r),c._map.fire("contextmenu.select",{contextmenu:c,el:s})}},_insertElementAt:function(t,e,o,i){let n,a=document.createElement(t);return a.className=e,void 0!==i&&(n=o.children[i]),n?o.insertBefore(a,n):o.appendChild(a),a},_show:function(e){if(!e.originalEvent.target.closest(".mapml-vector-container")){this._mapMenuVisible&&this._hide();let t=(this._clickEvent=e).originalEvent.target;if(t.closest("fieldset")){if(t=t.closest("fieldset"),t=("mapml-layer-extent"===t.className?t.closest("fieldset").parentNode.parentNode.parentNode:t).querySelector("span"),!t.layer.validProjection)return;this._layerClicked=t,this._layerMenu.removeAttribute("hidden"),this._showAtPoint(e.containerPoint,e,this._layerMenu)}else if(t.classList.contains("leaflet-container")||t.classList.contains("mapml-debug-extent")||"path"===t.tagName){var o=this._map.options.mapEl.layers;this._layerClicked=Array.from(o).find(t=>t.checked);let t=e.containerPoint;L.Browser.gecko&&(t=(i=this._map.getContainer(),o=i.getBoundingClientRect().width,i=i.getBoundingClientRect().height,{x:Number.parseInt(o/2),y:Number.parseInt(i/2)})),this._container.removeAttribute("hidden"),this._showAtPoint(t,e,this._container),this._updateCS()}var i;0!==e.originalEvent.button&&-1!==e.originalEvent.button||(this._keyboardEvent=!0,this._layerClicked.className.includes("mapml-layer-item")?(e=document.activeElement,this._elementInFocus=e.shadowRoot.activeElement,this._layerMenuTabs=1,this._layerMenu.firstChild.focus()):this._container.querySelectorAll("button:not([disabled])")[0].focus())}},_showAtPoint:function(t,e,o){var i;this._items.length&&(i=L.extend(e||{},{contextmenu:this}),this._showLocation={containerPoint:t},e&&e.relatedTarget&&(this._showLocation.relatedTarget=e.relatedTarget),this._setPosition(t,o),this._mapMenuVisible||(o.removeAttribute("hidden"),this._mapMenuVisible=!0),this._map.fire("contextmenu.show",i))},_hide:function(){this._mapMenuVisible&&(this._mapMenuVisible=!1,this._container.setAttribute("hidden",""),this._copySubMenu.setAttribute("hidden",""),this._layerMenu.setAttribute("hidden",""),this._map.fire("contextmenu.hide",{contextmenu:this}),setTimeout(()=>this._map._container.focus(),0),this.activeIndex=0,this.isRunned=!1)},_setPosition:function(t,e){var o,i=this._map.getSize(),n=this._getElementSize(e);this._map.options.contextmenuAnchor&&(o=L.point(this._map.options.contextmenuAnchor),t=t.add(o)),(e._leaflet_pos=t).x+n.x>i.x?(e.style.left="auto",e.style.right=Math.min(Math.max(i.x-t.x,0),i.x-n.x-1)+"px"):(e.style.left=Math.max(t.x,0)+"px",e.style.right="auto"),t.y+n.y>i.y?(e.style.top="auto",e.style.bottom=Math.min(Math.max(i.y-t.y,0),i.y-n.y-1)+"px"):(e.style.top=Math.max(t.y,0)+"px",e.style.bottom="auto")},_getElementSize:function(t){let e=this._size;return e&&!this._sizeChanged||(e={},t.style.left="-999999px",t.style.right="auto",e.x=t.offsetWidth,e.y=t.offsetHeight,t.style.left="auto",this._sizeChanged=!1),e},_focusOnLayerControl:function(){this._mapMenuVisible=!1,delete this._layerMenuTabs,this._layerMenu.setAttribute("hidden",""),(this._elementInFocus||this._layerClicked.parentElement.firstChild).focus(),delete this._elementInFocus},_setActiveItem:function(o){if(null===document.activeElement.shadowRoot&&!0===this.noActiveEl&&(this.noActiveEl=!1,this._items[9].el.el.focus()),document.activeElement.shadowRoot.activeElement.innerHTML===this._items[o].el.el.innerHTML){let t=o+1;for(;this._items[t].el.el.disabled;)t++,t>=this._items.length&&(t=0);this._setActiveItem(t)}else if(this.excludedIndices.includes(o)){let t=o+1,e=o-1;for(;this.excludedIndices.includes(t)||this._items[t].el.el.disabled;)t++,t>=this._items.length&&(t=0);for(;this.excludedIndices.includes(e)||this._items[e].el.el.disabled;)e--,e<0&&(e=this._items.length-1);this.activeIndex=this._items.length&&(t=0);this._setActiveItem(t)}else this._setActiveItem(0),this.isRunned=!0;else{let t=0;for(;this._items[t].el.el.disabled;)t++,t>=this._items.length&&(t=0);this._setActiveItem(t)}else this._layerMenu.children[this._menuItems.LYRZOOMTO].focus();else this._layerMenu.children[this._menuItems.LYRCOPY].focus();else this._copySubMenu.children[this._menuItems.CPYMENUEXTENT].focus();else this._copySubMenu.children[this._menuItems.CPYMENULOC].focus();else this._copySubMenu.children[this._menuItems.CPYMENUMAP].focus();else if("ArrowRight"===t.code)null!==document.activeElement.shadowRoot&&document.activeElement.shadowRoot.activeElement.innerHTML===this._items[this._menuItems.CTXCOPY].el.el.innerHTML&&this._copySubMenu.hasAttribute("hidden")?(this._showCopySubMenu(),this._copySubMenu.children[0].focus()):document.activeElement.shadowRoot.activeElement.innerHTML!==this._items[this._menuItems.CTXCOPY].el.el.innerHTML||this._copySubMenu.hasAttribute("hidden")||this._copySubMenu.children[0].focus();else if("ArrowLeft"===t.code)this._copySubMenu.hasAttribute("hidden")||null===document.activeElement.shadowRoot||document.activeElement.shadowRoot.activeElement.innerHTML!==this._copySubMenu.children[this._menuItems.CPYMENUMAP].innerHTML&&document.activeElement.shadowRoot.activeElement.innerHTML!==this._copySubMenu.children[this._menuItems.CPYMENUEXTENT].innerHTML&&document.activeElement.shadowRoot.activeElement.innerHTML!==this._copySubMenu.children[this._menuItems.CPYMENULOC].innerHTML||(this._copySubMenu.setAttribute("hidden",""),this._setActiveItem(this._menuItems.CTXCOPY));else if("Escape"===t.code){if(this._layerMenuTabs)return L.DomEvent.stop(t),void this._focusOnLayerControl();null===document.activeElement.shadowRoot||this._copySubMenu.hasAttribute("hidden")?this._hide():document.activeElement.shadowRoot.activeElement.innerHTML!==this._copySubMenu.children[this._menuItems.CPYMENUMAP].innerHTML&&document.activeElement.shadowRoot.activeElement.innerHTML!==this._copySubMenu.children[this._menuItems.CPYMENUEXTENT].innerHTML&&document.activeElement.shadowRoot.activeElement.innerHTML!==this._copySubMenu.children[this._menuItems.CPYMENULOC].innerHTML||(this._copySubMenu.setAttribute("hidden",""),this._setActiveItem(this._menuItems.CTXCOPY))}else"KeyC"!==t.code&&document.activeElement.shadowRoot.activeElement.innerHTML!==this._items[this._menuItems.CTXCOPY].el.el.innerHTML&&this._hide();switch(t.code){case"Enter":document.activeElement.shadowRoot.activeElement.innerHTML===this._items[this._menuItems.CTXCOPY].el.el.innerHTML?(this._copyCoords({latlng:this._map.getCenter()}),this._copySubMenu.firstChild.focus()):this._map._container.parentNode.activeElement.parentNode.classList.contains("mapml-contextmenu")&&this._map._container.parentNode.activeElement.click();break;case"Space":this._map._container.parentNode.activeElement.parentNode.classList.contains("mapml-contextmenu")&&this._map._container.parentNode.activeElement.click();break;case"KeyC":this._copyCoords({latlng:this._map.getCenter()}),this._copySubMenu.firstChild.focus();break;case"KeyD":this._toggleDebug(t);break;case"KeyM":this._copyMapML(t);break;case"KeyL":this._layerClicked.className.includes("mapml-layer-item")&&this._copyLayer(t);break;case"KeyF":this._toggleFullScreen(t);break;case"KeyP":this._paste(t);break;case"KeyT":this._toggleControls(t);break;case"KeyV":this._viewSource(t);break;case"KeyZ":this._layerClicked.className.includes("mapml-layer-item")&&this._zoomToLayer(t)}}},_showCopySubMenu:function(t){let e=this._map.getSize(),o=this._clickEvent,i=this._copySubMenu,n=this._items[5].el.el;n.setAttribute("aria-expanded","true"),i.removeAttribute("hidden");var a=this._container.offsetWidth,r=(this._container.offsetHeight,i.offsetWidth);o.containerPoint.x+a+r>e.x?(i.style.left="auto",i.style.right=a+"px"):(i.style.left=a+"px",i.style.right="auto"),i.style.top="78px",i.style.bottom="auto"},_hideCopySubMenu:function(t){if(t.relatedTarget&&t.relatedTarget.parentElement&&!t.relatedTarget.parentElement.classList.contains("mapml-submenu")&&!t.relatedTarget.classList.contains("mapml-submenu")){let t=this._copySubMenu,e=this._items[4].el.el;e.setAttribute("aria-expanded","false"),t.setAttribute("hidden",""),this.noActiveEl=!0}},_onItemMouseOver:function(t){L.DomUtil.addClass(t.target||t.srcElement,"over"),t.srcElement.innerText===M.options.locale.cmCopyCoords+" (C)"&&this._showCopySubMenu(t)},_onItemMouseOut:function(t){L.DomUtil.removeClass(t.target||t.srcElement,"over"),this._hideCopySubMenu(t)},toggleContextMenuItem:function(t,e){t=t.toUpperCase(),"disabled"===e?"CONTROLS"===t?this._items[8].el.el.disabled=!0:"BACK"===t?this._items[0].el.el.disabled=!0:"FORWARD"===t?this._items[1].el.el.disabled=!0:"RELOAD"===t&&(this._items[2].el.el.disabled=!0):"enabled"===e&&("CONTROLS"===t?this._items[8].el.el.disabled=!1:"BACK"===t?this._items[0].el.el.disabled=!1:"FORWARD"===t?this._items[1].el.el.disabled=!1:"RELOAD"===t&&(this._items[2].el.el.disabled=!1))},setViewFullScreenInnerHTML:function(t){"view"===t?this._map.contextMenu._items[3].el.el.innerHTML=M.options.locale.btnFullScreen+" (F)":"exit"===t&&(this._map.contextMenu._items[3].el.el.innerHTML=M.options.locale.btnExitFullScreen+" (F)")}}),w=function(e,o,t){if(!e||!o)return{};let i=[],n=[],a=[],r=[],s=o.options.crs.tile.bounds.max.y;for(let t=0;t{!o.inPlace&&i?e.parentElement.zoomTo(+i.lat,+i.lng,+i.z):o.inPlace||e.zoomTo(),r&&(e.opacity=r),a.getContainer().focus()})}},K=function(t){if(!t)return null;let o=M.FALLBACK_CS,i=t.querySelector("map-meta[name=projection]")&&M._metaContentToObject(t.querySelector("map-meta[name=projection]").getAttribute("content")).content.toUpperCase()||M.FALLBACK_PROJECTION;try{var n=t.querySelector("map-meta[name=extent]")&&M._metaContentToObject(t.querySelector("map-meta[name=extent]").getAttribute("content")),a=n.zoom||0;let e=Object.keys(n);for(let t=0;t';e.insertAdjacentHTML("beforeend",t),e.lastElementChild.whenReady().catch(()=>{e&&e.removeChild(e.lastChild),t=null})}catch(t){if(")|()|()|()|()|()|()|()|()|()|()|()|()|()|()|()|(