From e89f6ad98bb2a061800ffaa3f79b3a350d01120e Mon Sep 17 00:00:00 2001 From: Jonas Date: Wed, 27 Sep 2023 14:51:34 +0200 Subject: [PATCH 1/5] Respect origin setting (#1835) --- src/maputils.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/maputils.js b/src/maputils.js index 9e0bdac94..cbaf69115 100644 --- a/src/maputils.js +++ b/src/maputils.js @@ -45,7 +45,9 @@ const maputils = { tileGrid: function tileGrid(settings, defaultSettings = {}) { const tileGridSettings = Object.assign({}, defaultSettings, settings); const extent = tileGridSettings.extent; - tileGridSettings.origin = tileGridSettings.alignBottomLeft === false ? getTopLeft(extent) : getBottomLeft(extent); + if (!tileGridSettings.origin) { + tileGridSettings.origin = tileGridSettings.alignBottomLeft === false ? getTopLeft(extent) : getBottomLeft(extent); + } return new TileGrid(tileGridSettings); }, checkZoomChange: function checkZoomChange(resolution, currentResolution) { From 4802902e6f18fe394edf9c7fd37302f82c386d7d Mon Sep 17 00:00:00 2001 From: Jonas Date: Wed, 27 Sep 2023 14:51:49 +0200 Subject: [PATCH 2/5] Rename legend (#1839) --- src/controls/print/print-settings.template.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controls/print/print-settings.template.js b/src/controls/print/print-settings.template.js index a58071a2d..dc3ac49d8 100644 --- a/src/controls/print/print-settings.template.js +++ b/src/controls/print/print-settings.template.js @@ -52,7 +52,7 @@ export default function printTemplate({
-
Visa legend
+
Visa teckenförklaring
${printLegendControl.render()}
From ab0916af66d671f690d876dce85b1dea0957c79f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Bl=C3=A4sta?= Date: Wed, 11 Oct 2023 10:58:16 +0200 Subject: [PATCH 3/5] fix: bad url for icon in print legend --- src/controls/print/print-legend.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controls/print/print-legend.js b/src/controls/print/print-legend.js index 9e89f098b..af0edf42f 100644 --- a/src/controls/print/print-legend.js +++ b/src/controls/print/print-legend.js @@ -61,7 +61,7 @@ const LayerRow = function LayerRow(options) { const layerName = aLayer.get('name'); const style = viewer.getStyle(aLayer.get('styleName')); if (style && style[0] && style[0][0] && style[0][0].icon) { - return `${style[0][0].icon.src}&format=${format}`; + return `${style[0][0].icon.src}?format=${format}`; } return `${url}?SERVICE=WMS&layer=${layerName}&format=${format}&version=1.1.1&request=getLegendGraphic&scale=401&legend_options=dpi:300`; }; From 891cc4ed05ad51e126f5202690a88ead66c0c433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Bl=C3=A4sta?= Date: Wed, 11 Oct 2023 11:48:57 +0200 Subject: [PATCH 4/5] check for ? --- src/controls/print/print-legend.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/controls/print/print-legend.js b/src/controls/print/print-legend.js index af0edf42f..3a64430f4 100644 --- a/src/controls/print/print-legend.js +++ b/src/controls/print/print-legend.js @@ -61,6 +61,9 @@ const LayerRow = function LayerRow(options) { const layerName = aLayer.get('name'); const style = viewer.getStyle(aLayer.get('styleName')); if (style && style[0] && style[0][0] && style[0][0].icon) { + if (style[0][0].icon.src.includes('?')) { + return `${style[0][0].icon.src}&format=${format}`; + } return `${style[0][0].icon.src}?format=${format}`; } return `${url}?SERVICE=WMS&layer=${layerName}&format=${format}&version=1.1.1&request=getLegendGraphic&scale=401&legend_options=dpi:300`; From 1da8d53934468ed94a4fd79b5b64aa05b94e9689 Mon Sep 17 00:00:00 2001 From: Stefan Forsgren <33832077+steff-o@users.noreply.github.com> Date: Fri, 20 Oct 2023 10:56:30 +0200 Subject: [PATCH 5/5] fix: don't use state attribut for highlight (#1855) * Remove state attrib POC * Cleaned up state attrib POC --------- Co-authored-by: Stefan Forsgren --- src/selectionmanager.js | 43 +++++++++++++++++++++++++++++------------ 1 file changed, 31 insertions(+), 12 deletions(-) diff --git a/src/selectionmanager.js b/src/selectionmanager.js index feb57f0d5..d3e216c03 100644 --- a/src/selectionmanager.js +++ b/src/selectionmanager.js @@ -28,6 +28,9 @@ const Selectionmanager = function Selectionmanager(options = {}) { /** The selectionmanager component itself */ let component; + /** Keeps track of highlighted features. Stores pointers to the actual features. */ + let highlightedFeatures = []; + const multiselectStyleOptions = options.multiSelectionStyles || styleTypes.getStyle('multiselection'); const isInfowindow = options.infowindow === 'infowindow' || false; const infowindowManager = options.infowindowOptions && options.infowindowOptions.listLayout ? infowindowManagerV2 : infowindowManagerV1; @@ -84,6 +87,13 @@ const Selectionmanager = function Selectionmanager(options = {}) { }); } + /** Helper that refreshes all urvallayers. Typically called after highlightning or symbology has changed */ + function refreshAllLayers() { + urval.forEach((value) => { + value.getFeatureStore().changed(); + }); + } + /** * Highlights the feature with fid id. * All other items are un-highlighted @@ -94,18 +104,13 @@ const Selectionmanager = function Selectionmanager(options = {}) { selectedItems.forEach((item) => { const feature = item.getFeature(); if (item.getId() === id) { - feature.set('state', 'selected'); + highlightedFeatures = [feature]; component.dispatch('highlight', item); - } else { - // FIXME: Second argument should be a bool. Change to true to intentionally supress event, or remove second arg to emit the event. May affect the all other layers refresh below - feature.unset('state', 'selected'); } }); - // we need to manually refresh other layers, otherwise unselecting does not take effect until the next layer refresh. - urval.forEach((value) => { - value.getFeatureStore().changed(); - }); + // We need to manually refresh all layers, otherwise selecting and unselecting does not take effect until the next layer refresh. + refreshAllLayers(); } function highlightAndExpandItem(item) { @@ -148,12 +153,17 @@ const Selectionmanager = function Selectionmanager(options = {}) { } function clearSelection() { + // This will trigger onItemremove for each feature and refresh layers etc selectedItems.clear(); component.dispatch('cleared', null); } + /** + * Callback function that styles a feature when it is drawn. + * @param {any} feature + */ function featureStyler(feature) { - if (feature.get('state') === 'selected') { + if (highlightedFeatures.includes(feature)) { return Style.createStyleRule(multiselectStyleOptions.highlighted); } return Style.createStyleRule(multiselectStyleOptions.selected); @@ -257,6 +267,10 @@ const Selectionmanager = function Selectionmanager(options = {}) { return retval.join('
'); } + /** + * Callback function called when a SelectedItem is added to selectedItems + * @param {any} event + */ function onItemAdded(event) { const item = event.element; @@ -280,6 +294,10 @@ const Selectionmanager = function Selectionmanager(options = {}) { infowindow.updateSelectionGroupFooter(selectionGroup, aggregationstring); } + /** + * Callback function called when a SelectedItem is removed from selectedItems + * @param {any} event + */ function onItemRemoved(event) { const item = event.element; @@ -287,8 +305,8 @@ const Selectionmanager = function Selectionmanager(options = {}) { const selectionGroupTitle = event.element.getSelectionGroupTitle(); const feature = item.getFeature(); - // FIXME: second argument should be a bool. True supresses event. 'selected' will be treated as true. Maybe correct, but not obvious. - feature.unset('state', 'selected'); + // Remove from highlighted as feature does not exist in the layer anymore + highlightedFeatures = highlightedFeatures.filter(f => f !== feature); urval.get(selectionGroup).removeFeature(feature); infowindow.removeListElement(item); @@ -312,7 +330,8 @@ const Selectionmanager = function Selectionmanager(options = {}) { * @param {any} feature The feature to highlight */ function highlightFeature(feature) { - feature.set('state', 'selected'); + highlightedFeatures.push(feature); + refreshAllLayers(); } function getNumberOfSelectedItems() {