Skip to content

#12650: Zoom to filtered layer from the filter widget - #12707

Merged
allyoucanmap merged 4 commits into
geosolutions-it:masterfrom
dsuren1:#12650_zoomTo
Jul 31, 2026
Merged

allyoucanmap merged 4 commits into
geosolutions-it:masterfrom
dsuren1:#12650_zoomTo

Conversation

@dsuren1

@dsuren1 dsuren1 commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR enhances the dynamic filter widget by adding a new interaction Zoom To which let's the user perform autoZoom or manual zoom on the target map. Dashboard: one target per map

Please check if the PR fulfills these requirements

What kind of change does this PR introduce? (check one with "x", remove the others)

  • Feature

Issue

What is the current behavior?

What is the new behavior?

  • Zoom the map to the filtered geometry of connected layers. Supports both manual zoom via a button and automatic zoom when filters change.

    Map

    zoom-to.mp4

    Dashboard

    zoom-to-dashboard.mp4

Breaking change

Does this PR introduce a breaking change? (check one with "x", remove the other)

  • Yes, and I documented them in migration notes
  • No

Other useful information

@dsuren1 dsuren1 added this to the 2026.03.00 milestone Jul 21, 2026
@dsuren1
dsuren1 requested a review from offtherailz July 21, 2026 14:48
@dsuren1 dsuren1 added the New Feature used for new functionalities label Jul 21, 2026
@cla-bot cla-bot Bot added the CLA Ready label Jul 21, 2026
@dsuren1 dsuren1 linked an issue Jul 21, 2026 that may be closed by this pull request
10 tasks
@dsuren1
dsuren1 requested review from allyoucanmap and removed request for offtherailz July 27, 2026 13:14
@dsuren1 dsuren1 assigned allyoucanmap and unassigned offtherailz Jul 27, 2026

@allyoucanmap allyoucanmap left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No cleanup path handles APPLY_ZOOM_TO, so a plugged zoom-to interaction can outlive the applyFilter sibling it depends on, how to reproduce:

  • open a map and add a wms layer
  • add a filter widget
  • connect the filter widget to the layer
  • connect the zoom to action to the layer
  • save the widget
  • verify the zoom to is working
  • edit the widget again
  • disconnect only the filter interaction
  • save the widget
  • Expected the zoom to button is not visible because there is not event filter applied
  • Current the zoom to button is visible even if there is not event filter applied

Comment on lines +38 to +727
@@ -714,13 +715,16 @@ class OpenlayersMap extends React.Component {
const isDegenerate = bounds[0] === bounds[2] && bounds[1] === bounds[3];
// TODO: allow maxZoom to be customizable
const maxZoom = isDegenerate && isNil(zoomLevel) ? 21 : zoomLevel;
const mapEl = this.map.getTargetElement();
const {top = 0, right = 0, bottom = 0, left = 0} = resolveZoomToExtentPadding(mapEl, padding);
const paddingValues = [top, right, bottom, left];
this.map.getView().fit(bounds, {
size: this.map.getSize(),
// mapPaddingSelector returns null while the layout epic is mid-computation
// (e.g. during a setView swap on projection change). Pass undefined in that
// case so OL applies its own [0,0,0,0] default - passing null reaches
// View.fitInternal where padding[1] dereferences and throws.
...(padding ? { padding: [padding.top || 0, padding.right || 0, padding.bottom || 0, padding.left || 0] } : {}),
...(paddingValues.some(value => value > 0) ? { padding: paddingValues } : {}),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better we don't include Widgets logic inside the Map component, so please restore this file. We should avoid to import this utils and the padding should be resolved at epic level when we are using buildZoomToExtentAction (note buildZoomToExtentAction has a padding argument but never used). If we externalize this to the epic also the Cesium map will get the correct padding without changes on the map engine components

@dsuren1 dsuren1 Jul 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would require updating the Cesium map component as well, since it currently doesn't account for padding. I initially thought this was intentional and focused only on the OpenLayers map, but it looks like the padding support may have been missed in the original Cesium implementation. I will update it to handle the padding consistently

Comment thread web/client/components/widgets/enhancers/interactionZoomToExtent.js Outdated
Comment thread web/client/epics/interactions.js Outdated
* Values are arrays to support multiple targets per event.
*/
export const EVENT_TARGET_MAP = {
[EVENTS.FILTER_CHANGE]: [TARGET_TYPES.APPLY_FILTER, TARGET_TYPES.APPLY_STYLE, TARGET_TYPES.APPLY_DIMENSION]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to add APPLY_ZOOM_TO event?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so. EVENT_TARGET_MAP isn't used anywhere yet

@dsuren1
dsuren1 requested a review from allyoucanmap July 29, 2026 14:49
@allyoucanmap
allyoucanmap merged commit 5de1ed5 into geosolutions-it:master Jul 31, 2026
15 checks passed
@allyoucanmap

Copy link
Copy Markdown
Contributor

@ElenaGallo please test this enhancement on dev, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Ready New Feature used for new functionalities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Filter Widget] Zoom to filtered layer from the filter widget

3 participants