UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

106 lines • 4.92 kB
import 'maplibre-gl/dist/maplibre-gl.css'; import { type PointerMissedEventData, type SceneDef } from '@expofp/renderer'; import { type LngLatBoundsLike, Map as MaplibreMap, type StyleSpecification } from 'maplibre-gl'; import { type ReactNode } from 'react'; export declare const MAP_DIM_LAYER_ID = "expofp-map-dim"; /** * Configuration for the map tile source. * Abstracted so we can swap between online and offline (PMTiles) later * without touching MaplibreWrapper. */ export interface TileSourceConfig { /** Maplibre style URL or inline style JSON object */ style: string | StyleSpecification; /** * The style and everything it references ship inside the plan archive. Local * hosts serve those files themselves, so PMTiles archives get a source that * tolerates a host without Range support. */ offline?: boolean; } export interface CameraPaddingOptions { top: number; bottom: number; left: number; right: number; } /** Geographic configuration derived from fpGeo.properties */ export interface GeoConfig { /** Center of the venue in [lng, lat] */ center: [number, number]; /** Map bearing in degrees */ bearing: number; /** Initial zoom level */ zoom: number; /** Optional initial bounds. When present, MapLibre computes the initial zoom. */ bounds?: LngLatBoundsLike; /** Padding used with initial bounds. */ fitPadding?: CameraPaddingOptions; /** Small correction after bounds-based initial fit. */ zoomAdjustment?: number; } /** * The camera policy for a map: every field a caller decides. * * The props take a `Partial` of this, so a caller names only the fields it has decided. What it * leaves out is left off the map's own options and MapLibre's default applies (`maxPitch` 60, * `minZoom` 0, `maxZoom` 22, no bounds). This component defaults nothing itself. */ export interface MapOptions { /** Where the camera settles once the map is up, in degrees back from top down. */ pitch: number; /** How far it may tilt back from top down, in degrees. */ maxPitch: number; minZoom: number; maxZoom: number; /** Where the camera may pan. */ maxBounds: LngLatBoundsLike; } export interface MaplibreWrapperProps { /** * The scene to render inside the map, already prepared for external mode by the caller: * MapLibre is the only basemap (no areamap layer), the map paints the background, and the * scene's `staticTransform` places the plan in Mercator. */ sceneDef: SceneDef; /** Geographic configuration for map positioning and floorplan locking */ geoConfig: GeoConfig; /** Tile source configuration (online style URL for now) */ tileSource: TileSourceConfig; /** Map camera constraints and defaults; what is left out takes MapLibre's own default. */ mapOptions?: Partial<MapOptions>; /** * Mounts the renderer's debug overlay. Fixed for the wrapper's lifetime: when set, map creation * waits for `prepareDebug()`, so the map's context is created already instrumented and the * GPU-memory panel has figures to show. */ debug?: boolean; /** * Called once the map exists and its custom layer received the shared WebGL context — the * moment the caller can wire map-level state: camera port, options, store flags. */ onMapReady?: (map: MaplibreMap, requestRepaint: () => void) => void; /** Called when the dim overlay layer is available for paint updates. */ onMapDimLayerReady?: (map: MaplibreMap) => void; /** Called when the map style cannot be loaded. */ onMapLoadError?: (error: unknown) => void; /** Forwarded to the renderer: a click that reached no layer handler. */ onPointerMissed?: (event: PointerMissedEventData) => void; /** Components rendered inside the renderer's tree, under the scene's space. */ children?: ReactNode; } /** * A pure, state-agnostic React component that renders a Maplibre map * with the ExpoFP floorplan embedded via CustomLayerInterface. * * The floorplan draws through the ordinary `<Renderer>` in external mode: the custom layer hands * over the map's WebGL context when MapLibre creates it, repaint demand becomes * `map.triggerRepaint()`, and every frame the map draws forwards its projection matrix to the * renderer's subscribed draw. There is no update pump: the renderer asks the host for frames * itself, through the same demand channel its own canvas would use. * * This component does NOT import MobX or any application state. * All state synchronization is done externally via the onMapReady callback. */ export default function MaplibreWrapper({ sceneDef, geoConfig, tileSource, mapOptions, debug, onMapReady, onMapDimLayerReady, onMapLoadError, onPointerMissed, children, }: MaplibreWrapperProps): import("react").JSX.Element; //# sourceMappingURL=MaplibreWrapper.d.ts.map