aboutsummaryrefslogtreecommitdiff
path: root/src/types
diff options
context:
space:
mode:
authorJoris2022-07-05 21:55:41 +0200
committerJoris2023-01-28 09:35:55 +0100
commit063d8ef9eaf874a941f4459e831057dd0a1b7ddd (patch)
treec4a8b27cb8fdb5d1dc26c560c7483c9593f40dac /src/types
parent2936f06576997bffe7903ea840df563a408efc21 (diff)
Rewrite in TSmain
Diffstat (limited to 'src/types')
-rw-r--r--src/types/leaflet.d.ts95
1 files changed, 95 insertions, 0 deletions
diff --git a/src/types/leaflet.d.ts b/src/types/leaflet.d.ts
new file mode 100644
index 0000000..c1eef16
--- /dev/null
+++ b/src/types/leaflet.d.ts
@@ -0,0 +1,95 @@
+export as namespace L
+
+// Map
+
+export function map(element: string, options?: MapOptions): Map
+
+export interface MapOptions {
+ center: number[],
+ zoom: number,
+ attributionControl: boolean,
+}
+
+export interface Map {
+ addLayer: (layer: Layer | FeatureGroup) => void,
+ removeLayer: (layer: Layer | FeatureGroup) => void,
+ addEventListener: (name: string, fn: (e: MapEvent) => void) => void,
+ getBounds: () => LatLngBounds,
+ fitBounds: (bounds: LatLngBounds, options: { padding: [number, number] } | undefined) => void,
+}
+
+// LatLngBounds
+
+export interface LatLngBounds {
+ contains: (otherBounds: LatLngBounds) => boolean,
+}
+
+// Feature group
+
+export interface FeatureGroup {
+ clearLayers: () => void,
+ addLayer: (layer: Layer | FeatureGroup) => void,
+ removeLayer: (layer: Layer | FeatureGroup) => void,
+ getBounds: () => LatLngBounds,
+}
+
+export function featureGroup(xs?: Layer[]): L.FeatureGroup
+
+// Layer
+
+export interface Layer {
+ addEventListener: (name: string, fn: (e: MapEvent) => void) => void,
+ getLatLng: () => Pos,
+ setLatLng: (pos: Pos) => void,
+}
+
+export function tileLayer(url: string): Layer
+
+// Marker
+
+export function marker(
+ pos: Pos,
+ options: {
+ draggable: boolean,
+ autoPan: boolean,
+ icon: Icon,
+ }
+): Layer
+
+// Circle
+
+export function circle(
+ pos: Pos,
+ options: {
+ radius: number,
+ color: string,
+ fillColor: string,
+ },
+): Layer
+
+// Icon
+
+export interface Icon {}
+
+export function divIcon(
+ params: {
+ className: string,
+ popupAnchor: number[],
+ html: Element,
+ }
+): Icon
+
+// Pos
+
+export interface Pos {
+ lat: number,
+ lng: number,
+}
+
+// MapEvent
+
+interface MapEvent {
+ originalEvent: MouseEvent,
+ latlng: {lat: number, lng: number},
+}
+