diff --git a/ts/components/MapAggregate.vue b/ts/components/MapAggregate.vue index d6597891..07ab6f05 100644 --- a/ts/components/MapAggregate.vue +++ b/ts/components/MapAggregate.vue @@ -27,8 +27,8 @@ diff --git a/ts/map-utils.ts b/ts/map-utils.ts new file mode 100644 index 00000000..4a4a1809 --- /dev/null +++ b/ts/map-utils.ts @@ -0,0 +1,22 @@ +import type { Marker } from "@/types"; +import { LngLat, LngLatBounds } from "maplibre-gl"; + +export function boundsMarkers(markers: Marker[]): LngLatBounds { + let min_lat = 90; + let min_lng = 180; + let max_lat = -90; + let max_lng = -180; + markers.forEach((marker: Marker) => { + min_lat = Math.min(marker.location.lat, min_lat); + min_lng = Math.min(marker.location.lng, min_lng); + max_lat = Math.min(marker.location.lat, max_lat); + max_lng = Math.min(marker.location.lng, max_lng); + }); + return new LngLatBounds( + new LngLat(min_lng, min_lat), + new LngLat(max_lng, max_lat), + ); +} +export function boundsDefault(): LngLatBounds { + return new LngLatBounds(new LngLat(-70, 50), new LngLat(-125, 25)); +} diff --git a/ts/rmo/content/Nuisance.vue b/ts/rmo/content/Nuisance.vue index dd7961a2..8433350a 100644 --- a/ts/rmo/content/Nuisance.vue +++ b/ts/rmo/content/Nuisance.vue @@ -156,7 +156,14 @@ select.tall { You can also click on the map to mark the location precisely