Skip to content

fix(map): fit bounds to all returned routes#474

Merged
DennisOSRM merged 2 commits into
gh-pagesfrom
fix/fit-all-route-bounds
May 23, 2026
Merged

fix(map): fit bounds to all returned routes#474
DennisOSRM merged 2 commits into
gh-pagesfrom
fix/fit-all-route-bounds

Conversation

@DennisOSRM
Copy link
Copy Markdown
Contributor

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 23, 2026 20:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the map “fit bounds” behavior so that when multiple routes (primary + alternatives) are returned, the viewport is fit to the combined geometry rather than only the selected route.

Changes:

  • Add src/route_zoom.js helper to collect bounds coordinates across all available routes (with a fallback).
  • Update the routeselected handler in src/index.js to compute bounds from all returned routes.
  • Add unit tests validating coordinate combination and fallback behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
src/index.js Uses combined route coordinates for L.latLngBounds() when fitting the map view.
src/route_zoom.js Introduces getBoundsCoordinates() to aggregate coordinates across multiple routes.
test/route_zoom.test.js Adds unit coverage for the new bounds-coordinate aggregation helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/route_zoom.js Outdated

sourceRoutes.forEach(function(route) {
if (route && Array.isArray(route.coordinates) && route.coordinates.length) {
coordinates = coordinates.concat(route.coordinates);
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@DennisOSRM DennisOSRM merged commit 8c67495 into gh-pages May 23, 2026
9 checks passed
@DennisOSRM DennisOSRM deleted the fix/fit-all-route-bounds branch May 23, 2026 21:06
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.

2 participants