From c48aebcb0b0f911738e9b4b7cdc22f94b9dab7ac Mon Sep 17 00:00:00 2001 From: Eli Ribble Date: Fri, 10 Apr 2026 14:20:04 +0000 Subject: [PATCH] Set initial camera based on location in compliance --- ts/components/MapLocator.vue | 32 ++++++++++++++++++---- ts/rmo/components/AddressAndMapLocator.vue | 8 ++++-- ts/rmo/content/compliance/Address.vue | 18 ++++++++++-- ts/rmo/view/Compliance.vue | 9 +++++- ts/type/api.ts | 29 ++++++++++++-------- ts/type/map.ts | 16 +++++++---- 6 files changed, 83 insertions(+), 29 deletions(-) diff --git a/ts/components/MapLocator.vue b/ts/components/MapLocator.vue index 070c1fe2..aa414e6f 100644 --- a/ts/components/MapLocator.vue +++ b/ts/components/MapLocator.vue @@ -177,7 +177,8 @@ interface Emits { // Props interface Props { - modelValue: Camera | null; + initialCamera?: Camera; + modelValue: Camera; markers?: Marker[]; } @@ -225,12 +226,7 @@ function deactivateMap() { function initializeMap() { if (!mapContainer.value) return; - let bounds = boundsDefault(); - if (props.markers.length > 0) { - bounds = boundsMarkers(props.markers); - } const _map = new maplibregl.Map({ - bounds: bounds, container: mapContainer.value, style: "https://tiles.stadiamaps.com/styles/alidade_smooth.json", // Disable interactions by default @@ -239,6 +235,30 @@ function initializeMap() { scrollZoom: false, touchZoomRotate: false, }); + if (props.markers.length > 0) { + _map.fitBounds(boundsMarkers(props.markers)); + } else if (props.initialCamera) { + _map.jumpTo({ + center: [ + props.initialCamera.location.longitude, + props.initialCamera.location.latitude, + ], + zoom: props.initialCamera.zoom, + }); + } else if ( + props.modelValue.location.latitude != 0 || + props.modelValue.location.longitude != 0 + ) { + _map.jumpTo({ + center: [ + props.modelValue.location.longitude, + props.modelValue.location.latitude, + ], + zoom: props.modelValue.zoom, + }); + } else { + _map.fitBounds(boundsDefault()); + } _map.addControl(new maplibregl.NavigationControl(), "top-left"); map.value = _map; _map.on("click", (e: maplibregl.MapLayerMouseEvent) => { diff --git a/ts/rmo/components/AddressAndMapLocator.vue b/ts/rmo/components/AddressAndMapLocator.vue index 4ea7d545..a0309ecd 100644 --- a/ts/rmo/components/AddressAndMapLocator.vue +++ b/ts/rmo/components/AddressAndMapLocator.vue @@ -50,10 +50,11 @@
@@ -64,17 +65,18 @@ import AddressSuggestion from "@/components/AddressSuggestion.vue"; import MapLocator from "@/components/MapLocator.vue"; import type { Address, Geocode, GeocodeSuggestion, Location } from "@/type/api"; import { useGeocodeStore } from "@/store/geocode"; -import type { Camera, Locator } from "@/type/map"; +import { Camera, Locator } from "@/type/map"; import type { Marker } from "@/types"; interface Emits { (e: "update:modelValue", value: Locator): void; } interface Props { + initialCamera?: Camera; modelValue: Locator; } const address = ref(""); -const currentCamera = ref(null); +const currentCamera = ref(new Camera()); const emit = defineEmits(); const geocode = useGeocodeStore(); const markers = computed((): Marker[] => { diff --git a/ts/rmo/content/compliance/Address.vue b/ts/rmo/content/compliance/Address.vue index d39e7107..a39f41d2 100644 --- a/ts/rmo/content/compliance/Address.vue +++ b/ts/rmo/content/compliance/Address.vue @@ -10,7 +10,10 @@ Please enter the address so we can match your response with our records.

- +
@@ -24,7 +27,7 @@