Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> Co-authored-by: prushfor <[email protected]> Co-authored-by: Aliyan Haq <[email protected]> Co-authored-by: yhy0217 <[email protected]>
- Loading branch information