feat(search): add viewport bias for location-aware geocoding

- Add mapCenter state to store (lat/lon/zoom)
- Track map center on moveend in MapView
- Pass mapCenter to searchGeocode from SearchBar
- Update searchGeocode API call to include viewport params

Search results now prioritize locations near the current map view.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Matt 2026-04-26 04:03:52 +00:00
commit b12ebe672e
4 changed files with 158 additions and 3 deletions

View file

@ -52,6 +52,7 @@ const SearchBar = forwardRef(function SearchBar(_, ref) {
const setSelectedPlace = useStore((s) => s.setSelectedPlace)
const setEditingContact = useStore((s) => s.setEditingContact)
const clearPendingDestination = useStore((s) => s.clearPendingDestination)
const mapCenter = useStore((s) => s.mapCenter)
useEffect(() => {
inputRef.current?.focus()
@ -98,7 +99,7 @@ const SearchBar = forwardRef(function SearchBar(_, ref) {
setSearchLoading(true)
try {
const data = await searchGeocode(q.trim(), 6, ctrl.signal)
const data = await searchGeocode(q.trim(), 6, ctrl.signal, mapCenter)
const combined = [...contactResults, ...(data.results || [])]
setResults(combined)
setAutocompleteOpen(combined.length > 0)