map-gl-indoor
Version:
A MapGL plugin to visualize multi-level buildings
144 lines (138 loc) • 4.56 kB
TypeScript
// Generated by dts-bundle-generator v6.5.0
import { BBox, FeatureCollection, Geometry } from 'geojson';
import { Map as MapboxMap } from 'mapbox-gl';
import { Listener as MaplibreListener, Map as MaplibreMap } from 'maplibre-gl';
export declare type Level = number;
export declare type LevelsRange = {
min: Level;
max: Level;
};
export declare type IndoorMapOptions = {
beforeLayerId?: string;
defaultLevel?: number;
layers?: Array<LayerSpecification>;
layersToHide?: Array<string>;
showFeaturesWithEmptyLevel?: boolean;
};
export declare type IndoorMapGeoJSON = FeatureCollection<Geometry>;
export declare type LayerSpecification = any;
export declare type FilterSpecification = any[] | null;
export declare type MapGL = MapboxMap | MaplibreMap;
export declare type MapboxMapWithIndoor = MapboxMap & {
indoor: IndoorLayer;
};
export declare type IndoorMapEvent = "indoor.map.loaded" | "indoor.map.unloaded" | "indoor.level.changed";
export declare type MaplibreMapWithIndoor = MaplibreMap & {
indoor: IndoorLayer;
on(type: IndoorMapEvent, listener: MaplibreListener): MaplibreMap;
off(type: IndoorMapEvent, listener: MaplibreListener): MaplibreMap;
};
export declare type MapGLWithIndoor = MapboxMapWithIndoor | MaplibreMapWithIndoor;
export declare class IndoorMap {
bounds: BBox;
geojson: IndoorMapGeoJSON;
layers: Array<LayerSpecification>;
levelsRange: LevelsRange;
beforeLayerId?: string;
layersToHide: Array<string>;
defaultLevel: number;
showFeaturesWithEmptyLevel: boolean;
constructor(bounds: BBox, geojson: IndoorMapGeoJSON, layers: Array<LayerSpecification>, levelsRange: LevelsRange, layersToHide: Array<string>, defaultLevel: number, showFeaturesWithEmptyLevel: boolean, beforeLayerId?: string);
static fromGeojson(geojson: IndoorMapGeoJSON, options?: IndoorMapOptions): IndoorMap;
}
export declare type SavedFilter = {
layerId: string;
filter: FilterSpecification;
};
/**
* Manage indoor levels
* @param {Map} map the Mapbox map
*/
export declare class IndoorLayer {
_map: MapGL;
_level: Level | null;
_indoorMaps: Array<IndoorMap>;
_selectedMap: IndoorMap | null;
_previousSelectedMap: IndoorMap | null;
_previousSelectedLevel: Level | null;
_savedFilters: Array<SavedFilter>;
_mapLoadedPromise: Promise<void>;
_updateMapPromise: Promise<void>;
constructor(map: MapGL);
getSelectedMap(): IndoorMap | null;
getLevel(): Level | null;
setLevel(level: Level | null, fireEvent?: Boolean): void;
/**
* ***********************
* Handle level change
* ***********************
*/
_addLayerForFiltering(layer: LayerSpecification, beforeLayerId?: string): void;
addLayerForFiltering(layer: LayerSpecification, beforeLayerId?: string): void;
_removeLayerForFiltering(layerId: string): void;
removeLayerForFiltering(layerId: string): void;
_updateFiltering(): void;
/**
* **************
* Handle maps
* **************
*/
addMap(map: IndoorMap): Promise<void>;
removeMap(map: IndoorMap): Promise<void>;
_updateSelectedMapIfNeeded(): Promise<void>;
_updateSelectedMap(indoorMap: IndoorMap | null): void;
_closestMap(): IndoorMap | null;
}
/**
* Creates a indoor control with floors buttons
* @implements {IControl}
*/
export declare class IndoorControl {
_map?: MapGLWithIndoor;
_indoor?: IndoorLayer;
_indoorMap: IndoorMap | null;
_container?: HTMLElement;
_levelsButtons: Array<HTMLElement>;
_selectedButton: HTMLElement | null;
constructor();
onAdd(map: MapGL | MapGLWithIndoor): HTMLDivElement;
onRemove(): void;
_onMapLoaded: ({ indoorMap }: {
indoorMap: IndoorMap;
}) => void;
_onMapUnLoaded: () => void;
_onLevelChanged: ({ level }: {
level: Level | null;
}) => void;
_updateNavigationBar(): void;
_setSelected(level: Level | null): void;
_createLevelButton(container: HTMLElement, level: Level): HTMLButtonElement;
_onContextMenu(e: Event): void;
}
export declare type RemoteMap = {
name: string;
path: string;
indoorMap?: IndoorMap;
};
export declare class MapServerHandler {
serverUrl: string;
map: MapGLWithIndoor;
remoteMapsDownloaded: RemoteMap[];
downloadedBounds: BBox | null;
loadMapsPromise: Promise<void>;
indoorMapOptions?: IndoorMapOptions;
private constructor();
private loadMapsIfNecessary;
private loadMapsInBounds;
private addCustomMap;
private removeCustomMap;
static manage(server: string, map: MapGL, indoorMapOptions?: IndoorMapOptions): MapServerHandler;
}
declare const _default: {
DefaultLayers: any[];
};
export function addIndoorTo(map: MapGL): MapGLWithIndoor;
export {
_default as DefaultStyle,
};
export {};