@expofp/floorplan
Version:
Interactive floor plan library for expos and events
390 lines • 11.5 kB
TypeScript
/**
* Represents a floor plan.
*/
export interface FloorPlan {
readonly ready: Promise<void>;
readonly element: HTMLDivElement;
readonly eventId: string;
readonly dataUrl: string;
readonly noOverlay: boolean;
readonly offHistory: boolean;
readonly allowConsent: boolean;
readonly onInit: (fp: FloorPlan) => void;
onBoothClick(e: FloorPlanBoothClickEvent): void;
onBookmarkClick(e: FloorPlanBookmarkClickEvent): void;
onVisitedClick(e: FloorPlanVisitedClickEvent): void;
onCategoryClick(e: FloorPlanCategoryClickEvent): void;
/**
* @deprecated
* The onFpConfigured method is deprecated. Use onInit instead.
*/
onFpConfigured(): void;
onDirection(e: FloorPlanDirectionEvent): void;
onDetails(e: FloorPlanDetailsEvent): void;
onExhibitorCustomButtonClick(e: FloorPlanCustomButtonEvent): void;
onGetCoordsClick(e: FloorPlanGetCoordsEvent): void;
onMarkerClick(e: FloorPlanMarkerEvent): void;
selectBooth(nameOrExternalId: string): void;
selectExhibitor(nameOrExternalId: string): void;
selectRoute(from: RouteWaypoint, to: RouteWaypoint): void;
selectRoute(waypoints: RouteWaypoint[]): void;
getOptimizedRoutes(waypoints: RouteWaypoint[]): RouteInfo[];
selectCurrentPosition(point: CurrentPosition, focus: boolean, icon?: number): void;
setBookmarks(bookmarks: {
name: string;
bookmarked: boolean;
}[]): void;
setEntitiesBookmarks(bookmarks: {
type: 'exhibitor' | 'event' | 'speaker' | 'booth';
name?: string;
externalId?: string;
bookmarked: boolean;
}[]): void;
setEntitiesVisited(entities: {
type: 'exhibitor' | 'event';
name?: string;
externalId?: string;
visited: boolean;
}[]): void;
setMarkers(markersData: MarkersData): void;
updateLayerVisibility(layer: string, visible: boolean): void;
getCenterCoordinates(): FloorPlanGetCoordsEvent;
applyParameters(queryRaw: string): void;
exhibitorsList(): FloorPlanExhibitor[];
boothsList(): FloorPlanBooth[];
categoriesList(): FloorPlanCategory[];
selectCategory(nameOrSlug?: string): void;
getVisibility(): Visibility;
setVisibility(visibility: Visibility): void;
findLocation(): void;
zoomIn(): void;
zoomOut(): void;
switchView(): void;
zoomTo(selectors: POISelectors, options?: {
padding?: number;
}): void;
fitBounds(): void;
fitBounds(bounds: Bounds, options?: {
padding?: number;
}): void;
getBounds(selectors: POISelectors): Bounds | undefined;
getBoothRect(name: string): Rect;
convertToGeo(x: number, y: number): [number, number] | never;
getGeoConfig(): GeoConfig | null;
unstable_destroy(): void;
highlightExhibitors(externalIds: string[]): void;
highlightBooths(externalIds: string[]): void;
onCurrentPositionChanged(point: CurrentPosition): void;
onLeaveEvent(): void;
search(term: string): Promise<{
item: unknown;
score: number;
}[]>;
getFloors(): Floor[];
onFloorActivated(floor: Floor): void;
activateFloor(floorId: {
name?: string;
index?: number;
}): void;
showPathway(pathwayId: string, externalIds: string[]): void;
showPathwayOnly(pathwayId: string, floorId: string): void;
hidePathways(): void;
showSearch(): void;
changeLanguage(langId: string): void;
isGpsTrackingEnabled(): boolean;
setGpsTrackingEnabled(value: boolean): void;
deselectCurrentPosition(): void;
deselectRoute(): void;
reset(): void;
/**
* Same as {@link selectRoute}, but restricts the path to accessible segments only.
* @param waypoints - Ordered route stops (booth name/ID or `CurrentPosition`).
*/
selectAccessibleRoute(waypoints: RouteWaypoint[]): void;
}
/**
* Options for configuring the FloorPlan instance.
*/
export interface FloorPlanOptions {
element?: HTMLDivElement;
expo?: string;
/**
* @deprecated
* Use 'expo' instead.
*/
event?: string;
/** @deprecated */
legacyDataVersion?: {
version: string;
};
/** @deprecated */
legacyDataUrlBase?: string;
previewMode?: boolean;
dataUrl?: string;
noOverlay?: boolean;
offHistory?: boolean;
ignoreQuery?: boolean;
allowConsent?: boolean;
onBoothClick?: (e: FloorPlanBoothClickEvent) => void;
onBookmarkClick?: (e: FloorPlanBookmarkClickEvent) => void;
onVisitedClick?: (e: FloorPlanVisitedClickEvent) => void;
onCategoryClick?: (e: FloorPlanCategoryClickEvent) => void;
/**
* @deprecated
* The onFpConfigured method is deprecated. Use onInit instead.
*/
onFpConfigured?: () => void;
onDirection?: (e: FloorPlanDirectionEvent) => void;
onDetails?: (e: FloorPlanDetailsEvent) => void;
onExhibitorCustomButtonClick?: (e: FloorPlanCustomButtonEvent) => void;
onMarkerClick?: (e: FloorPlanMarkerEvent | undefined) => void;
onGetCoordsClick?: (e: FloorPlanGetCoordsEvent) => void;
onInit?: (fp: FloorPlan) => void;
onCurrentPositionChanged?: (point: CurrentPosition) => void;
onFloorActivated?: (floor: Floor) => void;
onLeaveEvent?: () => void;
disableRuntimeAlerts?: boolean;
viewerMode?: boolean;
maplibre?: MaplibreOptions;
}
export interface MaplibreOptions {
/** MapLibre style URL. Offline packages point this to a local style JSON file. */
styleUrl?: string;
/** Inline MapLibre style object. */
style?: object;
/** Allows MapLibre to run without navigator.onLine when local map assets are bundled. */
offline?: boolean;
}
export interface Layer {
name: string;
description: string;
}
export interface FloorPlanBoothBase {
id: number;
externalId: string;
name: string;
layer: Layer;
}
export interface FloorPlanBooth extends FloorPlanBoothBase {
id: number;
name: string;
externalId: string;
isSpecial: boolean;
exhibitors: number[];
layer: Layer;
meta: Record<string, string>;
description: string;
entity: Entity;
}
export interface FloorPlanBoothClickEvent {
target: FloorPlanBoothBase;
}
export interface Point {
x: number;
y: number;
}
export interface FloorPlanBookmarkClickEvent {
name: string;
bookmarked: boolean;
externalId: string;
}
export interface FloorPlanVisitedClickEvent {
name: string;
visited: boolean;
externalId: string;
}
type FloorPlanCategoryClickEvent = FloorPlanCategory;
export interface FloorPlanDirectionEvent {
from: FloorPlanBoothBase;
to: FloorPlanBoothBase;
lines: {
p0: Point;
p1: Point;
}[];
distance: string;
units: string;
time: number;
}
export interface FloorPlanDetailsEvent {
type: 'booth' | 'exhibitor' | 'route' | 'category';
id: string;
name: string;
externalId: string;
boothsNames: string[];
routeInfo?: Record<string, unknown>;
}
export interface FloorPlanCustomButtonEvent {
externalId: string;
buttonNumber: number;
buttonUrl: string;
preventDefault: () => void;
}
export interface FloorPlanGetCoordsEvent extends Point {
z: string | null;
}
export interface FloorPlanMarkerEvent extends Point {
id: string;
z?: number | string;
}
export interface FloorPlanExhibitor {
id: number;
name: string;
externalId: string;
booths: number[];
entity: Entity;
slug: string;
}
export interface FloorPlanCategory {
id: number;
name: string;
exhibitors: number[];
entity: Entity;
slug: string;
}
export type RouteWaypoint = string | CurrentPosition;
export interface RouteInfo {
waypoints: RouteWaypoint[];
}
export interface ExpoData {
booths: FloorPlanBooth[];
exhibitors: FloorPlanExhibitor[];
categories: FloorPlanCategory[];
}
export type FloorPlanIcon = 'departure' | 'departure_inactive' | 'destination' | 'direction' | 'transition' | 'transition_up' | 'transition_down' | 'kiosk' | 'yah';
export interface LayerPoint extends Point {
layer: string;
}
export interface Entity {
type: 'booth' | 'category' | 'exhibitor' | 'schedule' | 'language' | 'heatmap-yah' | 'route-cut-in';
variant?: 'regular' | 'special';
}
export interface FloorPlanSchedule {
id: number;
externalId: string;
boothId: number;
exhibitorId: number;
name: string;
description: string;
startDate: string;
endDate: string;
link: string;
entity: Entity;
isEnded: boolean;
}
export interface FloorPlanLanguage {
id: number;
name: string;
entity: Entity;
selected: boolean;
}
export interface FloorPlanHeatmapYah {
id: string;
name: string;
viewCount: number;
x: number;
y: number;
z: number | string;
entity: Entity;
}
export type FloorPlanEntity = FloorPlanBooth | FloorPlanCategory | FloorPlanExhibitor | FloorPlanSchedule | FloorPlanLanguage | FloorPlanHeatmapYah;
export interface Floor {
name: string;
shortName: string;
description: string;
active: boolean;
disabled: boolean;
index: number;
}
export interface CurrentPosition extends Point {
z?: number | string;
angle?: number;
lat?: number;
lng?: number;
}
export interface Marker extends CurrentPosition {
id: string;
icon: string;
selectedIcon: string;
position: 'centertop' | 'lefttop';
active?: boolean;
}
export interface MarkerIcon {
name: string;
content: string;
width: number;
height: number;
scale?: number;
}
export interface MarkersData {
icons: MarkerIcon[];
markers: Marker[];
}
export interface Visibility {
controls?: boolean;
levels?: boolean;
header?: boolean;
overlay?: boolean;
}
export interface Rect {
x1: number;
x2: number;
y1: number;
y2: number;
}
/**
* Defines a rectangular bounding box using two corner points.
*/
export interface Bounds {
/** Top-left corner of the bounding box */
leftTop: Point;
/** Bottom-right corner of the bounding box */
rightBottom: Point;
}
/**
* Selector for identifying a Point of Interest (POI) by name or external ID.
*/
export interface POISelector {
/** Name of the POI */
name?: string;
/** External identifier of the POI */
externalId?: string;
}
/**
* Collection of POI selectors for booths and exhibitors.
*/
export interface POISelectors {
/** Array of booth selectors */
booths?: POISelector[];
/** Array of exhibitor selectors */
exhibitors?: POISelector[];
}
/**
* Geographic anchor point that ties a floor plan coordinate to a real-world
* GPS location. Used to georeference the map.
*/
export interface GeoAnchor {
/** X coordinate in the floor plan coordinate system */
x: number;
/** Y coordinate in the floor plan coordinate system */
y: number;
/** Latitude in decimal degrees */
lat: number;
/** Longitude in decimal degrees */
lng: number;
}
/**
* Geographic configuration of the floor plan: its orientation and the anchor
* points that map local coordinates to GPS positions.
*/
export interface GeoConfig {
/** Bearing in degrees clockwise from true north; `0` when the map is north-aligned. */
bearing: number;
/** Primary anchor point. */
p0: GeoAnchor;
/** Optional secondary anchor point. */
p1?: GeoAnchor;
/** Tertiary anchor point. */
p2: GeoAnchor;
}
export {};
//# sourceMappingURL=types.d.ts.map