Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drive zone forecast with map search #131

Merged
merged 5 commits into from
Nov 25, 2024
Merged

Drive zone forecast with map search #131

merged 5 commits into from
Nov 25, 2024

Conversation

jdudley1123
Copy link
Member

@jdudley1123 jdudley1123 commented Nov 25, 2024

Context

Currently the user specifies the location they want a forecast for by using a dropdown select. Separately there is a search control on the map to find places of interest. These two are not connected.
Trello: https://trello.com/c/00JLpGKY/110-location-search, https://trello.com/c/wk90EFVM/79-investigate-how-map-zooming-panning-might-impact-page-content

There is also an issue with ghost maps being retained when switching between views with Turbo, and in some cases the use of the forward and back buttons on the browser not working. Trello: https://trello.com/c/rhN3V2Fa/128-fix-ghost-maps-on-turbo-back-and-forth

Changes in this PR

This PR removes the zone select and makes the map search and pan change the forecast zone.

To achieve this we first have to change the way we render updates on the page. Currently we have a single Turbo frame that contains all of the forecast content. This allows us to update everything in one go when the location selector form changes. However, it also means replacing the map unnecessarily, and that is a unuseable when the map is driving those changes in the first place.

This PR splits the frame into two, a top and a bottom (with the map inbetween them). We use a Turbo stream, triggered by the location selector form to update these frames.

We then add two listeners, one for search and one for pan/zoom. When the map is panned or zoomed, get the new centre coordinates and look them up in the zone polygons. When the map is searched we get the coordinates of the selected search result. This may return more than one zone where there are overlapping zones of different levels. We choose between them using the zoom. If the coordinate falls outside of a zone, we ignore it and stay on the zone we were one before.

Screenshots of UI changes

Before

image

After

image

@jdudley1123 jdudley1123 changed the title Integrated search Drive zone forecast with map search Nov 25, 2024
When switching between the map and other views, Turbo caches the map. This leads to ghost versions of the map being retained, and in some cases the use of the forward and back buttons on the browser not working.

This change stops Turbo from caching the page at all, fixing the problem.
Currently we have a single turbo frame that contains all of the forecast content. This allows us to update everything in one go. However, it also means replacing the map unnecessarily. That was fine previously, but now we want to use map panning and zooming to trigger changes to the forecast that won't work anymore.

This change splits the frame into two, a top and a bottom (with the map inbetween them). We use a Turbo stream, triggered by the location selector form to update these frames.
When the map is panned or zoomed, get the new centre coordinates and look them up in the zone polygons. This may return more than one zone where there are overlapping zones of different levels. We choose between them using the zoom.

The forecast is then updated to match that zone.
Remove the zone dropdown and instead drive zone selection with the search function of the map.
We need the zone to be a top level zone because the map starts zoomed out.
Copy link

To automatically rebase, you need to add a personal access token with the name AUTO_REBASE_PERSONAL_ACCESS_TOKEN to the secrets section of this repo.

Once this is done, you can try the /rebase command again.

@jdudley1123 jdudley1123 disabled auto-merge November 25, 2024 17:49
@jdudley1123 jdudley1123 merged commit e71d0e1 into develop Nov 25, 2024
3 of 4 checks passed
@jdudley1123 jdudley1123 deleted the integrated-search branch November 25, 2024 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant