From 1e4025852e740ca508a62775c57039442f2b546a Mon Sep 17 00:00:00 2001 From: Dustin Carlino Date: Tue, 10 Dec 2024 13:24:27 +0000 Subject: [PATCH] Improve geocoder: - speed up the animation - prefer results close to the current map center --- src/lib/common/Geocoder.svelte | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/lib/common/Geocoder.svelte b/src/lib/common/Geocoder.svelte index d35d128ed..f92a6b6f4 100644 --- a/src/lib/common/Geocoder.svelte +++ b/src/lib/common/Geocoder.svelte @@ -12,13 +12,24 @@ let mapController: MapController; - // TODO HMR is broken onMount(() => { - mapController = createMapLibreGlMapController($map, maplibregl); + let marker = true; + let showResultMarkers = true; + let flyToOptions = { + duration: 1000, + }; + let fitBoundsOptions = { + duration: 1000, + }; + mapController = createMapLibreGlMapController( + $map, + maplibregl, + marker, + showResultMarkers, + flyToOptions, + fitBoundsOptions, + ); }); - - // TODO Show markers - // TODO Set the flyTo duration {#if mapController} @@ -27,6 +38,11 @@ {mapController} apiKey={import.meta.env.VITE_MAPTILER_API_KEY} country="gb" + proximity={[ + { + type: "map-center", + }, + ]} /> {/if}