Skip to content

Coordinate map camera padding with panels and add street-grid orientation snap #310

Description

@Medformatik

Problem

Map framing does not consistently account for desktop panels, mobile sheets, safe areas, and other visible obstructions. Separately, bearing reset always points north even when aligning with the local street grid would make an urban map easier to read.

Current state

  • Navigation has dedicated camera padding, while other fitBounds/flyTo calls often use fixed scalar padding.
  • There is no app-level registry for the actual unobscured map viewport.
  • resetBearing returns to north; there is no deterministic street-grid orientation estimate or snap behavior.

Proposed solution

Introduce a central map-obstruction/padding service used by every camera/framing operation. Add an optional grid-align action that derives a stable dominant road orientation near the current focus, snaps it with threshold/hysteresis, and always preserves an explicit north-reset action.

Acceptance criteria

  • Panels, drawers/sheets, navigation chrome, safe areas, and transient controls register their current map obstruction by edge.
  • The service computes one effective padding rectangle and updates MapLibre padding as layout changes.
  • Search results, places, routes, transit, imported geometry, offline-area selection, and deep links frame against the effective visible viewport.
  • Padding transitions are interruptible, avoid feedback loops/jitter, and honor reduced motion.
  • Mobile sheet detents and desktop panel resize/collapse are covered by layout tests.
  • Camera ownership rules prevent navigation tracking and a panel transition from fighting each other.
  • Grid orientation uses nearby drivable/visible road segments, length/importance weighting, and circular statistics modulo 90 degrees.
  • Low-confidence, sparse, curved, or conflicting grids do not rotate the map.
  • Snap threshold/hysteresis prevents oscillation and chooses the smallest understandable rotation.
  • Users can separately choose “align to streets” and “north up”; north reset remains predictable and accessible.
  • Computation is bounded/cached and does not issue broad network queries on every camera frame.
  • Visual/interaction tests cover dense grids, diagonal grids, rural roads, roundabouts, panel transitions, and RTL/safe-area layouts.

Alternatives considered

Per-feature padding fixes continue drift. Automatically rotating on every location change is disorienting; grid alignment should be deliberate and confidence-gated.

Area

Map camera, layout, navigation, accessibility.

References

  • apps/web/src/lib/MapContext.tsx
  • apps/web/src/lib/navigation/useNavCamera.ts
  • apps/web/src/components/map/MapControls.tsx

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestneeds-triageNeeds initial review and categorization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions