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

Hierarchy (View Summary, Expand)

  • PubSub<{ "language-change": { code: string; name: string } }>
    • MapData

Properties

Analytics: Analytics
getDirections: (
    from: TNavigationTarget | TNavigationTarget[],
    to: TNavigationTarget | TNavigationTarget[],
    options?: TGetDirectionsOptions,
) => undefined | Directions

Retrieves directions (Directions) from one navigable point (TNavigationTarget) to another on the map.

Type declaration

const directions = await map.getDirections(space1, space2);
getDirectionsMultiDestination: (
    from: TNavigationTarget,
    to: (TNavigationTarget | TNavigationTarget[])[],
    options?: TGetDirectionsOptions,
) => undefined | Directions[]

Retrieves directions (Directions) from one navigable point (TNavigationTarget) to multiple destination points on the map.

Type declaration

const directions = await map.getDirections(space1, [space2, space3]);
Query: Query
Search: Search

Search API for MapData

// 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);

Accessors

  • get mapName(): string
  • The name of the map.

    Returns string

    The name of the map.

  • get naturalBearing(): number
  • Retrieves the natural bearing of the map, which is the angle, in degrees, the map is considered to be "naturally oriented" towards. Typically the angle perpendicular to the street the map is facing, or the main entrance. Other print maps inside the map may have this direction be up. 90 degrees means East is "up"

    Returns number

    The natural bearing of the map.

  • get organizationId(): string
  • The organization ID of the map.

    Returns string

    The organization ID of the map.

  • get outdoorViewToken(): undefined | string
  • The token is used to fetch outdoor tiles.

    Returns undefined | string

    The outdoor view token.

Methods

  • Changes the language of the map data.

    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.

    An error if the language change fails.

    try {
    await mapData.changeLanguage('fr');
    console.log('Language changed to French');
    } catch (error) {
    console.error('Failed to change language:', error);
    }
  • Retrieves an array of map features by their type and shared external ID.

    Type Parameters

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

    Parameters

    • type: T

      The type of the element to retrieve (e.g., 'space', 'object').

    • externalId: string

      The external ID of the element.

    Returns TMapDataObjectTypes[T][]

    An array of features with the given type and external ID if they exist.

    const spaces = mapData.getByExternalId('space', 'space-external-id');
    
  • Retrieves a specific map feature by its type and ID.

    Type Parameters

    Parameters

    • type: T

      The type of the element to retrieve (e.g., 'space', 'object').

    • id: string

      The ID of the element.

    Returns undefined | TMapDataObjectTypes[T]

    The feature with the given type and ID, or undefined if it does not exist.

    const space = mapData.getById('space', 'space-id');
    
  • Retrieves all map elements of a specific type.

    Parameters

    • type: string

      The type of elements to retrieve (e.g., 'space', 'object').

    Returns object[]

    An array of elements of the given type.

    const spaces = mapData.getByType('space');
    
  • Parameters

    • type: "space"

    Returns Space[]

    The spaces (Space) on the map.

    const spaces = mapData.getByType('space');
    
  • Parameters

    • type: "door"

    Returns Door[]

    The doors (Door) on the map.

    const doors = mapData.getByType('door');
    
  • Parameters

    • type: "floor"

    Returns Floor[]

    The floors (Floor) on the map.

    const floors = mapData.getByType('floor');
    
  • Parameters

    • type: "floor-stack"

    Returns FloorStack[]

    The stacks of floors (FloorStack) within the map.

    const floorStacks = mapData.getByType('floor-stack');
    
  • Parameters

    • type: "facade"

    Returns Facade[]

    The facades (Facade) within the map.

    const facades = mapData.getByType('facade');
    
  • Parameters

    • type: "connection"

    Returns Connection[]

    The connections (Connection) on the map.

    const connections = mapData.getByType('connection');
    
  • Parameters

    • type: "object"

    Returns MapObject[]

    The objects (MapObject) on the map.

    const objects = mapData.getByType('object');
    
  • Parameters

    • type: "point-of-interest"

    Returns PointOfInterest[]

    The points of interest (PointOfInterest) on the map.

    const pointsOfInterest = mapData.getByType('point-of-interest');
    
  • Parameters

    • type: "annotation"

    Returns Annotation[]

    The annotations (Annotation) on the map.

    const annotations = mapData.getByType('annotation');
    
  • Parameters

    • type: "area"

    Returns Area[]

    The areas (Area) on the map.

    const areas = mapData.getByType('area');
    
  • Parameters

    • type: "node"

    Returns Node[]

    The nodes (Node) on the map.

    const nodes = mapData.getByType('node');
    
  • Parameters

    • type: "location-profile"

    Returns LocationProfile[]

    The location profiles (LocationProfile) on the map.

    const locationProfiles = mapData.getByType('location-profile');
    
  • Parameters

    • type: "location-category"

    Returns LocationCategory[]

    The location categories (LocationCategory) on the map.

    const locationCategories = mapData.getByType('location-category');
    
  • Parameters

    • type: "enterprise-location"

    Returns EnterpriseLocation[]

    The enterprise locations (EnterpriseLocation) on the map.

    const enterpriseLocations = mapData.getByType('enterprise-location');
    
  • Parameters

    • type: "enterprise-category"

    Returns EnterpriseCategory[]

    The enterprise categories (EnterpriseCategory) on the map.

    const enterpriseCategories = mapData.getByType('enterprise-category');
    
  • Parameters

    • type: "enterprise-venue"

    Returns undefined | EnterpriseVenue

    The enterprise venue (EnterpriseVenue) on the map.

    const enterpriseVenue = mapData.getByType('enterprise-venue');
    
  • Get the current environment.

    Returns {
        analyticsBaseUri: string;
        baseAuthUri: string;
        baseUri: string;
        tileServerUri: string;
    }

    const env = mapData.getEnv();
    console.log(env.baseUri); // Get the API URL for the current environment
  • Get the GeoJSON for a map data object on the map.

    Type Parameters

    • T extends IGeoJSONData

    Parameters

    • mapDataObject: T

    Returns T["geoJSON"]

  • Unsubscribe a function previously subscribed with on

    Type Parameters

    • EVENT_NAME extends "language-change"

    Parameters

    • eventName: EVENT_NAME

      An event name to which the provided function was previously subscribed.

    • fn: (
          payload: { "language-change": { code: string; name: string } }[EVENT_NAME] extends {
              data: null;
          }
              ? any[any]["data"]
              : { "language-change": { code: string; name: string } }[EVENT_NAME],
      ) => void

      A function that was previously passed to on. The function must have the same reference as the function that was subscribed.

    Returns void

    // Unsubscribe from the 'click' event
    const handler = (event) => {
    console.log('Map was clicked', event);
    };
    map.off('click', handler);
  • Subscribe a function to an event.

    Type Parameters

    • EVENT_NAME extends "language-change"

    Parameters

    • eventName: EVENT_NAME

      An event name which, when fired, will call the provided function.

    • fn: (
          payload: { "language-change": { code: string; name: string } }[EVENT_NAME] extends {
              data: null;
          }
              ? any[any]["data"]
              : { "language-change": { code: string; name: string } }[EVENT_NAME],
      ) => void

      A callback that gets called when the corresponding event is fired. The callback will get passed an argument with a type that's one of event payloads.

    Returns void

    // Subscribe to the 'click' event
    const handler = (event) => {
    const { coordinate } = event;
    const { latitude, longitude } = coordinate;
    console.log(`Map was clicked at ${latitude}, ${longitude}`);
    };
    map.on('click', handler);
  • Parameters

    • Optional__namedParameters: { downloadLanguagePacks?: boolean }

    Returns Promise<THydrateMapDataBundle>

MMNEPVFCICPMFPCPTTAAATR