Skip to content

Commit

Permalink
fix: add proxmity to geocoder
Browse files Browse the repository at this point in the history
  • Loading branch information
majkshkurti committed Jul 4, 2024
1 parent e2cce49 commit cdcee04
Showing 1 changed file with 10 additions and 14 deletions.
24 changes: 10 additions & 14 deletions apps/web/components/map/controls/Geocoder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ export default function Geocoder({
const [focused, setFocused] = useState(false);
const [collapsed, setCollapsed] = useState(true);
const { map } = useMap();

const theme = useTheme();

const fetch = useMemo(
Expand All @@ -88,13 +87,21 @@ export default function Geocoder({
request: { value: string },
onresult: (_error: Error, fc: FeatureCollection) => void,
) => {
const mapCenter = map?.getCenter();
let _proximity;
if (mapCenter) {
_proximity = {
longitude: mapCenter.lng,
latitude: mapCenter.lat,
};
}
search(
endpoint,
source,
accessToken,
request.value,
onresult,
proximity,
_proximity,
country,
bbox,
types,
Expand All @@ -105,18 +112,7 @@ export default function Geocoder({
},
400,
),
[
accessToken,
autocomplete,
bbox,
country,
endpoint,
language,
limit,
proximity,
source,
types,
],
[accessToken, autocomplete, bbox, country, endpoint, language, limit, map, source, types],
);

useEffect(() => {
Expand Down

0 comments on commit cdcee04

Please sign in to comment.