Continue messing with stores

This commit is contained in:
ThePetrovich 2025-06-27 19:27:19 +08:00
parent c7df38e6ce
commit 52558ed3b2
7 changed files with 148 additions and 83 deletions

View file

@ -2,37 +2,12 @@
import { onMount, createEventDispatcher } from "svelte";
import * as L from "leaflet";
import type { Map as LeafletMap, LayerGroup } from "leaflet";
type LatLngExpression = [number, number] | { lat: number; lng: number };
type LatLngLiteral = { lat: number; lng: number };
import "leaflet/dist/leaflet.css";
import VelocityLayer from "./velocity.svelte";
import { distHaversine } from "../lib/mathutil.ts";
import type { PredictionData, TelemetryData } from "../lib/types.ts";
interface Point {
latlng: LatLngLiteral & { alt: number };
datetime: Date;
}
interface PredictionData {
launch: Point;
landing: Point;
burst: Point;
flight_path: LatLngExpression[];
flight_time: number;
}
interface TelemetryPoint {
altitude: number;
datetime: string;
latitude: number;
longitude: number;
}
interface TelemetryData {
launch: Point;
datapoints: TelemetryPoint[];
flight_path: LatLngExpression[];
}
/**
* @type {'prediction' | 'telemetry'}
@ -151,6 +126,22 @@
map?.fitBounds(L.latLngBounds(telemetry.flight_path));
};
export const panTo = (lat: number, lng: number) => {
if (map) {
map.setView([lat, lng], map.getZoom());
}
};
export const zoomTo = (lat: number, lng: number, zoomLevel: number) => {
if (map) {
map.setView([lat, lng], zoomLevel);
}
};
export const getMap = () => {
return map;
};
</script>
<div class="map-container" bind:this={mapContainer}>