Mappedin JS - v6.14.0
    Preparing search index...

    Interface MapData

    MapData is the core data container for all map information, providing access to spaces, floors, points of interest, and navigation capabilities. It serves as the foundation for building interactive indoor mapping applications.

    • Access to all map elements (spaces, floors, doors, etc.)
    • Built-in search functionality with suggestions
    • Navigation and wayfinding capabilities
    • Multi-language support
    • Analytics tracking
    • Data export and serialization

    Best Practice: Use getByType() to retrieve collections of map elements, and getById() for specific elements. Enable search functionality when you need location discovery features.

    // Get all spaces on the map
    const spaces = mapData.getByType('space');

    // Find a specific space by ID
    const space = mapData.getById('space', 'space-123');

    // Get directions between two locations
    const directions = mapData.getDirections(space1, space2);

    // Enable and use search
    await mapData.Search.enable();
    const results = await mapData.Search.query('Coffee Shop');

    // Change language
    await mapData.changeLanguage('es');
    • Collections: Use getByType() for all elements of a type
    • Specific Elements: Use getById() for individual elements
    • External IDs: Use getByExternalId() for custom identifiers
    • GeoJSON: Use getGeoJSON() for geometric data
    • getDirections(): Route between two locations
    • getDirectionsMultiDestination(): Route with multiple destinations
    • getDistance(): Calculate distance between locations

    Represents the data for a map, providing access to map elements like spaces, floors, and points of interest.

    interface MapData {
        Analytics: Analytics;
        Query: Query;
        Search: Search;
        get currentLanguage(): Language | undefined;
        get isEnterpriseMode(): boolean;
        get mapCenter(): Coordinate;
        get mapId(): string | undefined;
        get mapName(): string;
        get naturalBearing(): number;
        get organizationId(): string;
        get outdoorViewToken(): string | undefined;
        changeLanguage(localeCode: string): Promise<void>;
        getAccessToken(): string | undefined;
        getByExternalId<
            T extends
                | "space"
                | "area"
                | "object"
                | "floor"
                | "location-profile"
                | "door"
                | "point-of-interest"
                | "connection"
                | "enterprise-location"
                | "node"
                | "floor-stack"
                | "enterprise-category"
                | "enterprise-venue"
                | "location-category",
        >(
            type: T,
            externalId: string,
        ): TMapDataObjectTypes[T][];
        getById<
            T extends
                | "space"
                | "area"
                | "object"
                | "floor"
                | "location-profile"
                | "annotation"
                | "door"
                | "point-of-interest"
                | "connection"
                | "enterprise-location"
                | "node"
                | "facade"
                | "floor-stack"
                | "enterprise-category"
                | "location-category"
                | "unknown",
        >(
            type: T,
            id: string,
        ):
            | (
                T extends keyof TMapDataObjectTypes
                    ? TMapDataObjectTypes[T<T>]
                    :
                        | Space
                        | Area
                        | MapObject
                        | Floor
                        | LocationProfile
                        | Annotation
                        | Door
                        | PointOfInterest
                        | Connection
                        | EnterpriseLocation
                        | Node
                        | Facade
                        | FloorStack
                        | EnterpriseCategory
                        | EnterpriseVenue
                        | LocationCategory
            )
            | undefined;
        getById<T extends keyof TMapDataObjectTypes>(
            type: T,
            id: string,
        ): TMapDataObjectTypes[T] | undefined;
        getById<T extends "unknown">(
            type: T,
            id: string,
        ):
            | Space
            | Area
            | MapObject
            | Floor
            | LocationProfile
            | Annotation
            | Door
            | PointOfInterest
            | Connection
            | EnterpriseLocation
            | Node
            | Facade
            | FloorStack
            | EnterpriseCategory
            | EnterpriseVenue
            | LocationCategory
            | undefined;
        getByType(type: string): MapDataElements[];
        getByType(type: "space"): Space[];
        getByType(type: "door"): Door[];
        getByType(type: "floor"): Floor[];
        getByType(type: "floor-stack"): FloorStack[];
        getByType(type: "facade"): Facade[];
        getByType(type: "connection"): Connection[];
        getByType(type: "object"): MapObject[];
        getByType(type: "point-of-interest"): PointOfInterest[];
        getByType(type: "annotation"): Annotation[];
        getByType(type: "node"): Node[];
        getByType(type: "area"): Area[];
        getByType(type: "enterprise-location"): EnterpriseLocation[];
        getByType(type: "enterprise-category"): EnterpriseCategory[];
        getByType(type: "enterprise-venue"): EnterpriseVenue | undefined;
        getByType(type: "location-profile"): LocationProfile[];
        getByType(type: "location-category"): LocationCategory[];
        getDirections(
            from: TNavigationTarget | TNavigationTarget[],
            to: TNavigationTarget | TNavigationTarget[],
            options?: TGetDirectionsOptions,
        ): Promise<Directions | undefined>;
        getDirectionsMultiDestination(
            from: TNavigationTarget,
            to: (TNavigationTarget | TNavigationTarget[])[],
            options?: TGetDirectionsOptions,
        ): Promise<Directions[] | undefined>;
        getDistance(
            from:
                | Coordinate
                | Space
                | Area
                | MapObject
                | Annotation
                | Door
                | PointOfInterest
                | EnterpriseLocation
                | Node,
            to:
                | Coordinate
                | Space
                | Area
                | MapObject
                | Annotation
                | Door
                | PointOfInterest
                | EnterpriseLocation
                | Node,
        ): number;
        getEnv(): {
            get analyticsBaseUri(): string;
            get baseAuthUri(): string;
            get baseUri(): string;
            get tileServerUri(): string;
        };
        getGeoJSON<T extends IGeoJSONData>(mapDataObject: T): T["geoJSON"];
        off<EventName extends "language-change">(
            eventName: EventName,
            fn: (
                payload: TMapDataEvents[EventName] extends { data: null }
                    ? any[any]["data"]
                    : TMapDataEvents[EventName],
            ) => void,
        ): void;
        on<EventName extends "language-change">(
            eventName: EventName,
            fn: (
                payload: TMapDataEvents[EventName] extends { data: null }
                    ? any[any]["data"]
                    : TMapDataEvents[EventName],
            ) => void,
        ): void;
        toJSONBundle(
            options?: { downloadLanguagePacks?: boolean },
        ): Promise<THydrateMapDataBundle>;
    }
    Index

    Properties

    Analytics: Analytics
    Query: Query

    Query API for advanced data filtering and retrieval.

    Provides powerful querying capabilities to filter and find map elements based on various criteria.

    // Find all spaces with specific properties
    const results = mapData.Query.spaces()
    .where('category', 'retail')
    .where('floor', floor)
    .execute();
    Search: Search

    Search API for MapData

    Provides full-text search capabilities across all map locations, with support for suggestions, filtering, and result ranking.

    // Enable search
    const mapData = await getMapData({ search: { enabled: true } });
    // or
    await mapData.Search.enable();

    // Perform a search query
    const results = await mapData.Search.query('Coffee Shop');
    console.log(results.locations);
    // Get search suggestions
    const suggestions = await mapData.Search.suggest('Coff');
    console.log(suggestions);
    const results = await mapData.Search.query('Shop', {
    categories: ['retail'],
    floor: mapData.getByType('floor')[0]
    });

    Accessors

    • get currentLanguage(): Language | undefined

      Gets the current language of the map data.

      Returns Language | undefined

      The current language code and name.

      const language = mapData.currentLanguage;
      console.log(`Current language: ${language.name} (${language.code})`);
    • get isEnterpriseMode(): boolean

      Indicates whether the map data was loaded from a CMS/Enterprise data source.

      Use this property to determine which data types to access at runtime, especially when loading map data from a zip file where the data source is unknown beforehand.

      Returns boolean

      true if using CMS/Enterprise data source, false if using Maker.

      Data Source Detection:

      • true - Map uses CMS/Enterprise data. Use enterprise-location, enterprise-category, enterprise-venue.
      • false - Map uses Maker data. Use location-profile, location-category.

      Important for AI/Code Generation: When loading from a zip file (using hydrateMapData), always check this property and write code that handles both data sources dynamically. This ensures your code works with any map regardless of its origin.

      import { hydrateMapData } from '@mappedin/mappedin-js';

      const mapData = await hydrateMapData(bundle);

      // Handle both data sources dynamically
      const locations = mapData.isEnterpriseMode
      ? mapData.getByType('enterprise-location')
      : mapData.getByType('location-profile');

      const categories = mapData.isEnterpriseMode
      ? mapData.getByType('enterprise-category')
      : mapData.getByType('location-category');

      // Now use locations and categories regardless of data source
      locations.forEach(loc => console.log(loc.name));
      if (mapData.isEnterpriseMode) {
      const venue = mapData.getByType('enterprise-venue');
      console.log('Enterprise venue:', venue?.name);
      } else {
      console.log('Maker map - no venue object available');
      }
    • get mapCenter(): Coordinate

      The approximate center coordinate (Coordinate) of the map.

      Returns Coordinate

      The center coordinate of the map.

      const center = mapData.mapCenter;
      console.log(`Map center: ${center.latitude}, ${center.longitude}`);
    • get mapId(): string | undefined

      The unique identifier for the map.

      Returns string | undefined

      The map ID.

      console.log(mapData.mapId); // "map-12345"
      
    • get mapName(): string

      The name of the map.

      Returns string

      The name of the map.

      console.log(mapData.mapName); // "Downtown Mall"
      
    • get naturalBearing(): number

      Gets the natural bearing of the map.

      The natural bearing represents the orientation of the map relative to true north. This is useful for aligning the map with compass directions or external mapping systems.

      Returns number

      The natural bearing in degrees.

      const bearing = mapData.naturalBearing;
      console.log(`Map is oriented ${bearing} degrees from true north`);
    • get organizationId(): string

      The organization ID of the map.

      Returns string

      The organization ID of the map.

      console.log(mapData.organizationId); // "org-12345"
      
    • get outdoorViewToken(): string | undefined

      The token used to fetch outdoor tiles for outdoor map integration.

      Returns string | undefined

      The outdoor view token.

      const outdoorToken = mapData.outdoorViewToken;
      if (outdoorToken) {
      // Configure outdoor map with token
      }

    Methods

    • Changes the language of the map data.

      Updates all text content (names, descriptions, etc.) to the specified language. The map will emit a 'language-change' event when the language is updated.

      Parameters

      • localeCode: string

        The ISO 639-1 language code to change to (e.g., 'en' for English, 'fr' for French). Check (EnterpriseVenue.languages) for available languages

      Returns Promise<void>

      A promise that resolves when the language change is complete.

      await mapData.changeLanguage('es');
      console.log('Map language changed to Spanish');
      await mapData.changeLanguage('fr');
      console.log('Map language changed to French');
      mapData.on('language-change', ({ code, name }) => {
      console.log(`Language changed to ${name} (${code})`);
      });
    • Get an access token for use with Mappedin's API.

      Returns the current access token that can be used for authenticated API requests.

      Returns string | undefined

      The current access token

      const token = mapData.getAccessToken();
      // Use token for API requests
    • Retrieves map elements by their external ID.

      External IDs are custom identifiers that can be assigned to map elements. This is useful for integrating with external systems or databases.

      Type Parameters

      • T extends
            | "space"
            | "area"
            | "object"
            | "floor"
            | "location-profile"
            | "door"
            | "point-of-interest"
            | "connection"
            | "enterprise-location"
            | "node"
            | "floor-stack"
            | "enterprise-category"
            | "enterprise-venue"
            | "location-category"

      Parameters

      • type: T

        The type of element to retrieve.

      • externalId: string

        The external identifier to search for.

      Returns TMapDataObjectTypes[T][]

      An array of elements with the matching external ID.

      Data Source Availability:

      • 'enterprise-location', 'enterprise-category' - Only available with CMS/Enterprise credentials
      • 'location-profile' - Only available with Maker credentials (keys starting with mik_)
      • All other types ('space', 'floor', etc.) - Available with both credential types
      const spaces = mapData.getByExternalId('space', 'STORE-001');
      spaces.forEach(space => console.log(`Found space: ${space.name}`));
      // With CMS/Enterprise credentials:
      const locations = mapData.getByExternalId('enterprise-location', 'RESTAURANT-ABC');
      locations.forEach(location => console.log(`Found location: ${location.name}`));
      // With Maker credentials (mik_ keys):
      const locations = mapData.getByExternalId('location-profile', 'RESTAURANT-ABC');
      locations.forEach(location => console.log(`Found location: ${location.name}`));
    • Retrieves a specific map feature by its type and ID.

      Use this method to find individual map elements when you know their exact ID. This is more efficient than filtering collections for specific elements.

      Type Parameters

      • T extends
            | "space"
            | "area"
            | "object"
            | "floor"
            | "location-profile"
            | "annotation"
            | "door"
            | "point-of-interest"
            | "connection"
            | "enterprise-location"
            | "node"
            | "facade"
            | "floor-stack"
            | "enterprise-category"
            | "location-category"
            | "unknown"

      Parameters

      • type: T

        The type of element to retrieve.

      • id: string

        The unique identifier of the element.

      Returns
          | (
              T extends keyof TMapDataObjectTypes
                  ? TMapDataObjectTypes[T<T>]
                  :
                      | Space
                      | Area
                      | MapObject
                      | Floor
                      | LocationProfile
                      | Annotation
                      | Door
                      | PointOfInterest
                      | Connection
                      | EnterpriseLocation
                      | Node
                      | Facade
                      | FloorStack
                      | EnterpriseCategory
                      | EnterpriseVenue
                      | LocationCategory
          )
          | undefined

      The map element if found, undefined otherwise.

      Data Source Availability:

      • 'enterprise-location', 'enterprise-category', 'enterprise-venue' - Only available with CMS/Enterprise credentials
      • 'location-profile', 'location-category' - Only available with Maker credentials (keys starting with mik_)
      • All other types ('space', 'floor', 'door', etc.) - Available with both credential types
      const space = mapData.getById('space', 'space-123');
      if (space) {
      console.log(`Found space: ${space.name}`);
      }
      const floor = mapData.getById('floor', 'floor-1');
      if (floor) {
      console.log(`Floor level: ${floor.level}`);
      }
      const door = mapData.getById('door', 'door-main-entrance');
      if (door) {
      console.log(`Door type: ${door.type}`);
      }

      In general, it is better to specify the type if you know it, since you get better type safety.

      const element = mapData.getById('unknown', 'element-123');
      if (!element) {
      console.log(`Element not found`);
      } else if (Space.is(element)) {
      console.log(`Found space: ${element.name}`);
      } else if (Door.is(element)) ...
    • Retrieves a specific map feature by its type and ID.

      Use this method to find individual map elements when you know their exact ID. This is more efficient than filtering collections for specific elements.

      Type Parameters

      Parameters

      • type: T

        The type of element to retrieve.

      • id: string

        The unique identifier of the element.

      Returns TMapDataObjectTypes[T] | undefined

      The map element if found, undefined otherwise.

      Data Source Availability:

      • 'enterprise-location', 'enterprise-category', 'enterprise-venue' - Only available with CMS/Enterprise credentials
      • 'location-profile', 'location-category' - Only available with Maker credentials (keys starting with mik_)
      • All other types ('space', 'floor', 'door', etc.) - Available with both credential types
      const space = mapData.getById('space', 'space-123');
      if (space) {
      console.log(`Found space: ${space.name}`);
      }
      const floor = mapData.getById('floor', 'floor-1');
      if (floor) {
      console.log(`Floor level: ${floor.level}`);
      }
      const door = mapData.getById('door', 'door-main-entrance');
      if (door) {
      console.log(`Door type: ${door.type}`);
      }

      In general, it is better to specify the type if you know it, since you get better type safety.

      const element = mapData.getById('unknown', 'element-123');
      if (!element) {
      console.log(`Element not found`);
      } else if (Space.is(element)) {
      console.log(`Found space: ${element.name}`);
      } else if (Door.is(element)) ...
    • Retrieves a specific map feature by its type and ID.

      Use this method to find individual map elements when you know their exact ID. This is more efficient than filtering collections for specific elements.

      Type Parameters

      • T extends "unknown"

      Parameters

      • type: T

        The type of element to retrieve.

      • id: string

        The unique identifier of the element.

      Returns
          | Space
          | Area
          | MapObject
          | Floor
          | LocationProfile
          | Annotation
          | Door
          | PointOfInterest
          | Connection
          | EnterpriseLocation
          | Node
          | Facade
          | FloorStack
          | EnterpriseCategory
          | EnterpriseVenue
          | LocationCategory
          | undefined

      The map element if found, undefined otherwise.

      Data Source Availability:

      • 'enterprise-location', 'enterprise-category', 'enterprise-venue' - Only available with CMS/Enterprise credentials
      • 'location-profile', 'location-category' - Only available with Maker credentials (keys starting with mik_)
      • All other types ('space', 'floor', 'door', etc.) - Available with both credential types
      const space = mapData.getById('space', 'space-123');
      if (space) {
      console.log(`Found space: ${space.name}`);
      }
      const floor = mapData.getById('floor', 'floor-1');
      if (floor) {
      console.log(`Floor level: ${floor.level}`);
      }
      const door = mapData.getById('door', 'door-main-entrance');
      if (door) {
      console.log(`Door type: ${door.type}`);
      }

      In general, it is better to specify the type if you know it, since you get better type safety.

      const element = mapData.getById('unknown', 'element-123');
      if (!element) {
      console.log(`Element not found`);
      } else if (Space.is(element)) {
      console.log(`Found space: ${element.name}`);
      } else if (Door.is(element)) ...
    • Retrieves all map elements of a specific type.

      This is the primary method for accessing collections of map elements. Use the typed overloads for better TypeScript support.

      Parameters

      • type: string

        The type of elements to retrieve.

      Returns MapDataElements[]

      An array of elements of the given type.

      const spaces = mapData.getByType('space');
      console.log(`Found ${spaces.length} spaces`);
      const floors = mapData.getByType('floor');
      floors.forEach(floor => console.log(floor.name));
      const doors = mapData.getByType('door');
      const entranceDoors = doors.filter(door => door.type === 'entrance');
    • Parameters

      • type: "space"

      Returns Space[]

      The spaces (Space) on the map.

      const spaces = mapData.getByType('space');
      const retailSpaces = spaces.filter(space => space.category === 'retail');
    • Parameters

      • type: "door"

      Returns Door[]

      The doors (Door) on the map.

      const doors = mapData.getByType('door');
      const entranceDoors = doors.filter(door => door.type === 'entrance');
    • Parameters

      • type: "floor"

      Returns Floor[]

      The floors (Floor) on the map.

      const floors = mapData.getByType('floor');
      const groundFloor = floors.find(floor => floor.level === 0);
    • Parameters

      • type: "floor-stack"

      Returns FloorStack[]

      The stacks of floors (FloorStack) within the map.

      const floorStacks = mapData.getByType('floor-stack');
      const mainBuilding = floorStacks.find(stack => stack.name === 'Main Building');
    • Parameters

      • type: "facade"

      Returns Facade[]

      The facades (Facade) within the map.

      const facades = mapData.getByType('facade');
      const northFacade = facades.find(facade => facade.name === 'North');
    • Parameters

      • type: "connection"

      Returns Connection[]

      The connections (Connection) on the map.

      const connections = mapData.getByType('connection');
      const elevators = connections.filter(conn => conn.type === 'elevator');
    • Parameters

      • type: "object"

      Returns MapObject[]

      The objects (MapObject) on the map.

      const objects = mapData.getByType('object');
      const furniture = objects.filter(obj => obj.category === 'furniture');
    • Parameters

      • type: "point-of-interest"

      Returns PointOfInterest[]

      The points of interest (PointOfInterest) on the map.

      const pois = mapData.getByType('point-of-interest');
      const restrooms = pois.filter(poi => poi.category === 'restroom');
    • Parameters

      • type: "annotation"

      Returns Annotation[]

      The annotations (Annotation) on the map.

      const annotations = mapData.getByType('annotation');
      const infoAnnotations = annotations.filter(ann => ann.type === 'info');
    • Parameters

      • type: "node"

      Returns Node[]

      The nodes (Node) on the map.

      const nodes = mapData.getByType('node');
      const navigationNodes = nodes.filter(node => node.type === 'navigation');
    • Parameters

      • type: "area"

      Returns Area[]

      The areas (Area) on the map.

      const areas = mapData.getByType('area');
      const parkingAreas = areas.filter(area => area.category === 'parking');
    • Parameters

      • type: "enterprise-location"

      Returns EnterpriseLocation[]

      The enterprise locations (EnterpriseLocation) on the map.

      Data Source: Enterprise - Only populated when using CMS/Enterprise credentials (clientId/clientSecret or API keys that do NOT start with mik_). Returns an empty array when using Maker credentials. Use 'location-profile' instead for Maker data.

      const locations = mapData.getByType('enterprise-location');
      const stores = locations.filter(loc => loc.category === 'store');
    • Parameters

      • type: "enterprise-category"

      Returns EnterpriseCategory[]

      The enterprise categories (EnterpriseCategory) on the map.

      Data Source: Enterprise - Only populated when using CMS/Enterprise credentials (clientId/clientSecret or API keys that do NOT start with mik_). Returns an empty array when using Maker credentials. Use 'location-category' instead for Maker data.

      const categories = mapData.getByType('enterprise-category');
      const retailCategories = categories.filter(cat => cat.type === 'retail');
    • Parameters

      • type: "enterprise-venue"

      Returns EnterpriseVenue | undefined

      The enterprise venue (EnterpriseVenue) for the map, or undefined if not available.

      Data Source: Enterprise - Only available when using CMS/Enterprise credentials (clientId/clientSecret or API keys that do NOT start with mik_). Returns undefined when using Maker credentials.

      const venue = mapData.getByType('enterprise-venue');
      if (venue) {
      console.log(venue.name, venue.languages);
      }
    • Parameters

      • type: "location-profile"

      Returns LocationProfile[]

      The location profiles (LocationProfile) on the map.

      Data Source: Maker - Only populated when using Maker credentials (API keys starting with mik_). Returns an empty array when using CMS/Enterprise credentials. Use 'enterprise-location' instead for Enterprise data.

      const profiles = mapData.getByType('location-profile');
      const featuredProfiles = profiles.filter(profile => profile.featured);
    • Parameters

      • type: "location-category"

      Returns LocationCategory[]

      The location categories (LocationCategory) on the map.

      Data Source: Maker - Only populated when using Maker credentials (API keys starting with mik_). Returns an empty array when using CMS/Enterprise credentials. Use 'enterprise-category' instead for Enterprise data.

      const categories = mapData.getByType('location-category');
      const mainCategories = categories.filter(cat => cat.parent === null);
    • Calculates directions between two or more locations.

      Provides turn-by-turn navigation instructions and a path between the specified locations. The path avoids obstacles and follows walkable routes.

      Parameters

      Returns Promise<Directions | undefined>

      A Directions object containing the route, or undefined if no route is found.

      const space1 = mapData.getById('space', 'space-123');
      const space2 = mapData.getById('space', 'space-456');

      if (space1 && space2) {
      const directions = await mapData.getDirections(space1, space2);
      if (directions) {
      console.log(`Distance: ${directions.distance}m`);
      console.log(`Duration: ${directions.duration}s`);
      directions.instructions.forEach(instruction => {
      console.log(instruction.action.type);
      });
      }
      }
      const directions = await mapData.getDirections(space1, space2, {
      accessible: true,
      smoothing: { radius: 3 }
      });
      const directions = await mapData.getDirections([space1, space2], destination);
      
    • Calculates directions to multiple destinations.

      Provides routes from a single starting point to multiple destinations. Useful for finding the best route when visiting multiple locations.

      Parameters

      Returns Promise<Directions[] | undefined>

      An array of Directions objects, one for each destination.

      const start = mapData.getById('space', 'entrance');
      const destinations = [
      mapData.getById('space', 'store-1'),
      mapData.getById('space', 'store-2'),
      mapData.getById('space', 'restaurant')
      ].filter(Boolean);

      const allDirections = await mapData.getDirectionsMultiDestination(start, destinations);
      allDirections.forEach((directions, index) => {
      console.log(`Route ${index + 1}: ${directions.distance}m`);
      });
      const directions = await mapData.getDirectionsMultiDestination(start, [
      [destination1, destination2], // First route option
      [destination3, destination4] // Second route option
      ]);
    • Calculates the straight-line distance between two locations.

      Returns the direct distance between two points, not following walkable paths. For navigation distances, use getDirections.

      Parameters

      Returns number

      The distance in meters.

      const space1 = mapData.getById('space', 'space-123');
      const space2 = mapData.getById('space', 'space-456');

      if (space1 && space2) {
      const distance = mapData.getDistance(space1, space2);
      console.log(`Direct distance: ${distance}m`);
      }
      const coordinate = mapData.mapCenter;
      const space = mapData.getByType('space')[0];
      const distance = mapData.getDistance(coordinate, space);
      console.log(`Distance from center: ${distance}m`);
    • Get the current environment configuration.

      Returns the environment settings including API endpoints and configuration.

      Returns {
          get analyticsBaseUri(): string;
          get baseAuthUri(): string;
          get baseUri(): string;
          get tileServerUri(): string;
      }

      Environment configuration object

      const env = mapData.getEnv();
      console.log(env.baseUri); // Get the API URL for the current environment
    • Retrieves the GeoJSON representation of a map element.

      Returns the geometric data for a map element in GeoJSON format, which can be used for custom rendering, analysis, or integration with mapping libraries.

      Type Parameters

      Parameters

      • mapDataObject: T

        The map element to get GeoJSON for.

      Returns T["geoJSON"]

      The GeoJSON representation of the element.

      const space = mapData.getById('space', 'space-123');
      if (space) {
      const geoJSON = mapData.getGeoJSON(space);
      console.log('Space geometry:', geoJSON.geometry);
      console.log('Space properties:', geoJSON.properties);
      }
      const floor = mapData.getByType('floor')[0];
      const geoJSON = mapData.getGeoJSON(floor);
      console.log('Floor bounds:', geoJSON.geometry.coordinates);
    • Unsubscribe from MapData events.

      Type Parameters

      • EventName extends "language-change"

      Parameters

      • eventName: EventName

        The name of the event to unsubscribe from.

      • fn: (
            payload: TMapDataEvents[EventName] extends { data: null }
                ? any[any]["data"]
                : TMapDataEvents[EventName],
        ) => void

        The callback function that was previously registered with on().

      Returns void

      const handleLanguageChange = ({ code, name }) => {
      console.log(`Language changed to ${name}`);
      };

      // Add listener
      mapData.on('language-change', handleLanguageChange);

      // Later, remove the listener
      mapData.off('language-change', handleLanguageChange);
    • Subscribe to MapData events.

      Listen for events emitted by the MapData instance such as language changes.

      Type Parameters

      • EventName extends "language-change"

      Parameters

      Returns void

      mapData.on('language-change', ({ code, name }) => {
      console.log(`Language changed to ${name} (${code})`);

      // Update UI to reflect new language
      updateInterfaceLanguage(code);
      });
    • Exports the map data as a JSON bundle.

      Creates a JSON representation of the map data that can be easily parsed and manipulated. Useful for data analysis, debugging, or integration with other systems.

      Parameters

      • options: { downloadLanguagePacks?: boolean } = {}

        Configuration options for the export.

        • OptionaldownloadLanguagePacks?: boolean

          Whether to include language packs in the export.

      Returns Promise<THydrateMapDataBundle>

      A JSON bundle containing the map data.

      const jsonBundle = mapData.toJSONBundle({ downloadLanguagePacks: true });
      console.log('Map data exported:', jsonBundle);
      const jsonBundle = mapData.toJSONBundle({ downloadLanguagePacks: false });
      // Use JSON data for analysis or processing