diff --git a/web-frontend/src/lib/Map.svelte b/web-frontend/src/lib/Map.svelte index f49382c..5f3e00b 100644 --- a/web-frontend/src/lib/Map.svelte +++ b/web-frontend/src/lib/Map.svelte @@ -48,7 +48,12 @@ // If they click the map at all, they are not interested in their location anymore locationCheckedChanged(false); }); - map.on('click', onMapClick); + map.on('click', (e) => { + onMapClick({ + latlng: e.latlng, + event: 'click' + }); + }); map.on('locationfound', (e) => { dispatch('locationfound', e.detail); }); @@ -68,17 +73,23 @@ let geocoder = new leafletControlGeocoder.Geocoder({ defaultMarkGeocode: false }) .on('markgeocode', function (e) { console.log('Marked geocode:', e); + + // They found a location. Disable location polling + locationCheckedChanged(false); + onMapClick({ latlng: { lat: e.geocode.center.lat, lng: e.geocode.center.lng - } + }, + event: 'markgeocode' }); }) .addTo(map); leaflet .tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { + maxZoom: 19, attribution: '© OpenStreetMap contributors' }) diff --git a/web-frontend/src/routes/app/+page.svelte b/web-frontend/src/routes/app/+page.svelte index 48a2e95..05a9ebe 100644 --- a/web-frontend/src/routes/app/+page.svelte +++ b/web-frontend/src/routes/app/+page.svelte @@ -32,7 +32,13 @@ }; const onMapClick = (e) => { - updateAddr(wasm.call.EncodedAddress.from_coordinate(`${e.latlng.lat}, ${e.latlng.lng}`), false); + // If they found this from a search, we should zoom there + let fromTextInput = e.event == 'markgeocode'; + + updateAddr( + wasm.call.EncodedAddress.from_coordinate(`${e.latlng.lat}, ${e.latlng.lng}`), + fromTextInput + ); }; let init = async () => {