Skip to content

added the recenter-route feature control file#342

Draft
s4chinjha wants to merge 2 commits intovalhalla:masterfrom
s4chinjha:recenter-route
Draft

added the recenter-route feature control file#342
s4chinjha wants to merge 2 commits intovalhalla:masterfrom
s4chinjha:recenter-route

Conversation

@s4chinjha
Copy link
Contributor

This Pr Closes #339 and adds a Recenter button to the map.

🛠️ Fixes Issue

As mentioned in issue #339, after Pr #336 disabled automatic map zooming, there was no way to return to the route once you pan or zoom away from it. So i wanted to add a simple control to recenter the map to the current route.

👨‍💻 Changes proposed

  • Added the recenter-route button to the map as propose in the issue
  • New button in the top-right MapLibre control group below Map Styles
  • Used a crosshair icon with the tooltip "Recenter to route"
  • Clicking the button fits the entire route back into view.
  • Button is hidden when no route is present and reappears automatically when a route is loaded.

📄 Note to reviewers

  • I have reused the bounds calculation, padding logic, and fitBounds call from the zoom effect in src/components/map/index.tsx.
  • The button was not hiding after resetting waypoints (same root cause as issue Map zooms too agressively to route extents #326) which I fixed by checking successful from directionsStore instead of coordinates, since successful is set to false when clearRoutes() is called.

📷 Screenshots

A img just to show how it looks
image

@gisops-bot
Copy link

Preview is ready! 🚀 You can view it here: https://valhalla-app-tests.gis-ops.com/342

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.

Add a button that would recenter map to current route

2 participants