Skip to content

#11162: Improve MS actions to automatically zoom to filtered features#11163

Merged
MV88 merged 3 commits intogeosolutions-it:masterfrom
mahmoudadel54:issue_11162
Jun 16, 2025
Merged

#11162: Improve MS actions to automatically zoom to filtered features#11163
MV88 merged 3 commits intogeosolutions-it:masterfrom
mahmoudadel54:issue_11162

Conversation

@mahmoudadel54
Copy link
Contributor

@mahmoudadel54 mahmoudadel54 commented Jun 2, 2025

Description

This PR enhances the zoom process to the filter features using query params action. It includes:

  • enhance zooming functionality if the queried layers is just one by auto zooming
  • automate that zoom process without the need to include any coordinates in query param action url

This PR addresses 2 handles 2 points:

  1. if the identified feature is within the stored map extent [visible on map] but behind the identify sidebar in code like: https://dev-mapstore.geosolutionsgroup.com/mapstore/#/viewer/51039?mapInfo=gs:us_states&mapInfoFilter=STATE_NAME='Maine'
  • if just one layer to be identified [which matches with the query-param above] the action of updateCenterToMarker is disabled so it just open the identify info without center the map to the identify marker, you can check this:
    if (!map || !layoutBounds || !coords || action.point.cartographic || isInsideVisibleArea(coords, map, layoutBounds, resolution) || isMouseMoveIdentifyActiveSelector(state)) {
  • You can reproduce another case here if you click on a feature at the place behind the sidebar of identify in just one layer in TOC or one layer visible and others hidden ---> the updateCenterToMarker will be disabled as well as it suppose the feature inside the visible area
  1. The other point, center to marker implement zoom to the point of marker but with the zoom level of map so I implemented in this PR getting bbox from the identified feature and apply zoomToExtent and it works as required

Please check if the PR fulfills these requirements

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

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

Issue

#11162

What is the current behavior?

#11162

What is the new behavior?

When a user opens the map viewer with a query parameter that includes 'mapinfo' and 'mapInfoFilter', but without specifying any coordinates, the application will automatically zoom to the bounding box of the filtered feature. For example, accessing the following URL:

http://localhost:8081/#/viewer/55570?mapinfo=unesco:Unesco_point&mapInfoFilter=componente='Centro%20storico%20di%20Roma'

will result in the map automatically zooming to the extent of the filtered feature.

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

…ltered features

- enhance zooming functionality if the queried layers is just one by auto zooming
- automate that zoom process without the need to include any coordinates
- add unit tests
@mahmoudadel54 mahmoudadel54 self-assigned this Jun 2, 2025
@mahmoudadel54 mahmoudadel54 added enhancement New Feature used for new functionalities BackportNeeded Commits provided for an issue need to be backported to the milestone's stable branch labels Jun 2, 2025
@mahmoudadel54 mahmoudadel54 linked an issue Jun 2, 2025 that may be closed by this pull request
6 tasks
@tdipisa tdipisa added this to the 2025.01.01 milestone Jun 3, 2025
@tdipisa tdipisa requested review from MV88 and removed request for allyoucanmap June 3, 2025 08:31
Copy link
Contributor

@MV88 MV88 left a comment

Choose a reason for hiding this comment

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

After synching with @tdipisa we decided to apply these expected behaviours

  • when no center, marker, bbox or zoom are provided as query params the zoom to feature bbox must not be used.

so

the following will use map zoom level but will override center
https://dev-mapstore.geosolutionsgroup.com/mapstore/#/viewer/51039?mapInfo=gs:us_states&mapInfoFilter=STATE_NAME='Maine'&center=12,15

same in the case of marker prop
https://dev-mapstore.geosolutionsgroup.com/mapstore/#/viewer/51039?mapInfo=gs:us_states&mapInfoFilter=STATE_NAME='Maine'&marker=3,6

this will use map center but will override zoom level
https://dev-mapstore.geosolutionsgroup.com/mapstore/#/viewer/51039?mapInfo=gs:us_states&mapInfoFilter=STATE_NAME='Maine'&zoom=15

this will zoom to the extent provided in bbox param
https://dev-mapstore.geosolutionsgroup.com/mapstore/#/viewer/51039?mapInfo=gs:us_states&mapInfoFilter=STATE_NAME='Maine'&bbox=8,8,53,53

this will generate featurebbox and zoom to its extent
https://dev-mapstore.geosolutionsgroup.com/mapstore/#/viewer/51039?mapInfo=gs:us_states&mapInfoFilter=STATE_NAME='Maine'

- handle when no center, marker, bbox or zoom are provided as query params the zoom to feature bbox must not be used
- add unit tests
- add jsdocs
@mahmoudadel54 mahmoudadel54 requested a review from MV88 June 13, 2025 13:02
Copy link
Contributor

@MV88 MV88 left a comment

Choose a reason for hiding this comment

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

this looks not to be working, seems that bbox alone is not enough to zoom to it

http://localhost:8081/?debug=true#/viewer/51039?mapInfo=gs:us_states&mapInfoFilter=STATE_NAME='Maine'&bbox=2,2,2,3

@mahmoudadel54
Copy link
Contributor Author

this looks not to be working, seems that bbox alone is not enough to zoom to it

http://localhost:8081/?debug=true#/viewer/51039?mapInfo=gs:us_states&mapInfoFilter=STATE_NAME='Maine'&bbox=2,2,2,3

I have checked it locally and it seems work

2025-06-16.17-40-58.mp4

@MV88 MV88 merged commit da249a5 into geosolutions-it:master Jun 16, 2025
6 checks passed
@MV88
Copy link
Contributor

MV88 commented Jun 16, 2025

@ElenaGallo please test it in DEV

@ElenaGallo
Copy link
Contributor

Test passed, @mahmoudadel54 backport to 2025.01.xx. Thanks

mahmoudadel54 added a commit to mahmoudadel54/MapStore2 that referenced this pull request Jun 19, 2025
…ltered features (geosolutions-it#11163)

* geosolutions-it#11162: Improve MS actions to automatically zoom to filtered features
- enhance zooming functionality if the queried layers is just one by auto zooming
- automate that zoom process without the need to include any coordinates
- add unit tests

* resolve review comments:
- handle when no center, marker, bbox or zoom are provided as query params the zoom to feature bbox must not be used
- add unit tests
- add jsdocs

* resolve FE test failure in QueryParamsUtils
@mahmoudadel54
Copy link
Contributor Author

Test passed, @mahmoudadel54 backport to 2025.01.xx. Thanks

Backport is done ---> #11226

@tdipisa tdipisa removed the BackportNeeded Commits provided for an issue need to be backported to the milestone's stable branch label Jun 19, 2025
tdipisa pushed a commit that referenced this pull request Jun 19, 2025
…#11163) (#11226)

* #11162: Improve MS actions to automatically zoom to filtered features
- enhance zooming functionality if the queried layers is just one by auto zooming
- automate that zoom process without the need to include any coordinates
- add unit tests

* resolve review comments:
- handle when no center, marker, bbox or zoom are provided as query params the zoom to feature bbox must not be used
- add unit tests
- add jsdocs

* resolve FE test failure in QueryParamsUtils
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New Feature used for new functionalities

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve MS actions to automatically zoom to filtered features

4 participants