From cedfa8b29df2f8201d92b2f9dc7cb35baffe7c7e Mon Sep 17 00:00:00 2001 From: Abbey Campbell Date: Fri, 29 May 2026 16:50:44 -0700 Subject: [PATCH 1/3] use bbox for location picker place search --- .../LocationPicker/LocationPickerContainer.js | 35 +++++++++++++------ .../LocationPicker/LocationSearch.tsx | 2 +- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/components/LocationPicker/LocationPickerContainer.js b/src/components/LocationPicker/LocationPickerContainer.js index c1cb26d99..fa700f22a 100644 --- a/src/components/LocationPicker/LocationPickerContainer.js +++ b/src/components/LocationPicker/LocationPickerContainer.js @@ -2,6 +2,7 @@ import { useNavigation } from "@react-navigation/native"; import { + getMapRegion, latitudeDeltaToMeters, metersToLatitudeDelta, } from "components/SharedComponents/Map/helpers/mapHelpers"; @@ -201,19 +202,33 @@ const LocationPickerContainer = ( ): Node => { const selectPlaceResult = place => { const { coordinates } = place.point_geojson; + let newRegion = { + ...region, + latitude: coordinates[1], + longitude: coordinates[0], + }; + + if ( place.bounding_box_geojson?.coordinates?.[0] ) { + // bbox is a 5-point clockwise rectangle starting from SW (5th === 1st), + // so the 1st and 3rd points give us the SW and NE corners. + const [ + [swlng, swlat], + _nwPoint, + [nelng, nelat], + ] = place.bounding_box_geojson.coordinates[0]; + newRegion = { + ...newRegion, + ...getMapRegion( { + swlng, swlat, nelng, nelat, + } ), + }; + } + dispatch( { type: "SELECT_PLACE_RESULT", locationName: place.display_name, - region: { - ...region, - latitude: coordinates[1], - longitude: coordinates[0], - }, - regionToAnimate: { - ...region, - latitude: coordinates[1], - longitude: coordinates[0], - }, + region: newRegion, + regionToAnimate: newRegion, } ); }; diff --git a/src/components/LocationPicker/LocationSearch.tsx b/src/components/LocationPicker/LocationSearch.tsx index de3f2feef..c3f058f3e 100644 --- a/src/components/LocationPicker/LocationSearch.tsx +++ b/src/components/LocationPicker/LocationSearch.tsx @@ -44,7 +44,7 @@ const LocationSearch = ( { ( optsWithAuth: ApiOpts ) => fetchSearchResults( { q: locationName, sources: "places", - fields: "place,place.display_name,place.point_geojson", + fields: "place,place.display_name,place.point_geojson,place.bounding_box_geojson", }, optsWithAuth ), ); From 40db1156fa755039005023149abc98fdc722dbf9 Mon Sep 17 00:00:00 2001 From: Abbey Campbell Date: Wed, 3 Jun 2026 15:25:47 -0700 Subject: [PATCH 2/3] use only deltas from getMapRegion --- .../LocationPicker/LocationPickerContainer.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/components/LocationPicker/LocationPickerContainer.js b/src/components/LocationPicker/LocationPickerContainer.js index fa700f22a..8b3455620 100644 --- a/src/components/LocationPicker/LocationPickerContainer.js +++ b/src/components/LocationPicker/LocationPickerContainer.js @@ -216,12 +216,12 @@ const LocationPickerContainer = ( ): Node => { _nwPoint, [nelng, nelat], ] = place.bounding_box_geojson.coordinates[0]; - newRegion = { - ...newRegion, - ...getMapRegion( { - swlng, swlat, nelng, nelat, - } ), - }; + // Take only the deltas from getMapRegion and keep the place's point_geojson as the center + // this gives us a more helpfully placed crosshair + const { latitudeDelta, longitudeDelta } = getMapRegion( { + swlng, swlat, nelng, nelat, + } ); + newRegion = { ...newRegion, latitudeDelta, longitudeDelta }; } dispatch( { From a6071f3395910475710ceec400d00832eb3566b0 Mon Sep 17 00:00:00 2001 From: Abbey Campbell Date: Tue, 9 Jun 2026 10:41:05 -0700 Subject: [PATCH 3/3] add bbox_geojson to place interface --- src/components/LocationPicker/LocationSearch.tsx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/components/LocationPicker/LocationSearch.tsx b/src/components/LocationPicker/LocationSearch.tsx index c3f058f3e..3325b257c 100644 --- a/src/components/LocationPicker/LocationSearch.tsx +++ b/src/components/LocationPicker/LocationSearch.tsx @@ -20,6 +20,9 @@ interface Place { point_geojson: { coordinates: [number, number]; }; + bounding_box_geojson?: { + coordinates: [number, number][][]; + }; } interface Props { locationName: string;