From beb6d9d0662f83d177a9f83803b349e37b75595c Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Fri, 3 Apr 2026 23:11:39 +0000 Subject: [PATCH] Better zoom to location on address selection --- ts/components/MapLocator.vue | 25 ++++++++++++------------- ts/rmo/content/Nuisance.vue | 3 +++ 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/ts/components/MapLocator.vue b/ts/components/MapLocator.vue index cf883963..5c8dbf2b 100644 --- a/ts/components/MapLocator.vue +++ b/ts/components/MapLocator.vue @@ -77,34 +77,33 @@ const initializeMap = () => { }); _map.on("load", () => { - console.log("map loaded"); emit("load"); + updateModel(_map); }); _map.on("zoomend", (evt: MoveEndEventInternal) => { console.log("zoomend", evt); if (_map && !evt.isInternalUpdate) { - const center = _map.getCenter(); - const newCamera: Camera = { - location: center, - zoom: _map.getZoom(), - }; - emit("update:modelValue", newCamera); + updateModel(_map); } }); _map.on("moveend", (evt: MoveEndEventInternal) => { console.log("moveend", evt); if (_map && !evt.isInternalUpdate) { - const center = _map.getCenter(); - emit("update:modelValue", { - location: center, - zoom: _map.getZoom(), - }); + updateModel(_map); } }); }; +function updateModel(_map: maplibregl.Map) { + const center = _map.getCenter(); + const newCamera: Camera = { + location: center, + zoom: _map.getZoom(), + }; + emit("update:modelValue", newCamera); +} // Update markers on the map const updateMarkers = () => { if (!map.value) return; @@ -149,7 +148,7 @@ const frameMarkers = () => { // Single marker: pan to it map.value.panTo( props.markers[0].location, - { duration: 1000 }, + { duration: 1000, zoom: props.modelValue?.zoom }, { isInternalUpdate: true }, ); } else { diff --git a/ts/rmo/content/Nuisance.vue b/ts/rmo/content/Nuisance.vue index b648a907..7bc4ba9a 100644 --- a/ts/rmo/content/Nuisance.vue +++ b/ts/rmo/content/Nuisance.vue @@ -530,6 +530,9 @@ function doAddressSelected(address: Address) { console.error("No geometry on address", address); return; } + if (currentCamera.value) { + currentCamera.value.zoom = 15; + } marker.value = { color: "#FF0000", draggable: true,