diff --git a/test/dist/mapml.js b/test/dist/mapml.js index bad4c27..5c160e9 100644 --- a/test/dist/mapml.js +++ b/test/dist/mapml.js @@ -1390,9 +1390,7 @@ }, onAdd: function () { this._map._addZoomLimit(this); - var mapml, headers = new Headers({'Accept': 'text/mapml'}); - var parser = new DOMParser(), - opacity = this.options.opacity || 1, + var opacity = this.options.opacity || 1, container = this._container, map = this._map; if (!this._features) { @@ -1415,36 +1413,8 @@ } }); } - // this was tricky...recursion alwasy breaks my brain - var features = this._features, - _pullFeatureFeed = function (url, limit) { - return (fetch (url,{redirect: 'follow',headers: headers}) - .then( function (response) {return response.text();}) - .then( function (text) { - mapml = parser.parseFromString(text,"application/xml"); - var base = (new URL(mapml.querySelector('map-base') ? mapml.querySelector('map-base').getAttribute('href') : url)).href; - url = mapml.querySelector('map-link[rel=next]')? mapml.querySelector('map-link[rel=next]').getAttribute('href') : null; - url = url ? (new URL(url, base)).href: null; - let nativeZoom = mapml.querySelector("map-meta[name=zoom]") && - +M.metaContentToObject(mapml.querySelector("map-meta[name=zoom]").getAttribute("content")).value || 0; - let nativeCS = mapml.querySelector("map-meta[name=cs]") && - M.metaContentToObject(mapml.querySelector("map-meta[name=cs]").getAttribute("content")).content || "GCRS"; - features.addData(mapml, nativeCS, nativeZoom); - if (url && --limit) { - return _pullFeatureFeed(url, limit); - } - })); - }; - if(map.getZoom() % this._template.step !== 0) { - this._onMoveEnd(); - return; - } - _pullFeatureFeed(this._getfeaturesUrl(), 10) - .then(function() { - map.addLayer(features); - map.fire('moveend'); // TODO: replace with moveend handler for layer and not entire map - }) - .catch(function (error) { console.log(error);}); + + map.fire('moveend'); // TODO: replace with moveend handler for layer and not entire map }, redraw: function() { this._onMoveEnd(); diff --git a/test/dist/mapml.min.js b/test/dist/mapml.min.js index 821073e..c98a5fa 100644 --- a/test/dist/mapml.min.js +++ b/test/dist/mapml.min.js @@ -1,6 +1,6 @@ -/*! @maps4html/web-map-custom-element 23-06-2022 */ +/*! @maps4html/web-map-custom-element 24-06-2022 */ -!function(){"use strict";function t(t){return new i(t)}function e(t,e){return new o(t,e)}var i=L.GridLayer.extend({initialize:function(t){this.zoomBounds=this._getZoomBounds(t.tileContainer,t.maxZoomBound),L.extend(t,this.zoomBounds),L.setOptions(this,t),this._groups=this._groupTiles(this.options.tileContainer.getElementsByTagName("map-tile"))},onAdd:function(){this._bounds=this._getLayerBounds(this._groups,this._map.options.projection),this.layerBounds=this._bounds[Object.keys(this._bounds)[0]];for(var t of Object.keys(this._bounds))this.layerBounds.extend(this._bounds[t].min),this.layerBounds.extend(this._bounds[t].max);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 i=e;i=i>this.options.maxNativeZoom?this.options.maxNativeZoom:i,i=i=this.zoomBounds.minZoom&&this._bounds[i]&&this._bounds[i].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 i=this._groups[this._tileCoordsToKey(t)]||[],o=document.createElement("map-tile"),n=this.getTileSize();o.setAttribute("col",t.x),o.setAttribute("row",t.y),o.setAttribute("zoom",t.z);for(let e=0;ee.options.zIndex?1:0}},initialize:function(t,e){for(var i in L.setOptions(this,e),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,t)this._addLayer(t[i],i,!0)},onAdd:function(){return this._initLayout(),this._map.on("validate",this._validateInput,this),L.DomEvent.on(this.options.mapEl,"layerchange",this._validateInput,this),L.DomEvent.on(this._container,"keydown",this._focusFirstLayer,this._container),this._update(),this._layers.length<1&&!this._map._showControls?this._container.setAttribute("hidden",""):this._map._showControls=!0,this._container},onRemove:function(t){t.off("validate",this._validateInput,this),L.DomEvent.off(this._container,"keydown",this._focusFirstLayer,this._container);for(var e=0;ee.focus(),0)},_withinZoomBounds:function(t,e){return e.min<=t&&t<=e.max},_addItem:function(t){var e=t.layer.getLayerUserControlsHTML();return t.input=e.querySelector("input"),this._layerControlInputs.push(t.input),t.input.layerId=L.stamp(t.layer),L.DomEvent.on(t.input,"click",this._onInputClick,this),t.layer.on("extentload",this._validateInput,this),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"),this}});const w="OSMTILE",d="TILEMATRIX",B="mapmltemplatedtileplaceholder";function n(t,e){return new h(t,e)}function a(t,e){return new _(t,e)}function s(t,e){return new y(t,e)}function r(t,e){return new x(t,e)}function l(t,e){return new g(t,e)}function m(t,e,i,o,n,a){return new f(t,e,i,o,n,a)}function u(t,e,i){return t||e?new b(t,e,i):null}function p(){return new v}function c(t){return new J(t)}var h=L.FeatureGroup.extend({initialize:function(t,e){var i;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,i=this._getNativeVariables(t),this.options.nativeZoom=i.zoom,this.options.nativeCS=i.cs),t&&!this.options.query&&(i=this._getNativeVariables(t),!t.querySelector("map-extent")&&t.querySelector("map-feature")&&this.options.static&&(this._features={},this._staticFeature=!0,this.isVisible=!0,this.zoomBounds=this._getZoomBounds(t,i.zoom),this.layerBounds=this._getLayerBounds(t),L.extend(this.options,this.zoomBounds)),this.addData(t,i.cs,i.zoom),this._staticFeature&&(this._resetFeatures(this._clampZoom(this.options._leafletLayer._map.getZoom())),this.options._leafletLayer._map._addZoomLimit(this)))},onAdd:function(t){L.FeatureGroup.prototype.onAdd.call(this,t),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()},getEvents:function(){return this._staticFeature?{moveend:this._handleMoveEnd,zoomend:this._handleZoomEnd}:{}},showPaginationFeature:function(e){if(this.options.query&&this._mapmlFeatures[e.i]){let t=this._mapmlFeatures[e.i];this.clearLayers(),this.addData(t,this.options.nativeCS,this.options.nativeZoom),e.popup._navigationBar.querySelector("p").innerText=e.i+1+"/"+this.options._leafletLayer._totalFeatureCount,e.popup._content.querySelector("iframe").setAttribute("sandbox","allow-same-origin allow-forms"),e.popup._content.querySelector("iframe").srcdoc=t.querySelector("map-properties").innerHTML}},_getNativeVariables:function(t){return{zoom:t.querySelector&&t.querySelector("map-meta[name=zoom]")&&+M.metaContentToObject(t.querySelector("map-meta[name=zoom]").getAttribute("content")).value||0,cs:t.querySelector&&t.querySelector("map-meta[name=cs]")&&M.metaContentToObject(t.querySelector("map-meta[name=cs]").getAttribute("content")).content||"PCRS"}},_handleMoveEnd:function(){var t=this._map.getZoom(),e=t<=this.zoomBounds.maxZoom&&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){var e=this._map.getZoom();e>this.zoomBounds.maxZoom||ethis.zoomBounds.maxZoom||t=this.options.minZoom&&this.extentBounds.overlaps(i),this.isVisible&&this._parentOnMoveEnd()},createTile:function(e){let i=document.createElement("DIV"),o=this.getTileSize();if(L.DomUtil.addClass(i,"mapml-tile-group"),L.DomUtil.addClass(i,"leaflet-tile"),this._template.linkEl.dispatchEvent(new CustomEvent("tileloadstart",{detail:{x:e.x,y:e.y,zoom:e.z,appendTile:t=>{i.appendChild(t)}}})),this._template.type.startsWith("image/")){let t=L.TileLayer.prototype.createTile.call(this,e,function(){});t.width=o.x,t.height=o.y,i.appendChild(t)}else this._url.includes(B)||this._fetchTile(e,i);return i},_mapmlTileReady:function(t){L.DomUtil.addClass(t,"leaflet-tile-loaded")},getPane:function(){return this.options.pane},_fetchTile:function(e,i){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,i),this._mapmlTileReady(i)}).catch(t=>{console.log("Error Creating Tile")})},_createFeatures:function(t,e,i){var o;t.querySelector("map-link[rel=stylesheet],map-style")&&(o=t.querySelector("map-base")&&t.querySelector("map-base").hasAttribute("href")?new URL(t.querySelector("map-base").getAttribute("href")).href:t.URL,M.parseStylesheetAsHTML(t,o,i));let n=L.SVG.create("svg"),a=L.SVG.create("g"),s=this._map.options.crs.options.crs.tile.bounds.max.x,r=e.x*s,l=e.y*s;var m,u=M.mapMlFeatures(t,{projection:this._map.options.projection,static:!1,interactive:!1});for(m in u._layers)for(var p in u._layers[m]._layers){let t=u._layers[m]._layers[p];M.FeatureRenderer.prototype._initPath(t,!1),t._project(this._map,L.point([r,l]),e.z),M.FeatureRenderer.prototype._addPath(t,a,!1),M.FeatureRenderer.prototype._updateFeature(t)}n.setAttribute("width",s.toString()),n.setAttribute("height",s.toString()),n.appendChild(a),i.appendChild(n)},getTileUrl:function(t){if(t.z>=this._template.tilematrix.bounds.length||!this._template.tilematrix.bounds[t.z].contains(t))return"";var e,i={};for(e in i[this._template.tilematrix.col.name]=t.x,i[this._template.tilematrix.row.name]=t.y,i[this._template.zoom.name]=this._getZoomForUrl(),i[this._template.pcrs.easting.left]=this._tileMatrixToPCRSPosition(t,"top-left").x,i[this._template.pcrs.easting.right]=this._tileMatrixToPCRSPosition(t,"top-right").x,i[this._template.pcrs.northing.top]=this._tileMatrixToPCRSPosition(t,"top-left").y,i[this._template.pcrs.northing.bottom]=this._tileMatrixToPCRSPosition(t,"bottom-left").y,i[this._template.tile.server]=this._getSubdomain(t),this._template.tile)["row","col","zoom","left","right","top","bottom"].indexOf(e)<0&&(i[e]=this._template.tile[e]);return this._map&&!this._map.options.crs.infinite&&(t=this._globalTileRange.max.y-t.y,this.options.tms&&(i[this._template.tilematrix.row.name]=t)),i.r=this.options.detectRetina&&L.Browser.retina&&0=e.min&&Number.parseInt(y,10)<=e.max?e.value=Number.parseInt(y,10):e.value=e.max,!isNaN(Number.parseInt(x,10))&&Number.parseInt(x,10)>=e.min&&Number.parseInt(x,10)<=e.max&&(e.min=Number.parseInt(x,10)),!isNaN(Number.parseInt(g,10))&&Number.parseInt(g,10)>=e.min&&Number.parseInt(g,10)<=e.max&&(e.max=Number.parseInt(g,10)),t.zoom=e;else if(d)t.tile.server=c,t.tile.subdomains=s[l].servers.slice();else if(_){const z=s[l].htmlselect;t.tile[c]=function(){return z.value}}else{const I=s[l];t.tile[c]=function(){return I.getAttribute("value")}}}function f(t,e){return b.transform(t,E(e)).divideBy(v).floor()}var b=this.options.crs.transformation,v=this.options.crs.options.crs.tile.bounds.max.x,E=L.bind(this.options.crs.scale,this.options.crs);i&&o?(t.pcrs={},t.pcrs.bounds=L.bounds([i.min,o.min],[i.max,o.max]),t.pcrs.easting=i,t.pcrs.northing=o):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 A=t.pcrs.bounds,C=t.zoom?t.zoom.min:0,S=t.zoom?t.zoom.max:r.resolutions.length,T=0;T<=S;T++)t.tilematrix.bounds[T]=C<=T?L.bounds(f(A.min,T),f(A.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}}),y=L.Layer.extend({initialize:function(t,e){this._templates=t,L.setOptions(this,e),this._container=L.DomUtil.create("div","leaflet-layer",e.pane),this._container.style.opacity=this.options.opacity,L.DomUtil.addClass(this._container,"mapml-templatedlayer-container");for(var i,o=0;o=this.zoomBounds.minZoom&&this.extentBounds.overlaps(i),this._features.clearLayers(),this._removeCSS(),this.isVisible||n!==t?(s=new Headers({Accept:"text/mapml;q=0.9,application/geo+json;q=0.8"}),r=new DOMParser,l=this._features,m=this._map,p=function(i,o){return fetch(i,{redirect:"follow",headers:s}).then(function(t){return t.text()}).then(function(t){a=r.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;t=a.querySelector("map-meta[name=zoom]")&&+M.metaContentToObject(a.querySelector("map-meta[name=zoom]").getAttribute("content")).value||0,e=a.querySelector("map-meta[name=cs]")&&M.metaContentToObject(a.querySelector("map-meta[name=cs]").getAttribute("content")).content||"GCRS";if(l.addData(a,e,t),i&&--o)return p(i,o)})},(u=this)._url=o,p(o,10).then(function(){m.addLayer(l),m.fire("templatedfeatureslayeradd"),M.TemplatedFeaturesLayer.prototype._updateTabIndex(u)}).catch(function(t){console.log(t)})):this._url="")},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},_updateTabIndex:function(t){var i,o=t||this;for(i in o._features._layers){let e=o._features._layers[i];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)},onRemove:function(){this._map.removeLayer(this._features)},_getfeaturesUrl:function(t,e){void 0===t&&(t=this._map.getZoom()),void 0===e&&(e=this._map.getPixelBounds());var i,o={};for(i in this.options.feature.zoom&&(o[this.options.feature.zoom]=t),this.options.feature.width&&(o[this.options.feature.width]=this._map.getSize().x),this.options.feature.height&&(o[this.options.feature.height]=this._map.getSize().y),this.options.feature.bottom&&(o[this.options.feature.bottom]=this._TCRSToPCRS(e.max,t).y),this.options.feature.left&&(o[this.options.feature.left]=this._TCRSToPCRS(e.min,t).x),this.options.feature.top&&(o[this.options.feature.top]=this._TCRSToPCRS(e.min,t).y),this.options.feature.right&&(o[this.options.feature.right]=this._TCRSToPCRS(e.max,t).x),this.options.feature)["width","height","left","right","top","bottom","zoom"].indexOf(i)<0&&(o[i]=this.options.feature[i]);return L.Util.template(this._template.template,o)},_TCRSToPCRS:function(t,e){var i=this._map.options.crs;return i.transformation.untransform(t,i.scale(e))},_setUpFeaturesTemplateVars:function(t){var e={feature:{}},i=t.values;e.feature.hidden=[];for(var o=0;o=this.zoomBounds.minZoom&&this.extentBounds.overlaps(i),this.isVisible?(i=(a=this._map).getPixelBounds().min.subtract(a.getPixelOrigin()),this._addImage(a.getPixelBounds(),e,i),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){this._clearLayer(),t._removeZoomLimit(this),this._container=null},getImageUrl:function(t,e){var i,o={};for(i in o[this.options.extent.width]=this._map.getSize().x,o[this.options.extent.height]=this._map.getSize().y,o[this.options.extent.bottom]=this._TCRSToPCRS(t.max,e).y,o[this.options.extent.left]=this._TCRSToPCRS(t.min,e).x,o[this.options.extent.top]=this._TCRSToPCRS(t.min,e).y,o[this.options.extent.right]=this._TCRSToPCRS(t.max,e).x,this.options.extent)["width","height","left","right","top","bottom"].indexOf(i)<0&&(o[i]=this.options.extent[i]);return L.Util.template(this._template.template,o)},_TCRSToPCRS:function(t,e){var i=this._map.options.crs;return i.transformation.untransform(t,i.scale(e))},_setUpExtentTemplateVars:function(t){for(var e={extent:{}},i=t.values,o=0;o{e.fire("checkdisabled")},0),e.on("popupopen",this._attachSkipButtons,this)}else this.validProjection=!1},_validProjection:function(e){let i=!1;if(this._extent&&this._extent._mapExtents)for(let t=0;t{if(this[t])if("_templatedLayer"===t){for(let e=0;e{let e=!0;t.target.checked=!1,this._extent._mapExtents[i].removed=!0,this._extent._mapExtents[i].checked=!1,this._layerEl.checked&&this._changeExtent(t,this._extent._mapExtents[i]),this._extent._mapExtents[i].extentAnatomy.parentNode.removeChild(this._extent._mapExtents[i].extentAnatomy);for(let t=0;t{!0===n.hidden?(y.setAttribute("aria-expanded",!0),n.hidden=!1):(y.setAttribute("aria-expanded",!1),n.hidden=!0)},this),u.setAttribute("aria-hidden",!0),a.appendChild(s),y.appendChild(u),u.appendChild(r),e.innerText="Opacity",e.id="mapml-layer-item-opacity-"+L.stamp(e),c.setAttribute("type","range"),c.setAttribute("min","0"),c.setAttribute("max","1.0"),c.setAttribute("value",this._extent._mapExtents[i]._templateVars.opacity||"1.0"),c.setAttribute("step","0.1"),c.setAttribute("aria-labelledby","mapml-layer-item-opacity-"+L.stamp(e)),this._extent._mapExtents[i]._templateVars.opacity=this._extent._mapExtents[i]._templateVars.opacity||"1.0",L.DomEvent.on(c,"change",this._changeExtentOpacity,this._extent._mapExtents[i]);a=L.DomUtil.create("span","mapml-layer-item-name",a);return s.defaultChecked=!!this._extent._mapExtents[i],this._extent._mapExtents[i].checked=s.defaultChecked,s.type="checkbox",a.innerHTML=t,L.DomEvent.on(s,"change",t=>{this._changeExtent(t,this._extent._mapExtents[i])}),a.id="mapml-extent-item-name-{"+L.stamp(a)+"}",o.setAttribute("aria-labelledby",a.id),a.extent=this._extent._mapExtents[i],o.onmousedown=e=>{if("input"!==e.target.tagName.toLowerCase()&&"select"!==e.target.tagName.toLowerCase()){e.preventDefault(),e.stopPropagation();let r=o,l=o.parentNode,t=!1,m=e.clientY;document.body.onmousemove=a=>{a.preventDefault();var s=a.clientY-m;if(t=5r.getBoundingClientRect().bottom||l.getBoundingClientRect().bottom{r.setAttribute("aria-grabbed","false"),r.removeAttribute("aria-dropeffect"),r.style.pointerEvents=null,r.style.transform=null;let t=l.children,e=0;for(var i of t){let t=i.querySelector("span").extent;t.setAttribute("data-moving",""),d.insertAdjacentElement("beforeend",t),t.removeAttribute("data-moving"),t.extentZIndex=e,t.templatedLayer.setZIndex(e),e++}l.classList.remove("mapml-draggable"),document.body.onmousemove=document.body.onmouseup=null}}},o},getLayerUserControlsHTML:function(){var i=L.DomUtil.create("fieldset","mapml-layer-item"),t=L.DomUtil.create("input"),e=L.DomUtil.create("span","mapml-layer-item-name"),o=L.DomUtil.create("span"),n=L.DomUtil.create("div","mapml-layer-item-properties",i),a=L.DomUtil.create("div","mapml-layer-item-settings",i),s=L.DomUtil.create("label","mapml-layer-item-toggle",n),r=L.DomUtil.create("div","mapml-layer-item-controls",n),l=L.DomUtil.create("details","mapml-layer-item-opacity mapml-control-layers",a),m=L.DomUtil.create("input"),u=L.DomUtil.create("summary"),p=L.SVG.create("svg"),c=L.SVG.create("path"),n=L.SVG.create("path"),h=L.DomUtil.create("fieldset","mapml-layer-grouped-extents"),d=this._layerEl.parentNode;this.opacityEl=m,this._mapmlLayerItem=i,p.setAttribute("viewBox","0 0 24 24"),p.setAttribute("height","22"),p.setAttribute("width","22"),c.setAttribute("d","M0 0h24v24H0z"),c.setAttribute("fill","none"),n.setAttribute("d","M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"),p.appendChild(c),p.appendChild(n),a.hidden=!0,o.setAttribute("aria-hidden",!0);let _=L.DomUtil.create("button","mapml-layer-item-remove-control",r);_.type="button",_.title="Remove Layer",_.innerHTML="",_.classList.add("mapml-button"),L.DomEvent.on(_,"click",L.DomEvent.stop),L.DomEvent.on(_,"click",t=>{let e=0,i,o;if(o=("MAPML-VIEWER"===d.tagName?d:d.querySelector(".mapml-web-map")).shadowRoot,t.target.closest("fieldset").nextElementSibling&&!t.target.closest("fieldset").nextElementSibling.disbaled)for(i=t.target.closest("fieldset").previousElementSibling;i;)e+=2,i=i.previousElementSibling;else i="link";d.removeChild(t.target.closest("fieldset").querySelector("span").layer._layerEl),i=i?o.querySelector(".leaflet-control-attribution").firstElementChild:i=o.querySelectorAll("input")[e],i.focus()},this);let y=L.DomUtil.create("button","mapml-layer-item-settings-control",r);if(y.type="button",y.title="Layer Settings",y.setAttribute("aria-expanded",!1),y.classList.add("mapml-button"),L.DomEvent.on(y,"click",t=>{!0===a.hidden?(y.setAttribute("aria-expanded",!0),a.hidden=!1):(y.setAttribute("aria-expanded",!1),a.hidden=!0)},this),t.defaultChecked=!!this._map,t.type="checkbox",(e.layer=this)._legendUrl?((r=document.createElement("a")).text=" "+this._title,r.href=this._legendUrl,r.target="_blank",r.draggable=!1,e.appendChild(r)):e.innerHTML=this._title,e.id="mapml-layer-item-name-{"+L.stamp(e)+"}",u.innerText="Opacity",u.id="mapml-layer-item-opacity-"+L.stamp(u),l.appendChild(u),l.appendChild(m),m.setAttribute("type","range"),m.setAttribute("min","0"),m.setAttribute("max","1.0"),m.setAttribute("value",this._container.style.opacity||"1.0"),m.setAttribute("step","0.1"),m.setAttribute("aria-labelledby",u.id),m.value=this._container.style.opacity||"1.0",i.setAttribute("aria-grabbed","false"),i.setAttribute("aria-labelledby",e.id),i.onmousedown=e=>{if("input"!==e.target.tagName.toLowerCase()&&"select"!==e.target.tagName.toLowerCase()){e.preventDefault();let r=i,l=i.parentNode,t=!1,m=e.clientY;document.body.onmousemove=a=>{a.preventDefault();var s=a.clientY-m;if(t=5r.getBoundingClientRect().bottom||l.getBoundingClientRect().bottom{r.setAttribute("aria-grabbed","false"),r.removeAttribute("aria-dropeffect"),r.style.pointerEvents=null,r.style.transform=null;let t=l.children,e=1;for(var i of t){let t=i.querySelector("span").layer._layerEl;t.setAttribute("data-moving",""),d.insertAdjacentElement("beforeend",t),t.removeAttribute("data-moving"),t._layer.setZIndex(e),e++}l.classList.remove("mapml-draggable"),document.body.onmousemove=document.body.onmouseup=null}}},L.DomEvent.on(m,"change",this._changeOpacity,this),s.appendChild(t),s.appendChild(e),y.appendChild(o),o.appendChild(p),this._styles&&a.appendChild(this._styles),this._userInputs){var x=document.createDocumentFragment(),g=this._extent._templateVars;if(g)for(var f=0;f map-option");0===z.length&&S.hasAttribute("value")&&(z=S.getAttribute("value").split(""));for(var I=0;I'+i+""),L.setOptions(e,{attribution:i});t=t.querySelector("map-link[rel=legend]");t&&(e._legendUrl=t.getAttribute("href"))},getQueryTemplates:function(i){if(this._extent&&this._extent._queries){var o=[];if(this._layerEl.checked&&!this._layerEl.hidden&&this._mapmlLayerItem){var e=this._mapmlLayerItem.querySelectorAll(".mapml-layer-item-name");for(let t=0;t{L.DomEvent.stop(t),a.featureIndex._sortIndex(),a.closePopup(),a._container.focus()},n);let l=L.DomUtil.create("button","mapml-popup-button",o);l.type="button",l.title="Previous Feature",l.innerHTML="",L.DomEvent.on(l,"click",e._previousFeature,n);let m=L.DomUtil.create("p","mapml-feature-count",o),u=this._totalFeatureCount||1;m.innerText=n._count+1+"/"+u;let p=L.DomUtil.create("button","mapml-popup-button",o);p.type="button",p.title="Next Feature",p.innerHTML="",L.DomEvent.on(p,"click",e._nextFeature,n);let c=L.DomUtil.create("button","mapml-popup-button",o);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").focus()},n);t=L.DomUtil.create("hr");function h(t){let e=t.originalEvent.path||t.originalEvent.composedPath();var i=9===t.originalEvent.keyCode,o=t.originalEvent.shiftKey;(e[0].classList.contains("leaflet-popup-close-button")&&i&&!o||27===t.originalEvent.keyCode||("Focus Map"===e[0].title||e[0].classList.contains("mapml-popup-content"))&&i&&o)&&setTimeout(()=>{L.DomEvent.stop(t),a.closePopup(n),s.focus()},0)}function d(t){let e=t.originalEvent.path||t.originalEvent.composedPath();var i=9===t.originalEvent.keyCode,o=t.originalEvent.shiftKey;13===t.originalEvent.keyCode&&e[0].classList.contains("leaflet-popup-close-button")||27===t.originalEvent.keyCode?(L.DomEvent.stopPropagation(t),a.closePopup(n),a._container.focus(),27!==t.originalEvent.keyCode&&(a._popupClosed=!0)):i&&e[0].classList.contains("leaflet-popup-close-button")?a.closePopup(n):("Focus Map"===e[0].title||e[0].classList.contains("mapml-popup-content"))&&i&&o&&(a.closePopup(n),setTimeout(()=>{L.DomEvent.stop(t),a._container.focus()},0))}n._navigationBar=o,n._content.appendChild(t),n._content.appendChild(o),i.focus(),s&&!M.options.featureIndexOverlayOption?(s.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("popupclose",t),s&&s.setAttribute("aria-expanded","false"))})}}),v=L.Layer.extend({onAdd:function(t){var e=t.getSize();(400{},t},_handleMoveEnd:function(t){var e=this._map.getZoom();let i=e;i=i>this.options.maxNativeZoom?this.options.maxNativeZoom:i,i=i=this.zoomBounds.minZoom&&this._bounds[i]&&this._bounds[i].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 i=this._groups[this._tileCoordsToKey(t)]||[],o=document.createElement("map-tile"),n=this.getTileSize();o.setAttribute("col",t.x),o.setAttribute("row",t.y),o.setAttribute("zoom",t.z);for(let e=0;ee.options.zIndex?1:0}},initialize:function(t,e){for(var i in L.setOptions(this,e),this._layerControlInputs=[],this._layers=[],this._lastZIndex=0,this._handlingClick=!1,t)this._addLayer(t[i],i,!0)},onAdd:function(){return this._initLayout(),this._map.on("validate",this._validateInput,this),L.DomEvent.on(this.options.mapEl,"layerchange",this._validateInput,this),L.DomEvent.on(this._container,"keydown",this._focusFirstLayer,this._container),this._update(),this._layers.length<1&&!this._map._showControls?this._container.setAttribute("hidden",""):this._map._showControls=!0,this._container},onRemove:function(t){t.off("validate",this._validateInput,this),L.DomEvent.off(this._container,"keydown",this._focusFirstLayer,this._container);for(var e=0;ee.focus(),0)},_withinZoomBounds:function(t,e){return e.min<=t&&t<=e.max},_addItem:function(t){var e=t.layer.getLayerUserControlsHTML();return t.input=e.querySelector("input"),this._layerControlInputs.push(t.input),t.input.layerId=L.stamp(t.layer),L.DomEvent.on(t.input,"click",this._onInputClick,this),t.layer.on("extentload",this._validateInput,this),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"),this}});const B="OSMTILE",d="TILEMATRIX",w="mapmltemplatedtileplaceholder";function n(t,e){return new c(t,e)}function a(t,e){return new _(t,e)}function s(t,e){return new y(t,e)}function r(t,e){return new x(t,e)}function l(t,e){return new g(t,e)}function m(t,e,i,o,n,a){return new f(t,e,i,o,n,a)}function u(t,e,i){return t||e?new b(t,e,i):null}function p(){return new v}function h(t){return new J(t)}var c=L.FeatureGroup.extend({initialize:function(t,e){var i;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,i=this._getNativeVariables(t),this.options.nativeZoom=i.zoom,this.options.nativeCS=i.cs),t&&!this.options.query&&(i=this._getNativeVariables(t),!t.querySelector("map-extent")&&t.querySelector("map-feature")&&this.options.static&&(this._features={},this._staticFeature=!0,this.isVisible=!0,this.zoomBounds=this._getZoomBounds(t,i.zoom),this.layerBounds=this._getLayerBounds(t),L.extend(this.options,this.zoomBounds)),this.addData(t,i.cs,i.zoom),this._staticFeature&&(this._resetFeatures(this._clampZoom(this.options._leafletLayer._map.getZoom())),this.options._leafletLayer._map._addZoomLimit(this)))},onAdd:function(t){L.FeatureGroup.prototype.onAdd.call(this,t),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()},getEvents:function(){return this._staticFeature?{moveend:this._handleMoveEnd,zoomend:this._handleZoomEnd}:{}},showPaginationFeature:function(e){if(this.options.query&&this._mapmlFeatures[e.i]){let t=this._mapmlFeatures[e.i];this.clearLayers(),this.addData(t,this.options.nativeCS,this.options.nativeZoom),e.popup._navigationBar.querySelector("p").innerText=e.i+1+"/"+this.options._leafletLayer._totalFeatureCount,e.popup._content.querySelector("iframe").setAttribute("sandbox","allow-same-origin allow-forms"),e.popup._content.querySelector("iframe").srcdoc=t.querySelector("map-properties").innerHTML}},_getNativeVariables:function(t){return{zoom:t.querySelector&&t.querySelector("map-meta[name=zoom]")&&+M.metaContentToObject(t.querySelector("map-meta[name=zoom]").getAttribute("content")).value||0,cs:t.querySelector&&t.querySelector("map-meta[name=cs]")&&M.metaContentToObject(t.querySelector("map-meta[name=cs]").getAttribute("content")).content||"PCRS"}},_handleMoveEnd:function(){var t=this._map.getZoom(),e=t<=this.zoomBounds.maxZoom&&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){var e=this._map.getZoom();e>this.zoomBounds.maxZoom||ethis.zoomBounds.maxZoom||t=this.options.minZoom&&this.extentBounds.overlaps(i),this.isVisible&&this._parentOnMoveEnd()},createTile:function(e){let i=document.createElement("DIV"),o=this.getTileSize();if(L.DomUtil.addClass(i,"mapml-tile-group"),L.DomUtil.addClass(i,"leaflet-tile"),this._template.linkEl.dispatchEvent(new CustomEvent("tileloadstart",{detail:{x:e.x,y:e.y,zoom:e.z,appendTile:t=>{i.appendChild(t)}}})),this._template.type.startsWith("image/")){let t=L.TileLayer.prototype.createTile.call(this,e,function(){});t.width=o.x,t.height=o.y,i.appendChild(t)}else this._url.includes(w)||this._fetchTile(e,i);return i},_mapmlTileReady:function(t){L.DomUtil.addClass(t,"leaflet-tile-loaded")},getPane:function(){return this.options.pane},_fetchTile:function(e,i){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,i),this._mapmlTileReady(i)}).catch(t=>{console.log("Error Creating Tile")})},_createFeatures:function(t,e,i){var o;t.querySelector("map-link[rel=stylesheet],map-style")&&(o=t.querySelector("map-base")&&t.querySelector("map-base").hasAttribute("href")?new URL(t.querySelector("map-base").getAttribute("href")).href:t.URL,M.parseStylesheetAsHTML(t,o,i));let n=L.SVG.create("svg"),a=L.SVG.create("g"),s=this._map.options.crs.options.crs.tile.bounds.max.x,r=e.x*s,l=e.y*s;var m,u=M.mapMlFeatures(t,{projection:this._map.options.projection,static:!1,interactive:!1});for(m in u._layers)for(var p in u._layers[m]._layers){let t=u._layers[m]._layers[p];M.FeatureRenderer.prototype._initPath(t,!1),t._project(this._map,L.point([r,l]),e.z),M.FeatureRenderer.prototype._addPath(t,a,!1),M.FeatureRenderer.prototype._updateFeature(t)}n.setAttribute("width",s.toString()),n.setAttribute("height",s.toString()),n.appendChild(a),i.appendChild(n)},getTileUrl:function(t){if(t.z>=this._template.tilematrix.bounds.length||!this._template.tilematrix.bounds[t.z].contains(t))return"";var e,i={};for(e in i[this._template.tilematrix.col.name]=t.x,i[this._template.tilematrix.row.name]=t.y,i[this._template.zoom.name]=this._getZoomForUrl(),i[this._template.pcrs.easting.left]=this._tileMatrixToPCRSPosition(t,"top-left").x,i[this._template.pcrs.easting.right]=this._tileMatrixToPCRSPosition(t,"top-right").x,i[this._template.pcrs.northing.top]=this._tileMatrixToPCRSPosition(t,"top-left").y,i[this._template.pcrs.northing.bottom]=this._tileMatrixToPCRSPosition(t,"bottom-left").y,i[this._template.tile.server]=this._getSubdomain(t),this._template.tile)["row","col","zoom","left","right","top","bottom"].indexOf(e)<0&&(i[e]=this._template.tile[e]);return this._map&&!this._map.options.crs.infinite&&(t=this._globalTileRange.max.y-t.y,this.options.tms&&(i[this._template.tilematrix.row.name]=t)),i.r=this.options.detectRetina&&L.Browser.retina&&0=e.min&&Number.parseInt(y,10)<=e.max?e.value=Number.parseInt(y,10):e.value=e.max,!isNaN(Number.parseInt(x,10))&&Number.parseInt(x,10)>=e.min&&Number.parseInt(x,10)<=e.max&&(e.min=Number.parseInt(x,10)),!isNaN(Number.parseInt(g,10))&&Number.parseInt(g,10)>=e.min&&Number.parseInt(g,10)<=e.max&&(e.max=Number.parseInt(g,10)),t.zoom=e;else if(d)t.tile.server=h,t.tile.subdomains=s[l].servers.slice();else if(_){const z=s[l].htmlselect;t.tile[h]=function(){return z.value}}else{const I=s[l];t.tile[h]=function(){return I.getAttribute("value")}}}function f(t,e){return b.transform(t,E(e)).divideBy(v).floor()}var b=this.options.crs.transformation,v=this.options.crs.options.crs.tile.bounds.max.x,E=L.bind(this.options.crs.scale,this.options.crs);i&&o?(t.pcrs={},t.pcrs.bounds=L.bounds([i.min,o.min],[i.max,o.max]),t.pcrs.easting=i,t.pcrs.northing=o):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 A=t.pcrs.bounds,C=t.zoom?t.zoom.min:0,T=t.zoom?t.zoom.max:r.resolutions.length,S=0;S<=T;S++)t.tilematrix.bounds[S]=C<=S?L.bounds(f(A.min,S),f(A.max,S)):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}}),y=L.Layer.extend({initialize:function(t,e){this._templates=t,L.setOptions(this,e),this._container=L.DomUtil.create("div","leaflet-layer",e.pane),this._container.style.opacity=this.options.opacity,L.DomUtil.addClass(this._container,"mapml-templatedlayer-container");for(var i,o=0;o=this.zoomBounds.minZoom&&this.extentBounds.overlaps(i),this._features.clearLayers(),this._removeCSS(),this.isVisible||n!==t?(s=new Headers({Accept:"text/mapml;q=0.9,application/geo+json;q=0.8"}),r=new DOMParser,l=this._features,m=this._map,p=function(i,o){return fetch(i,{redirect:"follow",headers:s}).then(function(t){return t.text()}).then(function(t){a=r.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;t=a.querySelector("map-meta[name=zoom]")&&+M.metaContentToObject(a.querySelector("map-meta[name=zoom]").getAttribute("content")).value||0,e=a.querySelector("map-meta[name=cs]")&&M.metaContentToObject(a.querySelector("map-meta[name=cs]").getAttribute("content")).content||"GCRS";if(l.addData(a,e,t),i&&--o)return p(i,o)})},(u=this)._url=o,p(o,10).then(function(){m.addLayer(l),m.fire("templatedfeatureslayeradd"),M.TemplatedFeaturesLayer.prototype._updateTabIndex(u)}).catch(function(t){console.log(t)})):this._url="")},setZIndex:function(t){return this.options.zIndex=t,this._updateZIndex(),this},_updateTabIndex:function(t){var i,o=t||this;for(i in o._features._layers){let e=o._features._layers[i];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)},onRemove:function(){this._map.removeLayer(this._features)},_getfeaturesUrl:function(t,e){void 0===t&&(t=this._map.getZoom()),void 0===e&&(e=this._map.getPixelBounds());var i,o={};for(i in this.options.feature.zoom&&(o[this.options.feature.zoom]=t),this.options.feature.width&&(o[this.options.feature.width]=this._map.getSize().x),this.options.feature.height&&(o[this.options.feature.height]=this._map.getSize().y),this.options.feature.bottom&&(o[this.options.feature.bottom]=this._TCRSToPCRS(e.max,t).y),this.options.feature.left&&(o[this.options.feature.left]=this._TCRSToPCRS(e.min,t).x),this.options.feature.top&&(o[this.options.feature.top]=this._TCRSToPCRS(e.min,t).y),this.options.feature.right&&(o[this.options.feature.right]=this._TCRSToPCRS(e.max,t).x),this.options.feature)["width","height","left","right","top","bottom","zoom"].indexOf(i)<0&&(o[i]=this.options.feature[i]);return L.Util.template(this._template.template,o)},_TCRSToPCRS:function(t,e){var i=this._map.options.crs;return i.transformation.untransform(t,i.scale(e))},_setUpFeaturesTemplateVars:function(t){var e={feature:{}},i=t.values;e.feature.hidden=[];for(var o=0;o=this.zoomBounds.minZoom&&this.extentBounds.overlaps(i),this.isVisible?(i=(a=this._map).getPixelBounds().min.subtract(a.getPixelOrigin()),this._addImage(a.getPixelBounds(),e,i),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){this._clearLayer(),t._removeZoomLimit(this),this._container=null},getImageUrl:function(t,e){var i,o={};for(i in o[this.options.extent.width]=this._map.getSize().x,o[this.options.extent.height]=this._map.getSize().y,o[this.options.extent.bottom]=this._TCRSToPCRS(t.max,e).y,o[this.options.extent.left]=this._TCRSToPCRS(t.min,e).x,o[this.options.extent.top]=this._TCRSToPCRS(t.min,e).y,o[this.options.extent.right]=this._TCRSToPCRS(t.max,e).x,this.options.extent)["width","height","left","right","top","bottom"].indexOf(i)<0&&(o[i]=this.options.extent[i]);return L.Util.template(this._template.template,o)},_TCRSToPCRS:function(t,e){var i=this._map.options.crs;return i.transformation.untransform(t,i.scale(e))},_setUpExtentTemplateVars:function(t){for(var e={extent:{}},i=t.values,o=0;o{e.fire("checkdisabled")},0),e.on("popupopen",this._attachSkipButtons,this)}else this.validProjection=!1},_validProjection:function(e){let i=!1;if(this._extent&&this._extent._mapExtents)for(let t=0;t{if(this[t])if("_templatedLayer"===t){for(let e=0;e{let e=!0;t.target.checked=!1,this._extent._mapExtents[i].removed=!0,this._extent._mapExtents[i].checked=!1,this._layerEl.checked&&this._changeExtent(t,this._extent._mapExtents[i]),this._extent._mapExtents[i].extentAnatomy.parentNode.removeChild(this._extent._mapExtents[i].extentAnatomy);for(let t=0;t{!0===n.hidden?(y.setAttribute("aria-expanded",!0),n.hidden=!1):(y.setAttribute("aria-expanded",!1),n.hidden=!0)},this),u.setAttribute("aria-hidden",!0),a.appendChild(s),y.appendChild(u),u.appendChild(r),e.innerText="Opacity",e.id="mapml-layer-item-opacity-"+L.stamp(e),h.setAttribute("type","range"),h.setAttribute("min","0"),h.setAttribute("max","1.0"),h.setAttribute("value",this._extent._mapExtents[i]._templateVars.opacity||"1.0"),h.setAttribute("step","0.1"),h.setAttribute("aria-labelledby","mapml-layer-item-opacity-"+L.stamp(e)),this._extent._mapExtents[i]._templateVars.opacity=this._extent._mapExtents[i]._templateVars.opacity||"1.0",L.DomEvent.on(h,"change",this._changeExtentOpacity,this._extent._mapExtents[i]);a=L.DomUtil.create("span","mapml-layer-item-name",a);return s.defaultChecked=!!this._extent._mapExtents[i],this._extent._mapExtents[i].checked=s.defaultChecked,s.type="checkbox",a.innerHTML=t,L.DomEvent.on(s,"change",t=>{this._changeExtent(t,this._extent._mapExtents[i])}),a.id="mapml-extent-item-name-{"+L.stamp(a)+"}",o.setAttribute("aria-labelledby",a.id),a.extent=this._extent._mapExtents[i],o.onmousedown=e=>{if("input"!==e.target.tagName.toLowerCase()&&"select"!==e.target.tagName.toLowerCase()){e.preventDefault(),e.stopPropagation();let r=o,l=o.parentNode,t=!1,m=e.clientY;document.body.onmousemove=a=>{a.preventDefault();var s=a.clientY-m;if(t=5r.getBoundingClientRect().bottom||l.getBoundingClientRect().bottom{r.setAttribute("aria-grabbed","false"),r.removeAttribute("aria-dropeffect"),r.style.pointerEvents=null,r.style.transform=null;let t=l.children,e=0;for(var i of t){let t=i.querySelector("span").extent;t.setAttribute("data-moving",""),d.insertAdjacentElement("beforeend",t),t.removeAttribute("data-moving"),t.extentZIndex=e,t.templatedLayer.setZIndex(e),e++}l.classList.remove("mapml-draggable"),document.body.onmousemove=document.body.onmouseup=null}}},o},getLayerUserControlsHTML:function(){var i=L.DomUtil.create("fieldset","mapml-layer-item"),t=L.DomUtil.create("input"),e=L.DomUtil.create("span","mapml-layer-item-name"),o=L.DomUtil.create("span"),n=L.DomUtil.create("div","mapml-layer-item-properties",i),a=L.DomUtil.create("div","mapml-layer-item-settings",i),s=L.DomUtil.create("label","mapml-layer-item-toggle",n),r=L.DomUtil.create("div","mapml-layer-item-controls",n),l=L.DomUtil.create("details","mapml-layer-item-opacity mapml-control-layers",a),m=L.DomUtil.create("input"),u=L.DomUtil.create("summary"),p=L.SVG.create("svg"),h=L.SVG.create("path"),n=L.SVG.create("path"),c=L.DomUtil.create("fieldset","mapml-layer-grouped-extents"),d=this._layerEl.parentNode;this.opacityEl=m,this._mapmlLayerItem=i,p.setAttribute("viewBox","0 0 24 24"),p.setAttribute("height","22"),p.setAttribute("width","22"),h.setAttribute("d","M0 0h24v24H0z"),h.setAttribute("fill","none"),n.setAttribute("d","M12 8c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"),p.appendChild(h),p.appendChild(n),a.hidden=!0,o.setAttribute("aria-hidden",!0);let _=L.DomUtil.create("button","mapml-layer-item-remove-control",r);_.type="button",_.title="Remove Layer",_.innerHTML="",_.classList.add("mapml-button"),L.DomEvent.on(_,"click",L.DomEvent.stop),L.DomEvent.on(_,"click",t=>{let e=0,i,o;if(o=("MAPML-VIEWER"===d.tagName?d:d.querySelector(".mapml-web-map")).shadowRoot,t.target.closest("fieldset").nextElementSibling&&!t.target.closest("fieldset").nextElementSibling.disbaled)for(i=t.target.closest("fieldset").previousElementSibling;i;)e+=2,i=i.previousElementSibling;else i="link";d.removeChild(t.target.closest("fieldset").querySelector("span").layer._layerEl),i=i?o.querySelector(".leaflet-control-attribution").firstElementChild:i=o.querySelectorAll("input")[e],i.focus()},this);let y=L.DomUtil.create("button","mapml-layer-item-settings-control",r);if(y.type="button",y.title="Layer Settings",y.setAttribute("aria-expanded",!1),y.classList.add("mapml-button"),L.DomEvent.on(y,"click",t=>{!0===a.hidden?(y.setAttribute("aria-expanded",!0),a.hidden=!1):(y.setAttribute("aria-expanded",!1),a.hidden=!0)},this),t.defaultChecked=!!this._map,t.type="checkbox",(e.layer=this)._legendUrl?((r=document.createElement("a")).text=" "+this._title,r.href=this._legendUrl,r.target="_blank",r.draggable=!1,e.appendChild(r)):e.innerHTML=this._title,e.id="mapml-layer-item-name-{"+L.stamp(e)+"}",u.innerText="Opacity",u.id="mapml-layer-item-opacity-"+L.stamp(u),l.appendChild(u),l.appendChild(m),m.setAttribute("type","range"),m.setAttribute("min","0"),m.setAttribute("max","1.0"),m.setAttribute("value",this._container.style.opacity||"1.0"),m.setAttribute("step","0.1"),m.setAttribute("aria-labelledby",u.id),m.value=this._container.style.opacity||"1.0",i.setAttribute("aria-grabbed","false"),i.setAttribute("aria-labelledby",e.id),i.onmousedown=e=>{if("input"!==e.target.tagName.toLowerCase()&&"select"!==e.target.tagName.toLowerCase()){e.preventDefault();let r=i,l=i.parentNode,t=!1,m=e.clientY;document.body.onmousemove=a=>{a.preventDefault();var s=a.clientY-m;if(t=5r.getBoundingClientRect().bottom||l.getBoundingClientRect().bottom{r.setAttribute("aria-grabbed","false"),r.removeAttribute("aria-dropeffect"),r.style.pointerEvents=null,r.style.transform=null;let t=l.children,e=1;for(var i of t){let t=i.querySelector("span").layer._layerEl;t.setAttribute("data-moving",""),d.insertAdjacentElement("beforeend",t),t.removeAttribute("data-moving"),t._layer.setZIndex(e),e++}l.classList.remove("mapml-draggable"),document.body.onmousemove=document.body.onmouseup=null}}},L.DomEvent.on(m,"change",this._changeOpacity,this),s.appendChild(t),s.appendChild(e),y.appendChild(o),o.appendChild(p),this._styles&&a.appendChild(this._styles),this._userInputs){var x=document.createDocumentFragment(),g=this._extent._templateVars;if(g)for(var f=0;f map-option");0===z.length&&T.hasAttribute("value")&&(z=T.getAttribute("value").split(""));for(var I=0;I'+i+""),L.setOptions(e,{attribution:i});t=t.querySelector("map-link[rel=legend]");t&&(e._legendUrl=t.getAttribute("href"))},getQueryTemplates:function(i){if(this._extent&&this._extent._queries){var o=[];if(this._layerEl.checked&&!this._layerEl.hidden&&this._mapmlLayerItem){var e=this._mapmlLayerItem.querySelectorAll(".mapml-layer-item-name");for(let t=0;t{L.DomEvent.stop(t),a.featureIndex._sortIndex(),a.closePopup(),a._container.focus()},n);let l=L.DomUtil.create("button","mapml-popup-button",o);l.type="button",l.title="Previous Feature",l.innerHTML="",L.DomEvent.on(l,"click",e._previousFeature,n);let m=L.DomUtil.create("p","mapml-feature-count",o),u=this._totalFeatureCount||1;m.innerText=n._count+1+"/"+u;let p=L.DomUtil.create("button","mapml-popup-button",o);p.type="button",p.title="Next Feature",p.innerHTML="",L.DomEvent.on(p,"click",e._nextFeature,n);let h=L.DomUtil.create("button","mapml-popup-button",o);h.type="button",h.title="Focus Controls",h.innerHTML="",L.DomEvent.on(h,"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").focus()},n);t=L.DomUtil.create("hr");function c(t){let e=t.originalEvent.path||t.originalEvent.composedPath();var i=9===t.originalEvent.keyCode,o=t.originalEvent.shiftKey;(e[0].classList.contains("leaflet-popup-close-button")&&i&&!o||27===t.originalEvent.keyCode||("Focus Map"===e[0].title||e[0].classList.contains("mapml-popup-content"))&&i&&o)&&setTimeout(()=>{L.DomEvent.stop(t),a.closePopup(n),s.focus()},0)}function d(t){let e=t.originalEvent.path||t.originalEvent.composedPath();var i=9===t.originalEvent.keyCode,o=t.originalEvent.shiftKey;13===t.originalEvent.keyCode&&e[0].classList.contains("leaflet-popup-close-button")||27===t.originalEvent.keyCode?(L.DomEvent.stopPropagation(t),a.closePopup(n),a._container.focus(),27!==t.originalEvent.keyCode&&(a._popupClosed=!0)):i&&e[0].classList.contains("leaflet-popup-close-button")?a.closePopup(n):("Focus Map"===e[0].title||e[0].classList.contains("mapml-popup-content"))&&i&&o&&(a.closePopup(n),setTimeout(()=>{L.DomEvent.stop(t),a._container.focus()},0))}n._navigationBar=o,n._content.appendChild(t),n._content.appendChild(o),i.focus(),s&&!M.options.featureIndexOverlayOption?(s.setAttribute("aria-expanded","true"),a.on("keydown",c)):a.on("keydown",d),a.on("popupclose",function t(e){e.popup===n&&(a.off("keydown",c),a.off("keydown",d),a.off("popupclose",t),s&&s.setAttribute("aria-expanded","false"))})}}),v=L.Layer.extend({onAdd:function(t){var e=t.getSize();(400tile: i: ${Math.trunc(a)}, j: ${Math.trunc(s)} @@ -24,10 +24,10 @@ pcrs: easting: ${o.x.toFixed(2)}, northing: ${o.y.toFixed(2)} - `}}}),A=function(t){return new E(t)},C=L.GridLayer.extend({initialize:function(t){L.setOptions(this,t),L.GridLayer.prototype.initialize.call(this,this._map)},createTile:function(t){let e=L.DomUtil.create("div","mapml-debug-tile");return e.setAttribute("col",t.x),e.setAttribute("row",t.y),e.setAttribute("zoom",t.z),e.innerHTML=["col: "+t.x,"row: "+t.y,"zoom: "+t.z].join(", "),e.style.outline="1px dashed red",e}}),S=function(t){return new C(t)},T=L.LayerGroup.extend({initialize:function(t){L.setOptions(this,t),L.LayerGroup.prototype.initialize.call(this,this._map,t)},onAdd:function(t){t.on("overlayremove",this._mapLayerUpdate,this),t.on("overlayadd",this._mapLayerUpdate,this);var e=t.options.crs.transformation.transform(L.point(0,0),t.options.crs.scale(0));this._centerVector=L.circle(t.options.crs.pointToLatLng(e,0),{radius:250}),this._centerVector.bindTooltip("Projection Center"),this._addBounds(t)},onRemove:function(t){this.clearLayers()},_addBounds:function(t){let e=Object.keys(t._layers),i=t._layers,o=["#FF5733","#8DFF33","#3397FF","#E433FF","#F3FF33"],n=0;this.addLayer(this._centerVector);for(var a of e)if(i[a].layerBounds||i[a].extentBounds){let t;t=i[a].layerBounds?[i[a].layerBounds.min,L.point(i[a].layerBounds.max.x,i[a].layerBounds.min.y),i[a].layerBounds.max,L.point(i[a].layerBounds.min.x,i[a].layerBounds.max.y)]:[i[a].extentBounds.min,L.point(i[a].extentBounds.max.x,i[a].extentBounds.min.y),i[a].extentBounds.max,L.point(i[a].extentBounds.min.x,i[a].extentBounds.max.y)];let e=k(t,{color:o[n%o.length],weight:2,opacity:1,fillOpacity:.01,fill:!0});i[a].options._leafletLayer&&e.bindTooltip(i[a].options._leafletLayer._title,{sticky:!0}),this.addLayer(e),n++}t.totalLayerBounds&&(t=[t.totalLayerBounds.min,L.point(t.totalLayerBounds.max.x,t.totalLayerBounds.min.y),t.totalLayerBounds.max,L.point(t.totalLayerBounds.min.x,t.totalLayerBounds.max.y)],t=k(t,{color:"#808080",weight:5,opacity:.5,fill:!1}),this.addLayer(t))},_mapLayerUpdate:function(t){this.clearLayers(),this._addBounds(t.target)}}),z=function(t){return new T(t)},I=L.Path.extend({options:{className:"mapml-debug-extent"},initialize:function(t,e){this._locations=t,L.setOptions(this,e)},_project:function(){this._rings=[];let e=this._map.options.crs.scale(this._map.getZoom()),i=this._map;for(let t=0;t{!this._map.isFocused||this._map._popupClosed||" "!==t.originalEvent.key&&13!=+t.originalEvent.keyCode?delete this._map._popupClosed:this._map.fire("click",{latlng:this._map.getCenter(),layerPoint:this._map.latLngToLayerPoint(this._map.getCenter()),containerPoint:this._map.latLngToContainerPoint(this._map.getCenter())})},0)},_queryTopLayer:function(t){var e=this._getTopQueryableLayer();e&&(e._mapmlFeatures&&delete e._mapmlFeatures,this._query(t,e))},_query(a,s){function e(t){return l.transformation.untransform(t,l.scale(n))}function i(t){return l.unproject(l.transformation.untransform(t,l.scale(n)),n)}function o(t,e,o){const n=new DOMParser;fetch(L.Util.template(t.template,e),{redirect:"follow"}).then(e=>{if(200<=e.status&&e.status<300)return e.text().then(t=>({contenttype:e.headers.get("Content-Type"),text:t}));throw new Error(e.status)}).then(i=>{if(s._mapmlFeatures||(s._mapmlFeatures=[]),i.contenttype.startsWith("text/mapml")){let t=n.parseFromString(i.text,"application/xml"),e=Array.prototype.slice.call(t.querySelectorAll("map-feature"));e.length&&(s._mapmlFeatures=s._mapmlFeatures.concat(e))}else{var t=""+a.latlng.lng+" "+a.latlng.lat+"",t=n.parseFromString(""+i.text+""+t+"","text/html").querySelector("map-feature");s._mapmlFeatures.push(t)}if(o)return function(t,e){let i=M.mapMlFeatures(t,{renderer:M.featureRenderer(),pane:u,projection:r.options.projection,_leafletLayer:s,query:!0,static:!0});i.addTo(r);let o=L.DomUtil.create("div","mapml-popup-content"),n=L.DomUtil.create("iframe");n.style="border: none",n.srcdoc=t[0].querySelector("map-feature map-properties").innerHTML,n.setAttribute("sandbox","allow-same-origin allow-forms"),o.appendChild(n),s._totalFeatureCount=t.length,s.bindPopup(o,p).openPopup(e),s.on("popupclose",function(){r.removeLayer(i)}),i.showPaginationFeature({i:0,popup:s._popup})}(s._mapmlFeatures,a.latlng)}).catch(t=>{console.log("Looks like there was a problem. Status: "+t.message)})}var n=a.target.getZoom(),r=this._map,l=s._extent.crs,m=r.options.crs.options.crs.tile.bounds.max.x,u=s._container,p={autoClose:!1,autoPan:!0,maxHeight:.5*r.getSize().y-50},c=l.latLngToPoint(a.latlng,n),h=c.divideBy(m).floor(),d=new L.Bounds(c.divideBy(m).floor().multiplyBy(m),c.divideBy(m).ceil().multiplyBy(m)),t=this._map.project(a.latlng),_=this._map.options.crs.scale(this._map.getZoom()),y=this._map.options.crs.transformation.untransform(t,_),x=s.getQueryTemplates(y);for(let t=0;tB)",callback:this._goBack},{text:M.options.locale.cmForward+" (F)",callback:this._goForward},{text:M.options.locale.cmReload+" (R)",callback:this._reload},{spacer:"-"},{text:M.options.locale.cmToggleControls+" (T)",callback:this._toggleControls},{text:M.options.locale.cmCopyCoords+" (C)",callback:this._copyCoords,hideOnSelect:!1,popup:!0,submenu:[{text:"tile",callback:this._copyTile},{text:"tilematrix",callback:this._copyTileMatrix},{spacer:"-"},{text:"map",callback:this._copyMap},{spacer:"-"},{text:"tcrs",callback:this._copyTCRS},{text:"pcrs",callback:this._copyPCRS},{text:"gcrs",callback:this._copyGCRS},{spacer:"-"},{text:M.options.locale.cmCopyAll,callback:this._copyAllCoords}]},{text:M.options.locale.cmToggleDebug+" (D)",callback:this._toggleDebug},{text:M.options.locale.cmCopyMapML+" (M)",callback:this._copyMapML},{text:M.options.locale.cmViewSource+" (V)",callback:this._viewSource}],this._layerItems=[{text:M.options.locale.lmZoomToLayer+" (Z)",callback:this._zoomToLayer},{text:M.options.locale.lmCopyExtent+" (C)",callback:this._copyLayerExtent}],this._mapMenuVisible=!1,this._keyboardEvent=!1,this._container=L.DomUtil.create("div","mapml-contextmenu",t._container),this._container.setAttribute("hidden","");for(let t=0;t<6;t++)this._items[t].el=this._createItem(this._container,this._items[t]);this._coordMenu=L.DomUtil.create("div","mapml-contextmenu mapml-submenu",this._container),this._coordMenu.id="mapml-copy-submenu",this._coordMenu.setAttribute("hidden",""),this._clickEvent=null;for(let t=0;t`;e._copyData(t)},_zoomToLayer:function(t){let e=(t instanceof KeyboardEvent?this._map:this).contextMenu;e._layerClicked.layer._layerEl.focus()},_goForward:function(t){let e=(t instanceof KeyboardEvent?this._map:this).options.mapEl;e.forward()},_goBack:function(t){let e=(t instanceof KeyboardEvent?this._map:this).options.mapEl;e.back()},_reload:function(t){let e=(t instanceof KeyboardEvent?this._map:this).options.mapEl;e.reload()},_toggleControls:function(t){let e=(t instanceof KeyboardEvent?this._map:this).options.mapEl;e._toggleControls()},_copyMapML:function(t){let e=(t instanceof KeyboardEvent?this._map:this).contextMenu,i=(t instanceof KeyboardEvent?this._map:this).options.mapEl;e._copyData(i.outerHTML.replace(/
.*?<\/div>|