mirror of
https://github.com/zvx-echo6/navi.git
synced 2026-05-20 22:54:42 +02:00
fix(map): Always zoom in to fit boundaries, never zoom out
Replace blanket z14 cap with zoom-in-only logic for boundary fitBounds: - target.zoom > currentZoom → zoom IN to fit boundary (always allowed) - target.zoom < currentZoom → skip fitBounds (never zoom out) - target.zoom == currentZoom → allow pan to center This means: - Click Portland at z5 → fly in to ~z10 to show city boundary - Click Idaho at z5 → fly in to ~z6 to show state boundary - Click Portland at z15 → boundary draws, camera stays at z15 The z14 cap for selectedPlace flyTo (search results without boundary) is preserved - that only affects the initial flyTo to coordinates. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
bd372b9dc9
commit
62669fc7de
1 changed files with 16 additions and 8 deletions
|
|
@ -2421,16 +2421,24 @@ const MapView = forwardRef(function MapView(_, ref) {
|
|||
// Validate bounds before fitting
|
||||
if (minLng >= -180 && maxLng <= 180 && minLat >= -90 && maxLat <= 90 &&
|
||||
minLng < maxLng && minLat < maxLat) {
|
||||
// Only fit bounds if zoomed out (< z14). At z14+ just draw boundary silently.
|
||||
const bounds = [[minLng, minLat], [maxLng, maxLat]]
|
||||
const currentZoom = map.getZoom()
|
||||
if (currentZoom < 14) {
|
||||
const bounds = [[minLng, minLat], [maxLng, maxLat]]
|
||||
map.fitBounds(bounds, {
|
||||
padding: 50,
|
||||
duration: 700,
|
||||
maxZoom: 16,
|
||||
})
|
||||
const target = map.cameraForBounds(bounds, { padding: 50 })
|
||||
|
||||
// Zoom-in only: allow zoom in to show boundary, never zoom out
|
||||
// - target.zoom > currentZoom → zoom IN to fit (always allowed)
|
||||
// - target.zoom < currentZoom → DON'T zoom out (skip fitBounds)
|
||||
// - target.zoom == currentZoom → pan only (allowed)
|
||||
if (!target || target.zoom < currentZoom) {
|
||||
// Would zoom out — just draw the boundary without moving camera
|
||||
return
|
||||
}
|
||||
|
||||
map.fitBounds(bounds, {
|
||||
padding: 50,
|
||||
duration: 700,
|
||||
maxZoom: 16,
|
||||
})
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue