Class MapData

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

Hierarchy (view full)

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

Properties

Analytics: Analytics

Accessors

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

    Returns string

    The name 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

  • Retrieves a specific map feature by its type and ID.

    Parameters

    • type: "space"

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

    • id: string

      The ID of the element.

    Returns undefined | Space

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

    const space = mapData.getById('space', 'space-id');
    
  • Parameters

    • type: "door"
    • id: string

    Returns undefined | Door

  • Parameters

    • type: "floor"
    • id: string

    Returns undefined | Floor

  • Parameters

    • type: "connection"
    • id: string

    Returns undefined | Connection

  • Parameters

    • type: "object"
    • id: string

    Returns undefined | MapObject

  • Parameters

    • type: "point-of-interest"
    • id: string

    Returns undefined | PointOfInterest

  • Parameters

    • type: "annotation"
    • id: string

    Returns undefined | Annotation

  • Parameters

    • type: "location"
    • id: string

    Returns undefined | Location

  • Parameters

    • type: "category"
    • id: string

    Returns undefined | Category

  • Parameters

    • type: string
    • id: string

    Returns undefined | object

  • 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: "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');
    
  • 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.

        • (payload): void
        • Parameters

          • payload: {
                    language-change: {
                        code: string;
                        name: string;
                    };
                }[EVENT_NAME] extends {
                    data: null;
                }
                ? any[any]["data"]
                : {
                    language-change: {
                        code: string;
                        name: string;
                    };
                }[EVENT_NAME]

          Returns void

    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.

        • (payload): void
        • Parameters

          • payload: {
                    language-change: {
                        code: string;
                        name: string;
                    };
                }[EVENT_NAME] extends {
                    data: null;
                }
                ? any[any]["data"]
                : {
                    language-change: {
                        code: string;
                        name: string;
                    };
                }[EVENT_NAME]

          Returns void

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