This commit is contained in:
Andras Schmelczer 2026-06-02 13:46:18 +01:00
parent a04ac2d857
commit d43da9708c
47 changed files with 4120 additions and 573 deletions

View file

@ -4,7 +4,11 @@ import type { MapFlyToOptions, PostcodeGeometry } from '../../types';
import { authHeaders, isAbortError } from '../../lib/api';
import { POSTCODE_SEARCH_ZOOM } from '../../lib/consts';
import { useIsMobile } from '../../hooks/useIsMobile';
import { useLocationSearch, type SearchResult } from '../../hooks/useLocationSearch';
import {
useLocationSearch,
type SearchResult,
type ViewportCenter,
} from '../../hooks/useLocationSearch';
import { PlaceSearchInput } from '../ui/PlaceSearchInput';
import { LocateIcon } from '../ui/icons/LocateIcon';
import { SearchIcon } from '../ui/icons/SearchIcon';
@ -44,6 +48,12 @@ const ZOOM_FOR_TYPE: Record<string, number> = {
locality: 14,
hamlet: 15,
isolated_dwelling: 16,
street: 16,
university: 15,
park: 15,
attraction: 16,
hospital: 16,
retail: 15,
};
const DEV_CURRENT_LOCATION = {
@ -56,6 +66,7 @@ export default function LocationSearch({
onLocationSearched,
onCurrentLocationFound,
onMouseEnter,
getViewportCenter,
className = '',
inputClassName,
}: {
@ -63,11 +74,13 @@ export default function LocationSearch({
onLocationSearched?: (postcode: SearchedLocation | null) => void;
onCurrentLocationFound?: (lat: number, lng: number) => void;
onMouseEnter?: () => void;
/** Returns the current map centre so search ranking can bias toward the visible area. */
getViewportCenter?: () => ViewportCenter | null;
className?: string;
inputClassName?: string;
}) {
const { t } = useTranslation();
const search = useLocationSearch();
const search = useLocationSearch(undefined, getViewportCenter);
const [error, setError] = useState<string | null>(null);
const [loading, setLoading] = useState(false);
const [expanded, setExpanded] = useState(false);