Fix flyto
This commit is contained in:
parent
32e0dc7395
commit
70ac7b95e6
1 changed files with 13 additions and 3 deletions
|
|
@ -146,6 +146,12 @@ export default function LocationSearch({
|
|||
if (result.type === 'place') {
|
||||
const zoom = ZOOM_FOR_TYPE[result.place_type] ?? 14;
|
||||
const flyZoom = result.place_type === 'outcode' ? POSTCODE_SEARCH_ZOOM : zoom;
|
||||
// Move the camera straight away using the coordinates already in the
|
||||
// search result. The nearest-postcode lookup below only feeds the side
|
||||
// panel, so gating the fly on it (and on isCurrentLookup) made the jump
|
||||
// intermittent whenever that request was slow, failed, or was superseded
|
||||
// by another keystroke/selection.
|
||||
if (!isMobile) onFlyTo(result.lat, result.lon, flyZoom);
|
||||
try {
|
||||
const params = new URLSearchParams({
|
||||
lat: String(result.lat),
|
||||
|
|
@ -172,7 +178,6 @@ export default function LocationSearch({
|
|||
markerLatitude: result.lat,
|
||||
markerLongitude: result.lon,
|
||||
});
|
||||
if (!isMobile) onFlyTo(result.lat, result.lon, flyZoom);
|
||||
search.saveRecentSearch(result);
|
||||
search.clear();
|
||||
if (isMobile) setExpanded(false);
|
||||
|
|
@ -189,6 +194,10 @@ export default function LocationSearch({
|
|||
}
|
||||
|
||||
if (result.type === 'address') {
|
||||
// Fly from the result's own coordinates immediately; the postcode fetch
|
||||
// below only resolves the geometry for the side panel. See the note in
|
||||
// the place branch above.
|
||||
if (!isMobile) onFlyTo(result.lat, result.lon, 17);
|
||||
try {
|
||||
const res = await fetch(
|
||||
`/api/postcode/${encodeURIComponent(result.postcode)}`,
|
||||
|
|
@ -201,7 +210,6 @@ export default function LocationSearch({
|
|||
}
|
||||
const json: PostcodeLookupResponse = await res.json();
|
||||
if (!isCurrentLookup(requestId, controller)) return;
|
||||
if (!isMobile) onFlyTo(result.lat, result.lon, 17);
|
||||
onLocationSearched?.({
|
||||
postcode: json.postcode,
|
||||
geometry: json.geometry,
|
||||
|
|
@ -228,7 +236,9 @@ export default function LocationSearch({
|
|||
return;
|
||||
}
|
||||
|
||||
// Postcode — fetch geometry
|
||||
// Postcode — fetch geometry. Unlike place/address results, a postcode
|
||||
// result carries no coordinates, so the camera move genuinely depends on
|
||||
// this response and stays gated by isCurrentLookup.
|
||||
try {
|
||||
const res = await fetch(
|
||||
`/api/postcode/${encodeURIComponent(result.label)}`,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue