The MapView class is the main class for rendering and interacting with the map.

It provides a set of controls for manipulating the map's elements and state.

For help getting started, refer to the Getting Started Guide.

Hierarchy (View Summary, Expand)

Properties

BlueDot: BlueDot

Controls for BlueDot positioning.

Camera: Camera

Controls for the map's camera.

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

Images: Images

Controls for the map's markers.

Labels: Labels

Controls for the map's labels.

Markers: Markers

Controls for the map's markers.

Models: Models

Controls for the map's models.

Navigation: default.Navigation

Controls for the map's navigation.

off: <
    EventName extends
        | "click"
        | "hover"
        | "camera-change"
        | "floor-change-start"
        | "floor-change"
        | "dynamic-focus-change"
        | "outdoor-view-loaded"
        | "outdoor-style-loaded"
        | "user-interaction-start"
        | "user-interaction-end"
        | "blue-dot-position-update"
        | "blue-dot-state-change"
        | "blue-dot-error"
        | "blue-dot-follow-change"
        | "navigation-connection-click"
        | "navigation-active-path-change"
        | "pre-render"
        | "post-render"
        | "stacked-maps-state-change",
>(
    eventName: EventName,
    fn: (payload: TEventPayload<EventName>) => void,
) => void

Unsubscribe a function previously subscribed with on

Type declaration

    • <
          EventName extends
              | "click"
              | "hover"
              | "camera-change"
              | "floor-change-start"
              | "floor-change"
              | "dynamic-focus-change"
              | "outdoor-view-loaded"
              | "outdoor-style-loaded"
              | "user-interaction-start"
              | "user-interaction-end"
              | "blue-dot-position-update"
              | "blue-dot-state-change"
              | "blue-dot-error"
              | "blue-dot-follow-change"
              | "navigation-connection-click"
              | "navigation-active-path-change"
              | "pre-render"
              | "post-render"
              | "stacked-maps-state-change",
      >(
          eventName: EventName,
          fn: (payload: TEventPayload<EventName>) => void,
      ): void
    • Type Parameters

      • EventName extends
            | "click"
            | "hover"
            | "camera-change"
            | "floor-change-start"
            | "floor-change"
            | "dynamic-focus-change"
            | "outdoor-view-loaded"
            | "outdoor-style-loaded"
            | "user-interaction-start"
            | "user-interaction-end"
            | "blue-dot-position-update"
            | "blue-dot-state-change"
            | "blue-dot-error"
            | "blue-dot-follow-change"
            | "navigation-connection-click"
            | "navigation-active-path-change"
            | "pre-render"
            | "post-render"
            | "stacked-maps-state-change"

      Parameters

      • eventName: EventName

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

      • fn: (payload: TEventPayload<EventName>) => 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) => {
const { coordinate } = event;
const { latitude, longitude } = coordinate;
console.log(`Map was clicked at ${latitude}, ${longitude}`);
};
mapView.off('click', handler);
on: <
    EventName extends
        | "click"
        | "hover"
        | "camera-change"
        | "floor-change-start"
        | "floor-change"
        | "dynamic-focus-change"
        | "outdoor-view-loaded"
        | "outdoor-style-loaded"
        | "user-interaction-start"
        | "user-interaction-end"
        | "blue-dot-position-update"
        | "blue-dot-state-change"
        | "blue-dot-error"
        | "blue-dot-follow-change"
        | "navigation-connection-click"
        | "navigation-active-path-change"
        | "pre-render"
        | "post-render"
        | "stacked-maps-state-change",
>(
    eventName: EventName,
    fn: (payload: TEventPayload<EventName>) => void,
) => void

Subscribe a function to an event.

Type declaration

    • <
          EventName extends
              | "click"
              | "hover"
              | "camera-change"
              | "floor-change-start"
              | "floor-change"
              | "dynamic-focus-change"
              | "outdoor-view-loaded"
              | "outdoor-style-loaded"
              | "user-interaction-start"
              | "user-interaction-end"
              | "blue-dot-position-update"
              | "blue-dot-state-change"
              | "blue-dot-error"
              | "blue-dot-follow-change"
              | "navigation-connection-click"
              | "navigation-active-path-change"
              | "pre-render"
              | "post-render"
              | "stacked-maps-state-change",
      >(
          eventName: EventName,
          fn: (payload: TEventPayload<EventName>) => void,
      ): void
    • Type Parameters

      • EventName extends
            | "click"
            | "hover"
            | "camera-change"
            | "floor-change-start"
            | "floor-change"
            | "dynamic-focus-change"
            | "outdoor-view-loaded"
            | "outdoor-style-loaded"
            | "user-interaction-start"
            | "user-interaction-end"
            | "blue-dot-position-update"
            | "blue-dot-state-change"
            | "blue-dot-error"
            | "blue-dot-follow-change"
            | "navigation-connection-click"
            | "navigation-active-path-change"
            | "pre-render"
            | "post-render"
            | "stacked-maps-state-change"

      Parameters

      • eventName: EventName

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

      • fn: (payload: TEventPayload<EventName>) => 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}`);
};
mapView.on('click', handler);
Outdoor: Outdoor

Controls for the outdoor map.

Paths: Paths

Controls for the map's paths.

Shapes: Shapes

Controls custom GeoJSON geometry on the map

Style: Style

Controls for the indoor map's style.

Text3D: Text3DApi

Controls for the map's 3D texts.

update: () => void

Accessors

  • get currentFloor(): Floor
  • The current floor (Floor) of the map.

    Returns Floor

Methods

  • Clears all added elements from the map.

    Returns void

  • Creates a Coordinate on the map.

    Parameters

    • latitude: number

      The latitude of the coordinate.

    • longitude: number

      The longitude of the coordinate.

    • Optionalfloor: Floor

      Optional floor information if applicable.

    Returns Coordinate

    The created coordinate object.

    // Create a coordinate at the CN Tower.
    const coord = map.createCoordinate(43.642567, -79.387054);
  • Parameters

    • x: number
    • y: number
    • Optionalfloor: Floor

    Returns undefined | Coordinate

  • Destroys the MapView.

    Returns void

  • Experimental

    Enable debug interface. Learn more about the debug interface in the Debug Mode Guide.

    Parameters

    • Optionalopitons: Partial<InspectorState>

    Returns Promise<void>

  • Retrieves the dimensions of the map's canvas.

    Returns { height: number; width: number }

    An object containing the width and height of the canvas.

  • Get global state of the MapView

    Returns GlobalState

  • Returns undefined | string

  • Retrieves the map data for the current map.

    Returns { [x: string]: MapData }

    The MapData for the current map.

  • Determines if a given target is within the viewport.

    This method checks if the specified target, such as a Space, MapObject, Label, Marker, or string identifier, is currently within the visible area of the map viewport. Note that this method returns true even if the target is not visible (e.g., its visibility is set to false).

    Parameters

    Returns boolean

    A boolean indicating whether the target is within the viewport.

  • Sets the current floor (Floor) of the map.

    Parameters

    • floor: string | Floor

      The floor or floor ID to set.

    Returns void

  • Sets the current floor stack (FloorStack) of the map. The default floor of the stack will be set as the current floor.

    Parameters

    • floorStack: string | FloorStack

      The floor stack or floor stack ID to set.

    Returns void

  • Parameters

    • c: string

    Returns void

  • Experimental

    Takes a screenshot of the current scene and returns it as a data URL.

    NOTE: This only captures the 3D scene, not the UI elements like labels, markers, etc. Also, this does not cause the screenshot to be saved to the user's device, it only returns the data.

    Returns Promise<string>

    A Promise that resolves with the screenshot as a base64-encoded data URL string

  • Update global state of the MapView

    Parameters

    • update: Partial<
          {
              backgroundAlpha: number;
              backgroundColor: string;
              environment: Partial<EnvMapOptions>;
              geometry: Partial<{ hoverColor: string }>;
              text3d: Partial<{ hoverColor: string }>;
          },
      >

    Returns void

MMNEPVFCICPMFPCPTTAAATR