diff options
Diffstat (limited to 'src/types')
-rw-r--r-- | src/types/leaflet.d.ts | 95 |
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}, +} + |