Skip to content

Commit

Permalink
In currentPathWithView, normalize longitude to be within -180,180
Browse files Browse the repository at this point in the history
  • Loading branch information
wbazant committed Nov 10, 2024
1 parent 8487b5c commit 7f06b02
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/utils/appUrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export const currentPathWithView = (view) => {
const path = stateIndex === -1 ? pathname : pathname.substring(0, stateIndex)

// 7 decimal places gives precision to 1 cm
return `${path}/@${view.center.lat.toFixed(7)},${view.center.lng.toFixed(
7,
)},${view.zoom}z`
// Normalize longitude to -180 to 180 range
const normalizedLng = ((view.center.lng + 540) % 360) - 180
return `${path}/@${view.center.lat.toFixed(7)},${normalizedLng.toFixed(7)},${
view.zoom
}z`
}

0 comments on commit 7f06b02

Please sign in to comment.