import type { BboxHandler, HashHandler, HashQuery, LinesLayer, MarkersLayer, OverpassLayer, OverpassPreset, SearchResultsLayer, VisibleLayers } from "facilmap-leaflet"; import type { LatLng, LatLngBounds, Map } from "leaflet"; import type { FilterFunc } from "facilmap-utils"; import type { Emitter } from "mitt"; import type { DeepReadonly } from "vue"; import type { SelectedItem } from "../../utils/selection"; import type SelectionHandler from "../../utils/selection"; import type { AttributionControl } from "../leaflet-map/attribution"; import type { Point } from "facilmap-types"; export type MapContextEvents = { "open-selection": { selection: DeepReadonly }; }; export interface MapComponents { attribution: AttributionControl; bboxHandler: BboxHandler; container: HTMLElement; graphicScale: any; hashHandler: HashHandler & { _fmActivate: () => Promise }; linesLayer: LinesLayer; locateControl?: L.Control.Locate; map: Map; markersLayer: MarkersLayer; mousePosition: L.Control.MousePosition; overpassLayer: OverpassLayer; searchResultsLayer: SearchResultsLayer; selectionHandler: SelectionHandler; } export type MapContextData = { center: LatLng; zoom: number; bounds: LatLngBounds; layers: VisibleLayers; filter: string | undefined; filterFunc: FilterFunc; hash: string; showToolbox: boolean; selection: DeepReadonly[]; activeQuery: HashQuery | undefined; fallbackQuery: HashQuery | undefined; setFallbackQuery: (query: HashQuery | undefined) => void; interaction: boolean; loading: number; overpassIsCustom: boolean; overpassPresets: OverpassPreset[]; overpassCustom: string; overpassMessage: string | undefined; location: Point | undefined; components: MapComponents; loaded: boolean; fatalError: string | undefined; /** Increase mapContext.loading while the given async function is running. */ runOperation: (operation: () => Promise) => Promise; }; export type WritableMapContext = MapContextData & Emitter; export type MapContext = DeepReadonly> & { readonly components: Readonly; };