diff --git a/Gruntfile.js b/Gruntfile.js index 9914c74f1..4c40f6bf1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -23,22 +23,8 @@ module.exports = function(grunt) { }, dist: { files: { - 'dist/mapml.js': ['<%= rollup.main.dest %>'], - 'dist/web-map.js': ['src/web-map.js'], - 'dist/mapml-viewer.js': ['src/mapml-viewer.js'], - 'dist/map-caption.js': ['src/map-caption.js'], - 'dist/map-feature.js': ['src/map-feature.js'], - 'dist/map-extent.js': ['src/map-extent.js'], - 'dist/map-input.js': ['src/map-input.js'], - 'dist/map-select.js': ['src/map-select.js'], - 'dist/map-link.js': ['src/map-link.js'], - 'dist/map-style.js': ['src/map-style.js'], - 'dist/map-area.js': ['src/map-area.js'], - 'dist/layer.js': ['src/layer.js'], - 'dist/leaflet.js': ['dist/leaflet-src.js', - 'dist/proj4-src.js', - 'dist/proj4leaflet.js', - 'dist/L.Control.Locate.js'] + 'dist/mapml-viewer.js': ['<%= rollup.main.dest %>'], + 'dist/web-map.js': ['<%= rollup.webmap.dest %>'] } } }, @@ -187,7 +173,7 @@ module.exports = function(grunt) { }, clean: { dist: ['dist'], - tidyup: ['dist/leaflet-src.js','dist/proj4-src.js','dist/proj4leaflet.js','dist/L.Control.Locate.js'], + tidyup: ['dist/leaflet-src.js','dist/proj4-src.js','dist/proj4leaflet.js','dist/L.Control.Locate.js','dist/mapmlviewer.js','dist/webmap.js'], experiments: { options: {force: true}, src: ['../experiments/dist'] @@ -207,13 +193,17 @@ module.exports = function(grunt) { }, rollup: { options: { - format: 'iife', + format: 'es', plugins: [nodeResolve()], external: './pmtilesRules.js' }, main: { - dest: 'dist/mapml.js', + dest: 'dist/mapmlviewer.js', src: 'src/mapml/index.js' // Only one source file is permitted + }, + webmap: { + dest: 'dist/webmap.js', + src: 'src/mapml/index-web-map.js' // Only one source file is permitted } }, prettier: { diff --git a/src/layer.js b/src/layer.js index 7db8fdf94..b814f84b0 100644 --- a/src/layer.js +++ b/src/layer.js @@ -1,5 +1,6 @@ -import './leaflet.js'; // a lightly modified version of Leaflet for use as browser module -import './mapml.js'; // modified URI to make the function a property of window scope (possibly a bad thing to do). +import { Util } from './mapml/utils/Util'; +import { MapMLLayer, mapMLLayer } from './mapml/layers/MapMLLayer'; +import { createLayerControlHTML } from './mapml/elementSupport/layers/createLayerControlForLayer'; export class MapLayer extends HTMLElement { static get observedAttributes() { @@ -67,7 +68,7 @@ export class MapLayer extends HTMLElement { } return this._layer ? Object.assign( - M._convertAndFormatPCRS( + Util._convertAndFormatPCRS( this._layer.bounds, M[this.getProjection()], this.getProjection() @@ -165,7 +166,7 @@ export class MapLayer extends HTMLElement { /* jshint ignore:start */ this.#hasConnected = true; /* jshint ignore:end */ - this._createLayerControlHTML = M._createLayerControlHTML.bind(this); + this._createLayerControlHTML = createLayerControlHTML.bind(this); const doConnected = this._onAdd.bind(this); const doRemove = this._onRemove.bind(this); this.parentElement @@ -241,7 +242,7 @@ export class MapLayer extends HTMLElement { this.checkForPreferredContent(); }) .then(() => { - this._layer = M.mapMLLayer(new URL(this.src, base).href, this, { + this._layer = mapMLLayer(new URL(this.src, base).href, this, { projection: this.getProjection(), opacity: this.opacity }); @@ -278,7 +279,7 @@ export class MapLayer extends HTMLElement { this.checkForPreferredContent(); }) .then(() => { - this._layer = M.mapMLLayer(null, this, { + this._layer = mapMLLayer(null, this, { projection: this.getProjection(), opacity: this.opacity }); @@ -398,7 +399,7 @@ export class MapLayer extends HTMLElement { let projection = this.parentElement.projection; if (mapml.querySelector('map-meta[name=projection][content]')) { projection = - M._metaContentToObject( + Util._metaContentToObject( mapml .querySelector('map-meta[name=projection]') .getAttribute('content') @@ -793,13 +794,13 @@ export class MapLayer extends HTMLElement { let maxZoom = extent.zoom.maxZoom, minZoom = extent.zoom.minZoom; - map.setView(center, M.getMaxZoom(layerBounds, map, minZoom, maxZoom), { + map.setView(center, Util.getMaxZoom(layerBounds, map, minZoom, maxZoom), { animate: false }); }); } mapml2geojson(options = {}) { - return M.mapml2geojson(this, options); + return Util.mapml2geojson(this, options); } pasteFeature(feature) { switch (typeof feature) { diff --git a/src/map-area.js b/src/map-area.js index ae436f9d0..747f775a0 100644 --- a/src/map-area.js +++ b/src/map-area.js @@ -1,6 +1,3 @@ -import './leaflet.js'; // a lightly modified version of Leaflet for use as browser module -import './mapml.js'; // refactored URI usage, replaced with URL standard - export class MapArea extends HTMLAreaElement { static get observedAttributes() { return ['coords', 'alt', 'href', 'shape', 'rel', 'type', 'target']; diff --git a/src/map-extent.js b/src/map-extent.js index d4d5979d4..b65a568be 100644 --- a/src/map-extent.js +++ b/src/map-extent.js @@ -1,3 +1,7 @@ +import { Util } from './mapml/utils/Util'; +import { extentLayer } from './mapml/layers/ExtentLayer'; +import { createLayerControlExtentHTML } from './mapml/elementSupport/extents/createLayerControlForExtent'; + /* global M */ export class MapExtent extends HTMLElement { static get observedAttributes() { @@ -54,7 +58,7 @@ export class MapExtent extends HTMLElement { get extent() { const getExtent = (extent) => { return Object.assign( - M._convertAndFormatPCRS( + Util._convertAndFormatPCRS( extent._extentLayer.bounds, M[extent.units], extent.units @@ -121,16 +125,16 @@ export class MapExtent extends HTMLElement { center = map.options.crs.unproject(bounds.getCenter(true)), maxZoom = extent.zoom.maxZoom, minZoom = extent.zoom.minZoom; - map.setView(center, M.getMaxZoom(bounds, map, minZoom, maxZoom), { + map.setView(center, Util.getMaxZoom(bounds, map, minZoom, maxZoom), { animate: false }); } getMapEl() { - return M.getClosest(this, 'mapml-viewer,map[is=web-map]'); + return Util.getClosest(this, 'mapml-viewer,map[is=web-map]'); } getLayerEl() { - return M.getClosest(this, 'layer-'); + return Util.getClosest(this, 'layer-'); } attributeChangedCallback(name, oldValue, newValue) { if (this.#hasConnected /* jshint ignore:line */) { @@ -226,7 +230,7 @@ export class MapExtent extends HTMLElement { // Always call super first in constructor super(); this._createLayerControlExtentHTML = - M._createLayerControlExtentHTML.bind(this); + createLayerControlExtentHTML.bind(this); this._changeHandler = this._handleChange.bind(this); } async connectedCallback() { @@ -257,7 +261,7 @@ export class MapExtent extends HTMLElement { // this._opacity is used to record the current opacity value (with or without updates), // the initial value of this._opacity should be set as opacity attribute value, if exists, or the default value 1.0 this._opacity = this.opacity || 1.0; - this._extentLayer = M.extentLayer({ + this._extentLayer = extentLayer({ opacity: this.opacity, crs: M[this.units], extentZIndex: Array.from( @@ -493,12 +497,12 @@ export class MapExtent extends HTMLElement { // initialize bounds from this.scope > map-meta let bounds = this.querySelector(':scope > map-meta[name=extent][content]') - ? M.getBoundsFromMeta(this) // TODO rewrite this pile of doo doo + ? Util.getBoundsFromMeta(this) // TODO rewrite this pile of doo doo : undefined; // initialize zoom bounds from this.scope > map-meta let zoomBounds = this.querySelector(':scope > map-meta[name=zoom][content]') - ? M.getZoomBoundsFromMeta(this) // TODO rewrite this pile of doo doo + ? Util.getZoomBoundsFromMeta(this) // TODO rewrite this pile of doo doo : undefined; // bounds should be able to be calculated unconditionally, not depend on map-extent.checked diff --git a/src/map-feature.js b/src/map-feature.js index 9a78d6c24..c8c0c4fe1 100644 --- a/src/map-feature.js +++ b/src/map-feature.js @@ -1,3 +1,5 @@ +import { Util } from './mapml/utils/Util'; + export class MapFeature extends HTMLElement { static get observedAttributes() { return ['zoom', 'min', 'max']; @@ -10,7 +12,8 @@ export class MapFeature extends HTMLElement { // for templated or queried features ** native zoom is only used for zoomTo() ** let meta = {}, metaEl = this.getMeta('zoom'); - if (metaEl) meta = M._metaContentToObject(metaEl.getAttribute('content')); + if (metaEl) + meta = Util._metaContentToObject(metaEl.getAttribute('content')); if (this._parentEl.nodeName === 'MAP-LINK') { // nativeZoom = zoom attribute || (sd.map-meta zoom 'value' || 'max') || this._initialZoom return +(this.hasAttribute('zoom') @@ -43,7 +46,8 @@ export class MapFeature extends HTMLElement { // for templated or queried features ** native zoom is only used for zoomTo() ** let meta = {}, metaEl = this.getMeta('zoom'); - if (metaEl) meta = M._metaContentToObject(metaEl.getAttribute('content')); + if (metaEl) + meta = Util._metaContentToObject(metaEl.getAttribute('content')); let projectionMinZoom = 0; if (this._parentEl.nodeName === 'MAP-LINK') { // minZoom = min attribute || sd.map-meta min zoom || map-link minZoom @@ -82,7 +86,8 @@ export class MapFeature extends HTMLElement { // for templated or queried features ** native zoom is only used for zoomTo() ** let meta = {}, metaEl = this.getMeta('zoom'); - if (metaEl) meta = M._metaContentToObject(metaEl.getAttribute('content')); + if (metaEl) + meta = Util._metaContentToObject(metaEl.getAttribute('content')); let projectionMaxZoom = this.getMapEl()._map.options.crs.options.resolutions.length - 1; if (this._parentEl.nodeName === 'MAP-LINK') { @@ -129,10 +134,10 @@ export class MapFeature extends HTMLElement { } } getMapEl() { - return M.getClosest(this, 'mapml-viewer,map[is=web-map]'); + return Util.getClosest(this, 'mapml-viewer,map[is=web-map]'); } getLayerEl() { - return M.getClosest(this, 'layer-'); + return Util.getClosest(this, 'layer-'); } attributeChangedCallback(name, oldValue, newValue) { @@ -231,7 +236,7 @@ export class MapFeature extends HTMLElement { // layerToRemoveFrom is the L.LayerGroup or L.FeatureGroup to remove this // feature from... layerToRemoveFrom.removeLayer(this._geometry); - // TODO: MOVE THIS LOGIC TO layerToRemoveFrom.removeLayer(M.Geometry) + // TODO: MOVE THIS LOGIC TO layerToRemoveFrom.removeLayer(Geometry) // if (layerToRemoveFrom._staticFeature) { // if (layerToRemoveFrom._features[this.zoom]) { // this._removeInFeatureList(this.zoom); @@ -302,7 +307,7 @@ export class MapFeature extends HTMLElement { // the fallback 'gcrs' SHOULD be specified by the MapML spec // per https://github.com/Maps4HTML/MapML/issues/257 return csMeta - ? M._metaContentToObject(csMeta.getAttribute('content')).content + ? Util._metaContentToObject(csMeta.getAttribute('content')).content : 'gcrs'; } @@ -341,7 +346,7 @@ export class MapFeature extends HTMLElement { } let topLeft = L.point(bboxExtent[0], bboxExtent[1]); let bottomRight = L.point(bboxExtent[2], bboxExtent[3]); - let pcrsBound = M.boundsToPCRSBounds( + let pcrsBound = Util.boundsToPCRSBounds( L.bounds(topLeft, bottomRight), zoom, map.options.projection, @@ -360,14 +365,14 @@ export class MapFeature extends HTMLElement { pcrsBound.min, M[projection].scale(+this.zoom || maxZoom) ); - pcrsBound = M.pixelToPCRSBounds( + pcrsBound = Util.pixelToPCRSBounds( L.bounds(pixel.subtract(tileCenter), pixel.add(tileCenter)), this.zoom || maxZoom, projection ); } let result = Object.assign( - M._convertAndFormatPCRS( + Util._convertAndFormatPCRS( pcrsBound, map.options.crs, map.options.projection @@ -389,14 +394,14 @@ export class MapFeature extends HTMLElement { .split(/[<>\ ]/g); switch (shape.tagName.toUpperCase()) { case 'MAP-POINT': - bboxExtent = M._updateExtent(bboxExtent, +data[0], +data[1]); + bboxExtent = Util._updateExtent(bboxExtent, +data[0], +data[1]); break; case 'MAP-LINESTRING': case 'MAP-POLYGON': case 'MAP-MULTIPOINT': case 'MAP-MULTILINESTRING': for (let i = 0; i < data.length; i += 2) { - bboxExtent = M._updateExtent(bboxExtent, +data[i], +data[i + 1]); + bboxExtent = Util._updateExtent(bboxExtent, +data[i], +data[i + 1]); } break; default: @@ -433,7 +438,7 @@ export class MapFeature extends HTMLElement { newZoom = this.zoom; } else { // if not, calculate the maximum zoom level that can show the feature completely - newZoom = M.getMaxZoom(bound, this.getMapEl()._map, minZoom, maxZoom); + newZoom = Util.getMaxZoom(bound, this.getMapEl()._map, minZoom, maxZoom); if (this.max < newZoom) { // if the calculated zoom is greater than the value of max zoom attribute, go with max zoom attribute newZoom = this.max; @@ -495,7 +500,7 @@ export class MapFeature extends HTMLElement { } else if (el.querySelector('table')) { // setting properties when table presented let table = el.querySelector('table').cloneNode(true); - json.properties = M._table2properties(table); + json.properties = Util._table2properties(table); } else { // when no table present, strip any possible html tags to only get text json.properties = { @@ -530,11 +535,11 @@ export class MapFeature extends HTMLElement { json.geometry.geometries = []; for (let shape of shapes) { json.geometry.geometries.push( - M._geometry2geojson(shape, source, dest, options.transform) + Util._geometry2geojson(shape, source, dest, options.transform) ); } } else { - json.geometry = M._geometry2geojson( + json.geometry = Util._geometry2geojson( shapes[0], source, dest, diff --git a/src/map-input.js b/src/map-input.js index 3a36e869e..fb11f4da2 100644 --- a/src/map-input.js +++ b/src/map-input.js @@ -1,3 +1,10 @@ +import { Util } from './mapml/utils/Util'; +import { ZoomInput } from './mapml/elementSupport/inputs/zoomInput'; +import { HiddenInput } from './mapml/elementSupport/inputs/hiddenInput'; +import { WidthInput } from './mapml/elementSupport/inputs/widthInput'; +import { HeightInput } from './mapml/elementSupport/inputs/heightInput'; +import { LocationInput } from './mapml/elementSupport/inputs/locationInput'; + /* global M */ export class MapInput extends HTMLElement { static get observedAttributes() { @@ -30,14 +37,14 @@ export class MapInput extends HTMLElement { // zoomInput.setAttribute('value', boundsFallback.zoom); // } // let axis = inp.getAttribute('axis'), - // axisBounds = M.convertPCRSBounds( + // axisBounds = Util.convertPCRSBounds( // boundsFallback.bounds, // boundsFallback.zoom, // projection, - // M.axisToCS(axis) + // Util.axisToCS(axis) // ); - // inp.setAttribute('min', axisBounds.min[M.axisToXY(axis)]); - // inp.setAttribute('max', axisBounds.max[M.axisToXY(axis)]); + // inp.setAttribute('min', axisBounds.min[Util.axisToXY(axis)]); + // inp.setAttribute('max', axisBounds.max[Util.axisToXY(axis)]); // } get name() { @@ -108,7 +115,7 @@ export class MapInput extends HTMLElement { // for location, it should fall back by searching upwards: same as for zoom } else if (this.parentElement.querySelector('map-meta[name=zoom]')) { // fallback map-meta on layer - return M._metaContentToObject( + return Util._metaContentToObject( this.parentElement .querySelector('map-meta[name=zoom]') .getAttribute('content') @@ -140,7 +147,7 @@ export class MapInput extends HTMLElement { // for location, it should fall back by searching upwards: same as for zoom } else if (this.parentElement.querySelector('map-meta[name=zoom]')) { // fallback map-meta on layer - return M._metaContentToObject( + return Util._metaContentToObject( this.parentElement .querySelector('map-meta[name=zoom]') .getAttribute('content') @@ -173,10 +180,10 @@ export class MapInput extends HTMLElement { } } getMapEl() { - return M.getClosest(this, 'mapml-viewer,map[is=web-map]'); + return Util.getClosest(this, 'mapml-viewer,map[is=web-map]'); } getLayerEl() { - return M.getClosest(this, 'layer-'); + return Util.getClosest(this, 'layer-'); } attributeChangedCallback(name, oldValue, newValue) { this.whenReady() @@ -269,7 +276,7 @@ export class MapInput extends HTMLElement { case 'zoom': // input will store the input Class specific to the input type this.initialValue = +this.getAttribute('value'); - this.input = new M.ZoomInput( + this.input = new ZoomInput( this.name, this.min, this.max, @@ -280,7 +287,7 @@ export class MapInput extends HTMLElement { break; case 'location': // input will store the input Class specific to the input type - this.input = new M.LocationInput( + this.input = new LocationInput( this.name, this.position, this.axis, @@ -293,15 +300,15 @@ export class MapInput extends HTMLElement { break; case 'width': // input will store the input Class specific to the input type - this.input = new M.WidthInput(this.name, this._layer); + this.input = new WidthInput(this.name, this._layer); break; case 'height': // input will store the input Class specific to the input type - this.input = new M.HeightInput(this.name, this._layer); + this.input = new HeightInput(this.name, this._layer); break; case 'hidden': // input will store the input Class specific to the input type - this.input = new M.HiddenInput(this.name, this.initialValue); + this.input = new HiddenInput(this.name, this.initialValue); break; } }) diff --git a/src/map-link.js b/src/map-link.js index fbd1a365b..3be2bd175 100644 --- a/src/map-link.js +++ b/src/map-link.js @@ -1,3 +1,8 @@ +import { Util } from './mapml/utils/Util'; +import { templatedImageLayer } from './mapml/layers/TemplatedImageLayer'; +import { templatedTileLayer } from './mapml/layers/TemplatedTileLayer'; +import { templatedFeaturesLayer } from './mapml/layers/TemplatedFeaturesLayer'; +import { templatedPMTilesLayer } from './mapml/layers/TemplatedPMTilesLayer'; /* global M */ export class MapLink extends HTMLElement { @@ -101,7 +106,7 @@ export class MapLink extends HTMLElement { // return the content of media attribute as an object // maybe memoizing the object to avoid repeated formatting // the Util function may need to be renamed? - return M._metaContentToObject(this.getAttribute('media')); + return Util._metaContentToObject(this.getAttribute('media')); } set media(val) { this.setAttribute('media', val); @@ -129,7 +134,7 @@ export class MapLink extends HTMLElement { // _templateVars existence happens for both templated layers and query links return this._templateVars ? Object.assign( - M._convertAndFormatPCRS( + Util._convertAndFormatPCRS( this.getBounds(), M[this.parentExtent.units], this.parentExtent.units @@ -150,15 +155,15 @@ export class MapLink extends HTMLElement { center = map.options.crs.unproject(bounds.getCenter(true)), maxZoom = extent.zoom.maxZoom, minZoom = extent.zoom.minZoom; - map.setView(center, M.getMaxZoom(bounds, map, minZoom, maxZoom), { + map.setView(center, Util.getMaxZoom(bounds, map, minZoom, maxZoom), { animate: false }); } getMapEl() { - return M.getClosest(this, 'mapml-viewer,map[is=web-map]'); + return Util.getClosest(this, 'mapml-viewer,map[is=web-map]'); } getLayerEl() { - return M.getClosest(this, 'layer-'); + return Util.getClosest(this, 'layer-'); } attributeChangedCallback(name, oldValue, newValue) { @@ -290,7 +295,7 @@ export class MapLink extends HTMLElement { } // create the type of templated leaflet layer appropriate to the rel value // image/map/features = templated(Image/Feature), tile=templatedTile, - // this._tempatedTileLayer = M.templatedTile(pane: this.extentElement._leafletLayer._container) + // this._tempatedTileLayer = Util.templatedTile(pane: this.extentElement._leafletLayer._container) // add to viewer._map dependant on map-extent.checked, layer-.checked // what else? } @@ -313,7 +318,7 @@ export class MapLink extends HTMLElement { // be loaded as part of a templated layer processing i.e. on moveend // and the generated that implements this should be located // in the parent ._templatedLayer.container root node if - // the _templatedLayer is an instance of M.TemplatedTileLayer or M.TemplatedFeaturesLayer + // the _templatedLayer is an instance of TemplatedTileLayer or TemplatedFeaturesLayer // // if the parent node (or the host of the shadow root parent node) is layer-, the link should be created in the _layer // container @@ -375,7 +380,7 @@ export class MapLink extends HTMLElement { let pmtilesStylesheetLink = this.getLayerEl().src ? this.closest('map-extent')?.querySelector(s) ?? this.getRootNode().querySelector(':host > ' + s) - : M.getClosest( + : Util.getClosest( this, 'map-extent:has(' + s + '),layer-:has(' + s + ')' )?.querySelector(s); @@ -388,12 +393,12 @@ export class MapLink extends HTMLElement { linkEl: this, pmtilesRules: pmtilesStylesheetLink?._pmtilesRules }; - this._templatedLayer = M.templatedPMTilesLayer( + this._templatedLayer = templatedPMTilesLayer( this._templateVars, options ).addTo(this.parentExtent._extentLayer); } else if (this.rel === 'tile') { - this._templatedLayer = M.templatedTileLayer(this._templateVars, { + this._templatedLayer = templatedTileLayer(this._templateVars, { zoomBounds: this.getZoomBounds(), extentBounds: this.getBounds(), crs: M[this.parentExtent.units], @@ -404,7 +409,7 @@ export class MapLink extends HTMLElement { linkEl: this }).addTo(this.parentExtent._extentLayer); } else if (this.rel === 'image') { - this._templatedLayer = M.templatedImageLayer(this._templateVars, { + this._templatedLayer = templatedImageLayer(this._templateVars, { zoomBounds: this.getZoomBounds(), extentBounds: this.getBounds(), zIndex: this.zIndex, @@ -414,7 +419,7 @@ export class MapLink extends HTMLElement { } else if (this.rel === 'features') { // map-feature retrieved by link will be stored in shadowRoot owned by link this.attachShadow({ mode: 'open' }); - this._templatedLayer = M.templatedFeaturesLayer(this._templateVars, { + this._templatedLayer = templatedFeaturesLayer(this._templateVars, { zoomBounds: this.getZoomBounds(), extentBounds: this.getBounds(), zIndex: this.zIndex, @@ -659,7 +664,7 @@ export class MapLink extends HTMLElement { case 'longitude': case 'column': case 'easting': - boundsUnit.name = M.axisToCS( + boundsUnit.name = Util.axisToCS( inputs[i].getAttribute('axis').toLowerCase() ); bounds.min.x = min; @@ -672,7 +677,7 @@ export class MapLink extends HTMLElement { case 'latitude': case 'row': case 'northing': - boundsUnit.name = M.axisToCS( + boundsUnit.name = Util.axisToCS( inputs[i].getAttribute('axis').toLowerCase() ); bounds.min.y = min; @@ -703,7 +708,7 @@ export class MapLink extends HTMLElement { let zoomValue = this._templateVars.zoom?.hasAttribute('value') ? +this._templateVars.zoom.getAttribute('value') : 0; - bounds = M.boundsToPCRSBounds( + bounds = Util.boundsToPCRSBounds( bounds, zoomValue, projection, @@ -720,7 +725,9 @@ export class MapLink extends HTMLElement { let zoom = 0; let metaExtent = this.parentElement.getMeta('extent'); if (metaExtent) { - let content = M._metaContentToObject(metaExtent.getAttribute('content')), + let content = Util._metaContentToObject( + metaExtent.getAttribute('content') + ), cs; zoom = content.zoom || zoom; @@ -728,12 +735,12 @@ export class MapLink extends HTMLElement { let metaKeys = Object.keys(content); for (let i = 0; i < metaKeys.length; i++) { if (!metaKeys[i].includes('zoom')) { - cs = M.axisToCS(metaKeys[i].split('-')[2]); + cs = Util.axisToCS(metaKeys[i].split('-')[2]); break; } } - let axes = M.csToAxes(cs); - bounds = M.boundsToPCRSBounds( + let axes = Util.csToAxes(cs); + bounds = Util.boundsToPCRSBounds( L.bounds( L.point( +content[`top-left-${axes[0]}`], @@ -804,7 +811,7 @@ export class MapLink extends HTMLElement { // search document from here up, using closest source of zoom bounds info let meta = this.parentElement.getMeta('zoom'); let metaMin = meta - ? +M._metaContentToObject(meta.getAttribute('content'))?.min + ? +Util._metaContentToObject(meta.getAttribute('content'))?.min : null; zoomBounds.minZoom = metaMin || (zoomInput ? +zoomInput.getAttribute('min') : 0); @@ -812,7 +819,7 @@ export class MapLink extends HTMLElement { ? +zoomInput.getAttribute('min') : zoomBounds.minZoom; let metaMax = meta - ? +M._metaContentToObject(meta.getAttribute('content'))?.max + ? +Util._metaContentToObject(meta.getAttribute('content'))?.max : null; zoomBounds.maxZoom = metaMax || diff --git a/src/map-style.js b/src/map-style.js index 144b5858a..6073e8847 100644 --- a/src/map-style.js +++ b/src/map-style.js @@ -13,7 +13,7 @@ export class MapStyle extends HTMLElement { // be created as part of a templated layer processing i.e. on moveend / when connected // and the generated