Tags: Maps4HTML/MapML.js
Tags
Map link custom element implementation (#916) * Create map-link custom element - change map-extent._templatedLayer to map-extent._extentLayer - add map-extent.getMetaExtent() function to return closest map-meta extent - add comments where code should be in map-input for moved code from map-extent etc - get rid of map-link `title` attribute, we think never used - add comment and methods for map-select custom element in layer control - move map-select code from map-extent module to map-select.js - add comments to attributes to associate them with rel - remove call to _initTemplateVars from map-extent connectedCallback; - set the M.templatedLayer templateVars param to null in map-extent connectedCallback - work on map-link _initTemplateVars to get partially working - TODO; revisit how the bounds are established for map-link._templateVars - prettier formatting... - add map-link.getBase() function, relies on / supports map-base which should simulate how <base> works for remote content. - update copyRemoteContentToShadowRoot to copy all children of <map-head> to shadow root. - use parentElement instead of parentExtent in _initTemplateVars, which allows it to not have to wait on connectedCallback to be runnable - change TemplatedLayer to extend LayerGroup - remove TemplatedLayer templates parameter - move TemplatedLayer._setupQueryVars to map-link - get crs option for TemplatedLayer from map-extent units attribute - move creation of MapMLLayer._properties._queries array from map-extent into map-link - change map-extent._validateDisabled to iterate over querySelectorAll over child map-links of selected rel values (image,tile,features,query) - delete map-extent.redraw method, corresponding TemplatedLayer.redraw; that was needed to redraw the layer when the map-select change event happened. TODO we need to migrate that to map-select. - create map-link.mapEl property during connectedCallback - create map-link.getExtent that incorporates (refactors move + rename of) M._extractInputBounds(...) - create and use map-link.whenReady() for content links. Used by map-extent._calculateBounds when iterating child links. - create private _getZoomBounds(zoomInput) that is used during template / element initialization - create public getZoomBounds() which reads the bounds from the result\ of the above _getZoomBounds(zoomInput), but doesn't require to sift through the inputs for linked/non-linked zoom input that might not exist - simplify boundsFallback field of _templateVars; remove object props, return simple L.Bounds object type - add map-link._validateDisabled function which is used by map-extent._validateDisabled() - refactor map-extent._calculateBounds to use new map-link.getBounds and map-link.getZoomBounds API methods - update TemplatedTileLayer - pass zoomBounds and extentBounds as required options WIP: add the linkEl.templatedLayer to the extentLayerGroup when it is initialized; add leaflet.LayerGroup's prototyped initialize function call to properly init extentLayerGroup; add image as fallback linkEl.type if no type attribute is specified - non-functional source change: don't use L.extend(options, {}) when unnecessary, just pass the options - Refactor TemplatedImageLayer: - replace isVisible property with isVisible methods that will be invoked during validateDisabled process - add MapExtent.whenLinksReady, use it in Layer._validateDisabled - remove MapmlLayer._imageLayer - add leaflet FeatureGroup.prototype.initialize function call in FeatureLayer.js - make TemplatedTileLayer use minZoom,minNativeZoom,maxZoom,maxNativeZoom calculated and stored as map-link._templateVars.zoomBounds property, instead of calculating and usin those values itself (remove duplication) - add .zoom property to map-link._templateVars for use by TemplatedTileLayer (that layer was doing that itself before breaking readability and source code coherence). - remove creation of _templateVars.zoom by TemplatedTileLayer ._setUpTileTemplateVars initialize sub-process - use map-input[type=zoom].initialValue via _templateVars.zoom.initialValue when calculating (creating) _templateVars.pcrs.bounds property during TemplatedTileLayer ._setUpTileTemplateVars initialize sub-process - create map-link._templateVars.inputsReady Promise-valued property which returns the Promise.allSettled(child-map-inputs) value - make map-link.connectedCallback wait on _templateVars.inputsReady promise before using map-input[type=zoom].initialValue - move creation of map-input[type=zoom].initialValue property into map-input.connectedCallback to avoid map-input.whenReady() promise chain for attributChangedCallback on value attribute which prevented map-input[type=zoom].initialValue from being available even though the map-input was ready for use - Revert deletion of TemplatedTileLayer.options.minZoom,.maxZoom, .minNativeZoom,..maxNativeZoom - Get map-select quasi working (at least, add it to the layer control) TemplatedFeaturesLayer: - Temporary fix for map-link.getFallbackBounds by adding projection as parameter - Get map-select working better - Create remote templated features in the shadow root of map-link (instead of map-extent) - Add TemplatedLayer.redraw function in order to delegate map-select change event handling across templated layers that may share the variable map-link[rel=query]: - get rid of MapMLLayer.queryable property, replace with dynamic layer-.queryable() method, which looks for map-link[rel=query] and other properties that determine if a layer is queryable - create shadowRoot in linkEl for queried features - remove shadowRoot from extentEl, since it no longer needs it - MapMLLayer.getQueryTemplates radically simplified - map-feature now uses shadow root of map-link, not map-extent - change the order of defines for map-input and map-select, so that they have parentElement.whenReady available to them when booting up. - delete MapMLLayer._imageContainer - layer-.queryable only considers a map-link[rel=query] if it is in a layer-[checked] in a map-extent[checked] - update map-link.getBase to use the (resolved) layer-.src as a base against which to resolve any map-base.href, unless it's in local content, in which case it uses the map-link.baseURI value as base to resolve against - restore erroneously removed check for query location to be within bounds of the queryable link - ensure that the TemplatedLayer.onAdd and .onRemove CALL THE INHERITED METHOD OF THE SAME NAME INSTEAD OF SIMPLY OVERRIDING THAT FUNCTION This was the cause of much confusion! - add getMapEl(), getLayerEl() API to map-link - add mapEl reference to options for FeatureLayer wherever created - update TemplatedFeaturesLayer, TemplatedTileLayer, TemplatedImageLayer FeatureLayer .isVisible method so that it doesn't require the layer to be on the map when it is run; will use reference to mapEl._map in order to run - update DebugOverlay to use linkEl reference to get layerEl ref - delete map-link._templateVars.boundsFallbackPCRS, unused, problematic - change implementation of map-link.getBounds() to use getFallbackBounds when necessary, which gets those bounds from the CRS. map-link.getBounds() is called during connectedCallback, so usually the CRS is defined by then. - make map-extent.units getter fall back to M.FALLBACK_PROJECTION if no units attribute is present - add 'zoomchangesrc' internal event which can happen during zoom animations and when the layer is added to the map. Like its name suggests, it changes the layer-.src when called upon based on presence of map-link rel=zoom(in|out), changing the source of the layer as required - small change to FeatureLayer.onAdd to use the passed map parameter - get rid of duplicate options.zoomBounds info on Templated(Content)Layer - re-write logic of map-link.getMapEl and map-link.getLayerEl - create _createSelfOrStyleLink() function from part of logic from MapMLLayer.getAlternateStyles... the part that applies to a single link (generates an option for it). - re-code / generalize map-link.whenReady so that it works according to the rel value of the link - move MapMLLayer.getAlternateStyles() to layer-.getAlternateStyles(links) - call it from createLayerControlForLayer - try to wrap layer control generation in layer-.connectedCallback in a promise for links being ready when generating the layer control. Formerly, they didn't have to be ready, just the markup had to be available. To be continued... - working on getting layer control HTML to be part of defining whenReady() for layer... tbd, seems never created! - layer.js: probably want to keep: return shadowRoot from then, not resolve it - map-link.js: use L.stamp on just-created div instead of layer, will make it more whenReady-independent, if it works - map-link.js bind changeStyle listener to layer element; use addEventListener instead of L.on - comment out _createLicenseLink() for now, reduce console noise - createLayerControlForLayer.js: correct typo that meant the styles fieldset was not available or being appended to with self style etc links - get map-link.getLayerControlOption() working for templated links - make layer-.connectedCallback wait on map-link.whenReady() - add layer-._layerControlHTML to whenReady criteria for readiness - add extentsReady as a criteria for layer initialization to proceed. the problem encountered is that the `checked` attr. change callback does a layer-.whenReady() which happens much earlier and doesn't take into account the extents' readiness, so some properties of _extentLayer aren't set up when the layer-._layer is added to the map, resulting in console errors. - the MapMLLayer.copyContentToShadowRoot method was setting the href attribute of map-link elements erroneously. Remove that code, replaced the map-link.href getter with a better approach. - remove code from MapMLLayer that sets up the zoomin/zoomout links, move it to map-link href getter, essentially. - change MapMLLayer._validateLayerZoom() to use map-link, and not _properties.zoomin / zoomout - comment out map-link._createZoominOrZoomoutLink() since it isn't necessary (perhaps), being handled by the href getter. - move copyRemoteContentToShadowRoot from MapMLLayer to layer.js - remove parentLayer.whenReady() from map-extent.connectedCallback - add parentLayer.whenReady() to map-extent.attributeChangedCallback for `checked` and `hidden` - remove _leafletLayer option from construction of TemplatedLayer - move access to _layer pane from TemplatedLayer initialize option to onAdd - eliminate use of map-extent._DOMnode by map-extent and TemplatedLayer, use only map-extent (this) element itself - refactor map-extent._projectionMatch() to use the mapEl._map.options.projection value instead of that value passed via the MapMLLayer.options.mapprojection - update MapMLLayer.selectMatchingAlternateProjection() to use the version of mapml content that is saved to shadowRoot, which is now sort of unstructured, similar to the way it's expected to be as local content of the <layer-> element. - move attributeChangedCallback - select matching alternate projection in fetching of layer.js - modify copyRemoteContentToShadowRoot to use documentFragment, to move all elements to shadowRoot at once - add getBase + selectMatchingAlternateProjection + getProjection method for layer.js - map-input, remove dependency from _layer - map-link - add temporary _createAlternateLink(), not being USED - QueryHandler.js - replace layer._properties with alternate - MapMLLayer - move out getProjection, selectMatchingAlternateProjection(), determineLayerProjection() to layer.js - MapMLLayer - get rid of properties object - refactor promise resolution on mapml-viewer.attributeChangedCallback for `projection`. (To Do: do same to web-map). - remove call to mapml-viewer._updateMapCenter() from _map event listeners for: 'move','movestart','zoom','zoomstart' (To Do: do same to web-map) - remove MapMLLayer.copyRemoteContentToShadowRoot - update map-input getters for min, max - update layer-.extent getter tbd if it breaks tests, but it avoids some problems with the layer not being ready - update layer.-src attributeChangedCallback to not do side effects on first pass through lifecylcle callback for remote layer (with src). - refactor / rename layer-.selectMatchingAlternateProjection to selectAlternateOrChangeProjection. Make it throw when condition(s) detected, use it on both remote **and local** content (new behaviour). - add layer.#hasConnected private so that can avoid attributeChangedCallback calls queued by browser on upgrade etc. Allows to remove individual this.whenReady() calls and consequent microtask queue enlargement - remove use of inducing layer.connectedCallback by the layer.src.attributeChangedCallback - only do the side effects which means calling the functions that layer.src.connectedCallback calls, seems to prevent inadvertent duplication of content in layer.shadowRoot - per advice from HTML Standard, create layer.shadowRoot in constructor as well as initialization of opacity. - unconditionally purge layer.shadowRoot during onRemove - move selectAlternateOrChangeProjection() to after copying content to shadow root, insert into next then in promise chain which waits on all that contents' whenReady() to settle which can only be done there because it needs access to the map-link.getBase() instance function to determine the correct URL to load, which isn't a function until the map-link and all its "sibling" content becomes ready. - add changeprojection messaging to fetch catch block, but don't call it a "_fetchError" because that's confusing (not really a fetch error). Also, the overall promise should fulfill, just not until after changing the src or mapml-viewer.projection as selected. - get rid of copy of getBase() on layer, which was cut-and-pasted from map-link, and can't work on layer because the document context of the map-link is element instance-based and not available to layer. - remove the parameter from layer.getProjection(), make it detect whether the content is remote (.src exists, so .shadowRoot should contain stuff) - change other stuff that relies on layer.shadowRoot to use layer.src to detect if layer *should* have a shadowRoot - make map-link.whenReady() reject if rel=alternate but no href nor projection - attempt to map-link.whenReady() to reject with message when await used on parentExtent.whenReady() and _templateVars.inputsReady - validate and update map-link.getBounds(), map-link.getFallbackBounds() - add map-link.media attribute, with the idea of prototyping `prefers-map-content` proposed media feature - update layer on one side of connectedCallback to show where handling of map-link.media attribute may go see layer-.checkForPreferredContent() - add and use #hasConnected field to map-extent - tentatively add mapml-viewer._map.options.minZoom, .maxZoom to allow map to use all zoom levels in crs - update TemplatedTileLayer.initialize to remove .options.zoomBounds property which is / would be information triplication (already have TemplatedTileLayer.zoomBounds, .options.minZoom etc, don't need a third) - add media attribute to map-link, work towards media query support for prefers-map-content - re-organize promise then/catch for fetches - adopt consistent style of detecting projection, prefers-map-content etc to throw during loading, triggering src changes - Convert MapMLLayer to a Layer group + map-feature independence - layer- mutation observer to initialize map-features - move validateLayerZoom from MapMLLayer -> layer-, and move to validateDisabled, removed from zoomAnim handler - remove zoom-in/zoom-out workaround for map projection change #2553 - remove map-feature's dependency on MapMLLayer, to create it's own layer independently - map-feature - rerender feature on min, max, zoom attributes - queryHandler no longer appends directly to the map, appends itself to mapmlvectors - for templatedFeatures - we move everything from the mapml file's head and body to the shadowroot of map-link - layer- always has a shadowRoot, but it is not always used - used based on src attribute - map-extent handleChange is not dependent on the parentLayer.checked - adapt FeatureLayer so that it doesn't expect feature data during initialization. Change options.static to be options.tiles and let it be false by default: FeatureLayer is used only for its addData function by TemplatedTileLayer, in which case and only in that case options.tiles is passed as true; - adapt TemplatedTileLayer only uses M.featureLayer for access to the addData function, which it now calls once for each feature found in the fetched MapML vector tile response; map-feature elements are not added to the DOM for each feature, only their geometry is rendered as SVG <g> and <path> elements. - adapt TemplatedFeaturesLayer - remove use of options.static which now has a default of false - remove use of M.featureLayer.options.static by MapMLLayer._mapmlvectors, because it now has a default of false (and is more correctly called options.tiles). - remove QueryHandler.featureLayer.options.static, because that option is false by default and has been renamed to options.tiles - update map-feature to extend the bounds of the M.featureLayer to which it is added, since the bounds of the Leaflet layers are harvested to calculate the extent / bounds of the parent <layer-> element. - add console log of document that causes parser error, useful for debugging in geoserver query layers, which serves errors as xml documents - change layer-.zoomTo() use of whenElemsReady() to use this.whenReady() because the layer is only ready after the elements are ready, so whenElemsReady() doesn't wait long enough in some cases. - add M.geometry.layerBounds and M.geometry.zoomBounds via passed options of the same name. Necessary so that the M.featureLayer._layers hash table has a value of these properties for every layer it holds, which is necessary when setting the bounds of the overall <layer-> - make map-feature getters for zoom,min, max return fallback values if the attribute isn't set - map-feature disconnectedCallback can happen when ancestor elements are disconnected, which may have cleaned up resources used by map-feature, so the disconnectedCallback should test if they've been dealt with already and not throw errors if so. - rename-refactor M.FeatureLayer.addData to M.FeatureLayer.renderToLeaflet - fix bug in map-feature._updateExtent (used non-uppercased comparison for tagName value, which returns uppercase always) - add map-feature.extent.zoom property to match that of layer-.extent - add map-feature.getMeta API which returns the appropriate map-meta element in the ancestors of the map-feature, if any - update M.FeatureLayer: - add addLayer(layerToAdd) which conforms to L.LayerGroup API - update removeLayer(layerToRemove) to maintain internal structures of M.FeatureLayer, including .layerBounds, .zoomBounds and ._layers - make removeLayer return this, conforming to L.LayerGroup API - refactor geometryToLayer to tag it as 'private': _geometryToLayer - when feature is queried or static, we need to extend the M.featureLayer layerBounds and zoomBounds - for QueryHandler: - synthesize a <map-geometry><map-point> for all features returned by query if they do not posses a <map-geomtry>. Uses :has() because this was recently deemed fit for use across browsers, with FF 121 - change approach to parsing: text/mapml documents are handled the same way, but mapml documents returned under a different media type should get handled ok. text/html documents will get parsed and appended to a synthesized map-feature>map-properties element, which should display them as parsed HTML. Other text documents or unrecognized stuff will display as text in the popup, hopefully. - Updated DebugOverlay: make access to options._leafletLayer conditional on its existence, because it is actually iterating leaflet layers on the map and some of them are debug overlay artifacts and don't have a _leafletLayer (if _leafletLayer is taken to mean an "M.MapMLLayer" instance) tbd axisInferring.test.js - update map-feature.js - when calculating extent, don't use the zoom fallback value unless no zoom attribute exists. map-feature.zoom looks for map-meta in the parentage of the element, but falls back to the projection, which is not suitable for calculating extents when the coordinates require a zoom value for calculation - rename M.getBounds to M.getBoundsFromMeta - add map-meta[name=extent]-based bounds as default layer bounds for MapMLLayer._calculateBounds, so that map-meta, _mapmlvectors, static tiles and map-extent -generated bounds are additive - update Util.pointToPCRSPoint and Util.boundsToPCRSBounds logic so that zoom parameter is optional for points that don't require a zoom to transform i.e. gcrs to pcrs, pcrs to pcrs don't need a zoom value - update Util.getBoundsFromMeta to throw where it is invoked without a zoom where a zoom value is required to convert coordinate system i.e. tile,tcrs,tilematrix - remove fallback cs from Util.getBoundsFromMeta since it could be wrong - remove fallback to zoom = 0 where zoom parameter is not provided, throw instead where it could cause a problem - update axisInferring.html and .test.js. Add (commented) features that represent the bounding box of the map-meta[name=extent], for debugging purposes - update the expectations to expect that the extents of the layers involved should include the map-meta[name=extent] bounds AND the contents of the layers. Fix Layer zoomBounds - Fix zoomBounds initialization in FeatureLayer.js removeLayer, as an empty object is truthy - MapMLLayer.js - CalculateBounds() extend zoombounds for staticTileLayer and mapmlvectors - update tests to instead of using the old _templatedLayer, to use _extentLayer (renamed). - update multipleExtentsOpacity.test to slow it down a little, also simplify selector for assertion that may have been taking too long to evaluate - Add grunt 'geoserver' task which copies the viewer to the geoserver MapML extension 'widget' directory. Could be improved, as it clobbers the license headers in each of the geoserver copies of the file. - fix kbdAttribution.test.js, add timeout - temporarily add test-results.txt for reference of what's failing - fix markup in featureIndexOverlay.html which used XML self-closing syntax for <map-input/>, resulting in incorrect parentElement. - change '/>' to '>' and close tag where applicable in test/*.html where applicable - fix thrown error during layerContextMenu.test.js due to untested map-tile refactoring - synchronize applicable diff/updates mapml-viewer.js -> web-map.js - update a few things to get mapContextMenu.test.js passing - fix mapElement.test.js Dynamic layer bounds/zoombounds: - layer.js - layercontrol / Hidden API + controls API bug fix - map-extent.js - calculateBounds - finish implementation for zoombounds (naitiveZoom) - map-feature.js - min/max API - integrate search for map-meta zoom - bug fix - Util.js - add a new function -> getZoomBoundsFromMeta - Revert truncation of extent tcrs and Tilematrix coordinates - Reverted tests - axisInferring.test.js, mapContextMenu.test.js, mapElement.test.js, - FeatureLayer.js - rename renderToLeaflet->createGeometry and _resetFeatures->_validateRendering - addLayer - maintain featuresList - moved from createGeometry + recalculates bounds/zoomBounds - addRendering/removeRendering - new function to only add/remove geometries from DOM/Leaflet, without recalculating bounds, etc. - removeLayer - remove feature from featureslist + recalculate bounds/zoomBounds - _validateRendering -> refactor function variable names - MapMLLayer.js - _calculateBounds - change algorithm to incorporate map-meta and (_staticTileLayer, _mapmlvectors, _extentlayer) to be add together, add same functionality for zoombounds - _calculateBounds - merge the _mapmlvectors and _staticTileLayer blocks into one block - _calculateBounds - zoombounds and bounds are not treated independently - _calculateBounds - extend zoombounds for _staticTileLayer and _mapmlvectors - mapFeature.data.js - add zoom object to reflect code - mapFeature.test.js - rename use of private property which was changed from _featureGroup -> _geometry - add map-feature._initialZoom, which captures the zoom of the map when the feature is first connected. Used by getter for zoom instead of map-meta or projection zoom for static features only. - refactor rename map-feature.getMaxZoom() to getZoomToZoom() - change mapFeature test data (expectations) so that the map-feature default zoom value for no-zoom-attribute static features is that of the map viewer when the feature is first connected. - change mapFeature.test expectations around zooming to the bounds of a map-feature that has no zoom attribute - now it will zoom to the zoom value or pretty close to the zoom value of the map when the feature was first connected (the bounds of a point feature is based on the size of a tile at the zoom level of its zoom value, so depending on the size of the map it might zoom to a lower zoom than that of the point when it was connected). - eliminate "fallbackZoom" method and argument for creating geometry. FeatureLayer factory method createGeometry uses map-feature.zoom now - FeatureLayer._validateRendering checks to see if the layer is on the map - geometry _checkRender() now uses map-feature.zoom instead of attribute - for map-feature.zoom: in templated features case, eliminate use of projection max zoom, use attribute, map-meta.value, .max or else initial zoom. - for FeatureLayer.isVisible, use .zoomBounds || .options.zoomBounds and .layerBounds || .options.layerBounds to determine visibility (was using only .zoomBounds and .layerBounds, which didn't cover the templated features use case. - map-link: add conditions for drag/drop 'data-moving' on ancestor extent and layer - featureLayer - ensure zoomBounds property has min/maxNativeZoom property which reflects the min/maxNativeZoom value range of member map-features - add back a zoom parameter to the createGeometry method, because it's necessary for templated mapml vector tiles' features for which the map-feature is discarded and just the rendered geometry is used; in that case the zoom parameter is used to do coordinate transformations for the geometry, using the zoom of the tile to which the feature belongs. - globally, remove call to _map._addZoomLimit, replace with _map event handler for layeradd, layerremove to call _map.setZoomLimit with the zoomBounds for the map at that moment (assuming mapml-viewer.extent.zoom is kept up to date with layer changes. Some layers 'unpacked' their zoomBounds object onto their options object via L.extend(options, this.zoomBounds), which added the individual properties of zoomBounds to the options object for the layer. For subclasses of L.GridLayer, that information was used to constrain the zoom values to which the map would zoom. That is no longer used because of the layeradd/layerremove event handler discussed above, so those statements were globally deleted as well. - templatedImageLayer - get rid of options.minZoom, options.maxZoom (see comment above) - get rid of _map._addZoomLimit call (see comment above) - layer.js - add else if block for when a fetch fails due to CORS or other fetchy issues. The block adds a _fetchError flag to the layer so that whenReady can cut short its timer loop in such a case, as the tests for bad layer were taking 5 seconds to fail. - mapml-viewer.js / web-map.js - amend the algorithm for extent.min/maxZoom to use the layers' .extent property instead of the _map.getMin/MaxZoom() - update _setupEvents; add event handler for layeradd / layerremove which calls _map.setMin/MaxZoom(zoom) based on the extent.zoom values for min/maxZoom. The addition of the event handler must be delayed until whenLayersReady() promise is fulfilled, and the event handlers themselves must defer handling the event until the whenLayersReady() promise fulfills (layeradd/layerremove occur very frequently and don't correlate only to <layer-> layers - make disconnectedCallback remove event handlers too - QueryHandler.js - update so that tests pass: there needn't be nodes inside the body of an HTML response to a query; this may have changed due to a change in chrome behviour. - map-extent.js - separate handling of bounds zoomBounds, so it's easier to understand - TemplatedTileLayer.js - add tile.z to call to M.FeatureLayer.createGeometry per comment above - maintain TemplatedTileLayer.options.min/maxZoom, because L.TileLayer, which this is a subclass of, depends on /requires it - map-link.js - create (empty) _createStylesheetLink() which will need to be implemented in next commit, as the styleParing test is failing due to lack of implementation here - TemplatedFeaturesLayer.js - create .zoomBounds, .extentBounds properties, delete options. zoomBounds, extentBounds - remove unpacking of zoomBounds onto options, per global discussion above. Remove call to _map._addZoomLimit per above. - update onAdd/onRemove handler functions so that it adds/removes the added (geometry) layer to the ._features contained / child layer used to render the feature geometries for the layer. - replace triggering of _map 'moveend' event, replace with call to moveend handler function, per longstanding comment. - path.js - replace call to markup.getAttribute('zoom') with markup.zoom, in case that is ever called with a map-feature as the markup, which seems unlikely now - the zoom seems to be passed as an option property always. - get styleParsing.test.js working: - create (and remove) a <link rel=stylesheet> in the templated feature container so that styles loaded that way apply to the renderer-generated svg <g> elements in the container. - update test-results.txt - recover tileloadstart event functionality - get clientTemplatedTileLayer.test.js working - fix templatedFeaturesLayerStep test - fix templatedImageLayer test - fix customTCRS test - fix mapScale.test.js - update map-feature connected/disconnected callback to look at the ancestor layer- or map-extent for data-moving attribute and forego doing that in that case (supports drag and drop). - Get touchDevice.test.js working on linux Update ci-test.yml - remove --legacy-peer-deps argument to npm install - add very narrow map-style custom implementation - add mutation observer cases for map-link, map-style - move M._parseStylesheetAsHTML from Utils to TemplatedTileLayer, since that is the only place it is now used from, eventually to be removed altogether (see inline TO DO items) - remove use of M._parseStylesheetAsHTML from MapMLLayer - remove unnecessary _processContent function from MapMLLayer - Update TemplatedFeaturesLayer appendStyleLink, add complementary appendStyleElement function. This layer loads text/mapml documents dynamically, so it should propagate stylesheets and links to same into the shadow root container of the layer. - similar updates for TemplatedTileLayer need to be done, as the <map-link> element for TemplatedTileLayer does not have a shadow root and perhaps it should tbd. Anyway, it needs one if only for map-link and map-style elements loaded with the tile text/mapml data get connected to the DOM, similar to how it's done with TemplatedFeaturesLayer. - update some tests that failed because they formerly didn't take the map-link and map-style effects into account (because that wasn't implemented) - MapMLLayer._calculateBounds: set .bounds and .zoomBounds to default (corresponding property of the layer projection) for empty layers. - delete <layer->._layer.bounds in mutation observer when/before adding feature, so that the next time something uses <layer->.extent, it will be recalculated - map-feature: ensure that disconnectedCallback does not throw when following links etc. - update .extent property so that for rel=query it returns an value - add map-link.zoomTo() method - update map-link._validateDisabled() to account for the fact that map-link rel=query link now has an extent - add elements/map-link test directory, add it to server.js: - create locally hosted tiles for osm for zoom=3 to zoom=3 - add test html file (work in progress, not finished) - add empty map-link.test.js wip MapMLLayer.js: - update getQueryTemplates method, add a zoom parameter to make behaviour slightly more _map-independent. Affects call to this from QueryHandler.js - Refactor rename TemplatedLayer -> ExtentLayer to avoid layer confusion - affects: map-extent.js, index.js, renames TemplatedLayer.js to ExtentLayer.js, mapSpan.test.js, styleParsing.test.js, multipleExtents.test.js, imageStep.test.js, templatedImageLayer.test.js, templatedTileLayer.test.js, QueryHandler.js: - remove duplicate test to verify if click location is within the bounds of the selected query template (this step was already done in MapMLLayer.getQueryTemplates(location, zoom), which was called immediately prior). FeatureLayer.js: - rename refactor the this._mapmlFeatures -> this._queryFeatures property, so as to read a little less ambiguously TemplatedImageLayer.js - update _scaleImage method, which is invoked repeatedly during movend handling. The main behaviour is wrapped in a setTimeout, and the delay sometimes seems to cause the layer's ._map property to disappear (removed from map on zoom end due to zoom bounds constraint?). Return / do nothing if obj._map doesn't exist. map-extent.js: - copy refactor map-link API methods for .extent, .zoomTo(), .getMapEl(), .getLayerEl() fix bug in map-extent.js getMeta: - was over-scoping the selection of map-meta elements in parent layer to include map-meta elements in sibling map-extent. Fixed using :scope > selector. - add map-link.extent tests for inline and remote content. Limitation is that the tests only test map-link.rel=image and rel=query so far. - some tests started failing because they used http:, not https: today. Update so that they pass now. - add <g>._featureEl reference to map-feature from its rendered self - de-flake new map-link.test.js by reloading the page before testing disabled-ness, which is done in a loop, complicating matters - fix bug in first added or removed map-feature - fix bug in "Focus Controls" popup navigation button - closes #828 - enable switching from remote to local / inline content - closes #898 - add required tests, all pre-failing - add tests for map-extent extent - update selectors for map-meta related to extent - add failing tests with comments as reminders - next step (besides tests): resolve map-extent use of map-meta - fix bug in map-extent.getMeta() - fix min/maxNativeZoom bug in MapMLLayer._calculateBounds - update featureLayer.test.js to make it pass with bug fix, add comment explaining why - add _calculateBounds to map-extent - add Mutation Observer to map-extent, layer- - add Mutation Observer to map-extent, update layer-'s to listen for map-meta name=zoom / extent - prettier formatting in featureLayer.test.js - remove unwritten test from layer-src.test.js (updated extent test in featureLayer.test.js) - update / add tests for layer-extent.test that validate the effects of the MutationObservers (on layer- and map-extent listening for map-meta) on layer-.extent results - update map-extent.disconnectedCallback to delete the MapMLLayer.bounds so that bounds are recalculated - get tests working for map-extent - tests for map-extent api methods zoomTo(), getMapEl(), getLayerEl() local and remote and for web-map, where warranted - add empty map-feature-extent test to remind of need - tests for map-link api .extent and zoomTo() - add map-feature-extent.test.js - add map-feature test subdirectory to server.js config - add test for layer- .extent bounds change with added / removed child map-features - test case for svg tile rendering bug discovered by Andrea - update test page for render bug - select only map-feature with actual geometry for tile rendering - perttier formating on layer-extent.js - add "reftest" for 'zinger' rendering bug Co-authored-by: Aliyan Haq <aliyan.haq@nrcan-rncan.gc.ca> Co-authored-by: Hanyu Yao <97408822+yhy0217@users.noreply.github.com> * Update package.json version -> 0.13.0 --------- Co-authored-by: prushfor <prushfor@L-BSC-A146390.nrn.nrcan.gc.ca> Co-authored-by: Aliyan Haq <aliyan.haq@nrcan-rncan.gc.ca> Co-authored-by: Hanyu Yao <97408822+yhy0217@users.noreply.github.com>
Create map-extent, map-input, map-link (#887) * initial map-input setup * implement Classes for different types of map-input types * Update map-input implementation + Add support for tilematrix type=locataion Class * initial map-link setup * Make map-input.connectedCallback async, await on extent.whenReady() for setup * Update version to 0.12.0 in package.json * migrating extent initialization from MapMLLayer to map-extent.js * updating and adding and removing layer control extent HTML current problem is that this._layerControlHTML is not connected when disconnecting the map-extent from the DOM (manually), so unable to hide/unhide the extents' root fieldset line 620 map-extent.js * map-extent hidden API * map-extent Get checkbox working via API map-extent.checked. Change TemplatedLayer and related child layer types. * Fix TemplatedFeaturesLayer checking/unchecking behaviour. Prevent excessive disconnection / reconnection of layers and map-extents when clicking on layer control entries, by upping the 'moving' px threshold and calculating if the entry has changed position through the dragging event (do disconnect/reconnect) or not (do not do dis/re). In map-feature, look for data-moving on layer or map-extent element, regardless of whether it's a local or remote layer (light dom vs shadow dom). * Set 'Sub-layer' as default label attribute, add to options messages Synchronize opacity attribute, property and slider in layer control (note: works slightly differently than layer.opacity, which doesn't "sprout" the opacity attribute when set via layer control) Fix bug when setting map-extent.hidden in shadow dom of layer element * Move/ refactor MapMLLayer._setLayerElExtent into layer.js layer-.extent /layer-._calculateExtent(). To Do: make it efficient / memoize extent value until extent actually changes. * Fix bug in _calculateExtent, add whenReady() to layer.zoomTo * get tests configured with new map-extent attributes. Get rid of (some) use of live map tiles from NRCan. Add temporary todo list of still-failing tests * Fix a test done with map-extent hidden attribute implemented via CE * Make opacity work the same in map-extent as it does in layer. This is the documented behaviour too. * Make layer-.extent (layer-._calculateExtent()) memoized * Get map-extent label API working * fix/refactor query map-extents * avoid remote map-feature (in mapml) triggering MapFeature connectedCallback twice when it is parsed in form of text/html * Fix remote queryable layer with hidden extent not queryable. * Re-write AnnounceMovement.js totalBounds event handler to use layer-.extent. Create extent.getBounds() function which may be better written as a util function, since it's Leaflet specific. * create layer-.whenElemsReady method to check if the children elems of layer- are ready, create Util.extentToBounds for announcemovement * refactor debugMode, totalLayerBounds, AnnounceMovement * Get debugMode.test.js working * featureIndexOverlayResults needs to be in slowMo to work reliably WIP: Add data-testid to multipleExtents.test fixture. Update playwright to use locators, locator assertions. Note that I don't believe the layer bounds were ever being rendered by the debugOverlay, only a duplicate of the map-link at the map-extent level, which seemed to be that of the layer-, but was only a duplicate due to misuse of layerBounds at the map-extent level. To be discussed with team. Note that current failing test fails due to the map extent in the layer control not being correctly disabled, even though (I believe) the <map-extent> is disabled (has disabled attribute, at least). * WIP on multiple extents test semantics in-progress elimination of MapMLLayer._properties._mapExtents. * Refactor layer.js._calculateExtent into layer.js.extent + MapMLLayer._calculateBounds + map-extent.js._calculateBounds Fix problem with MapMLLayer._calculateExtent that wasn't calculating the zoom bounds properly. Problem visible on main when clicking on Finland or Sweden in Arctic SDI. Add some guard conditions to AnnounceMovement.totalBounds, which was firing too early in the map's life cycle and was causing issues with layers and descendant elements being not ready. Make layer.whenReady() a bit stronger, by determining if the shadowroot is ready too, which may head off some timing problems. * WIP on multiple extents test semantics. * get rid of layerControl._validateInput, make layer- and map-extent elements create and update the layerControl by themselves when needed; move the logic of creating layer-'s layerControlHTML from MapMLLayer.js to layer-.js * Upgrade playwright to 1.39.0 Update multipleExtents.test.js * WIP: refactor to get rid of _properties._mapExtents, make layer- and map-extent handle their own layerControlHTML (create and update), fix bugs showing up in experiments * add event listener on layer- to listen to layer- checked property changes, when it is changed trigger the _handlechange method of mapExtent to ensure the mapExtent._templatedLayer can be added to / removed from the map properly * remove trailing '/' from from xmlns links * Init checkbox defaultChecked for map-extent, layer- * get rid of MapMLLayer._validateExtent, add projection check in mapExtent._validateDisabled, create .catch for use cases of mapExtent.whenReady(), handle the timing issue of projection change * clean up the templatedTileLayer._container when the templatedTileLayer is removed, to fix the bug that the templated tiles cannot be rendered properly when zoom level is changed before it is readded to the map * Add rejection to map-extent, map-input in the case of the element being disconnected while waiting for whenReady. This can happen during API usage for example, when changing the map projection soon after map creation, resulting in the connectedCallbacks being called and attributeChangedCallbacks being called but the element is disconnected before that cycle can complete. Added the rejection in this case so that it is clear what happens. Added conditional enabling of announceMovement handler after projection change on mapml-viewer, because it should only be enabled when the setting calls for it to be so (otherwise errors can occur during the totalBounds method of the handler, due to nothing being ready). * Make it so that createLayerControlHTML works unconditionally, was causing issues when the layer was re-initialized due to changeprojection event happening during initialization. * Enable <select> as a control in <map-extent>, which will break keyboard tests, possibly others, because tab order to get to the select will be different. * get layer and extent layer control disabled properly + move over code for map-extent.createLayerControlExtentHTML to a seperate supporting file * update Gruntfile * grouping the radio buttons of styles in layerControl based on an unique identifier, to fix the bug that style does not have a default selection * invoke mapExtent.handlechange when the map projection is changed to make sure templatedLayers are properly added to the map; remove the map-change event listener of layer- after the map-extent is disconnected * Workaround leaflet bug when changing map.options.crs #2553 * Make map-input.connectedCallback async, await on extent.whenReady() for setup * WIP on map-extent Get checkbox working via API map-extent.checked. Change TemplatedLayer and related child layer types. * Upgrade playwright to 1.39.0 Update multipleExtents.test.js * get rid of layerControl._validateInput, make layer- and map-extent elements create and update the layerControl by themselves when needed; move the logic of creating layer-'s layerControlHTML from MapMLLayer.js to layer-.js * WIP: refactor to get rid of _properties._mapExtents, make layer- and map-extent handle their own layerControlHTML (create and update), fix bugs showing up in experiments * add event listener on layer- to listen to layer- checked property changes, when it is changed trigger the _handlechange method of mapExtent to ensure the mapExtent._templatedLayer can be added to / removed from the map properly * remove trailing '/' from from xmlns links * get rid of MapMLLayer._validateExtent, add projection check in mapExtent._validateDisabled, create .catch for use cases of mapExtent.whenReady(), handle the timing issue of projection change * Init checkbox defaultChecked for map-extent, layer- * clean up the templatedTileLayer._container when the templatedTileLayer is removed, to fix the bug that the templated tiles cannot be rendered properly when zoom level is changed before it is readded to the map * Add rejection to map-extent, map-input in the case of the element being disconnected while waiting for whenReady. This can happen during API usage for example, when changing the map projection soon after map creation, resulting in the connectedCallbacks being called and attributeChangedCallbacks being called but the element is disconnected before that cycle can complete. Added the rejection in this case so that it is clear what happens. Added conditional enabling of announceMovement handler after projection change on mapml-viewer, because it should only be enabled when the setting calls for it to be so (otherwise errors can occur during the totalBounds method of the handler, due to nothing being ready). * Make it so that createLayerControlHTML works unconditionally, was causing issues when the layer was re-initialized due to changeprojection event happening during initialization. * Enable <select> as a control in <map-extent>, which will break keyboard tests, possibly others, because tab order to get to the select will be different. WIP / to do: disable the extent controls, italicize the text labels for them * get layer and extent layer control disabled properly + move over code for map-extent.createLayerControlExtentHTML to a seperate supporting file * update Gruntfile * grouping the radio buttons of styles in layerControl based on an unique identifier, to fix the bug that style does not have a default selection * invoke mapExtent.handlechange when the map projection is changed to make sure templatedLayers are properly added to the map; remove the map-change event listener of layer- after the map-extent is disconnected * Workaround leaflet bug when changing map.options.crs #2553 * Workaround leaflet bug when changing map.options.crs #2553 part deux * Make opacity implementation the same for both layer- and map-extent Fix incorrect reference to _propertiesGroupAnatomy for map-extent (it's a property of parent layer element), it's the root fieldset that contains the individual map-extent fieldsets. Change class on map-extent's <details> for opacity from `mapml-layer-item-details` to `mapml-layer-item-opacity mapml-control-layers` Fix checked attribute for layer test failure * add the setTimeout for the layer-._validateDisable back, to make sure the validateDisabled happen after the moveend so that the result for validation is correct * Sync mapml-viewer -> web-map.js * Enable layer-.whenReady to handle fetch errors without waiting for the full 5s timeout. * Get tests working * Remove .only from some tests preventing full suite from running * sync multipleExtents tests with PR * Fix markup in mapSpan.html * fix failing test; migrate map-meta[name] from remote mapml to the shadowroot of layer-, make the staticTileLayer read zoom bounds from map-meta instead of map-tile, add whenReady in MapInput.attributechangecallback * fix the typo from map-meta[name=projection] to map-meta[name=zoom]; do L.extend on this.options instead of on the local options var * add settimeout in debugoverlay._addbounds to delay the function call until the layer.layerbounds / layer.extentbounds are ready after layer-.checked attribute is changed, modify the test to adapt the changes * sync mapml-viewer test with web-map * add constants.js to dist and import it in map-extent.js, remove unused import for constant.js and some unused variables in other files * Projection change test when following link to layer with default bounds based on the name, ('Debug components update with projection changes') this test may need revisiting; the only thing that is tested is that the map bounds changes when the link is loaded to replace the current layer. To me it seems that the test is failing silently on main tbd * make the minzoom and maxzoom of staticTileLayer read from map-meta instead of being calculated the map-tile zoom attribute; prettier formatting for projectionchange.test; enable ci testing * Add whenReady().then().catch() blocks to layer-.attributeChangedCallback usage. Lack of catch processing led to slow processing when pasting an invalid / unavailable link onto the map. * Set --workers=1 for playwright testing, be kind to github actions * add slowmo to the debugmode.test, history.test * add slowmo to a few tests to get GitHub CI testing pass * change the returned format of the zoom getter of mapmlviewer from String to Number, update tests accordingly; some prettier formatting for tms and clientTemplatedTileLayer tests * change map lat, lon, width and height getters to return a Number instead of String, update tests * add waitfortimeout for flaky tests to pass GitHub CI testing * Return number for layer-, map-extent.opacity, mapml-viewer.width, .height, .lat, .lon. Amend tests to enforce this. * move dist to right place for grunt web-map-doc * Bundle everything possible into mapml.js, use M. to access global symbols * initialize this._opacity of layer- and map-extent with the attribute value (if exists) or 1.0 as default; add waitfortimeout and slowmo to fix flaky tests * Add tests for map-extent attribute api. Fix bug in same. * Add test for template feature being disabled when going out of bounds * Change class on opacity details/summary for map-extent layer control --------- Co-authored-by: AliyanH <aliyanulhaq@gmail.com> Co-authored-by: prushfor <prushfor@L-BSC-A146390.nrn.nrcan.gc.ca> Co-authored-by: Aliyan Haq <55751566+AliyanH@users.noreply.github.com> Co-authored-by: yhy0217 <yhy0218th@gmail.com>
PreviousNext