Class BlueDot

Generic PubSub class implementing the Publish-Subscribe pattern for event handling.

Hierarchy (view full)

Properties

state: TBlueDotState = 'disabled'

Accessors

  • get accuracy(): undefined | number
  • The accuracy of the current position in metres.

    Returns undefined | number

  • get coordinate(): undefined | Coordinate
  • The coordinate of the current position.

    Returns undefined | Coordinate

  • get floor(): undefined | Floor
  • The floor the Blue Dot is currently on. If undefined, the Blue Dot will appear on every floor.

    Returns undefined | Floor

  • get heading(): undefined | null | number
  • The direction the user is facing in degrees from north.

    Returns undefined | null | number

Methods

  • Disable the Blue Dot. It will be hidden and no longer update.

    Returns void

  • Enable the Blue Dot. It will be hidden until a position is received either from the browser or by calling BlueDot.update.

    Parameters

    Returns void

  • Unsubscribe a function previously subscribed with on

    Type Parameters

    • EVENT_NAME extends "floor-change"

    Parameters

    • eventName: EVENT_NAME

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

    • fn: ((payload: TBlueDotEvents[EVENT_NAME] extends {
              data: null;
          }
          ? any[any]["data"]
          : TBlueDotEvents[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: TBlueDotEvents[EVENT_NAME] extends {
                    data: null;
                }
                ? any[any]["data"]
                : TBlueDotEvents[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 "floor-change"

    Parameters

    • eventName: EVENT_NAME

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

    • fn: ((payload: TBlueDotEvents[EVENT_NAME] extends {
              data: null;
          }
          ? any[any]["data"]
          : TBlueDotEvents[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: TBlueDotEvents[EVENT_NAME] extends {
                    data: null;
                }
                ? any[any]["data"]
                : TBlueDotEvents[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);
  • Manually override some position properties of the Blue Dot. Accepts a full GeolocationPosition object or a partial TBlueDotPositionUpdate object.

    Parameters

    • position: undefined | TBlueDotPositionUpdate | GeolocationPosition & {
          coords: GeolocationCoordinates & {
              floorLevel?: number;
          };
      }

    Returns void

    api.BlueDot.update({ accuracy: 10, heading: 90 });
    
    api.BlueDot.update({ accuracy: 'device', heading: 'device' });
    
  • Enable or disable the devices's geolocation listener to automatically position the Blue Dot. If enabled, the device will request permission to access the user's precise location.

    Parameters

    • watch: boolean

      Whether to enable or disable the listener.

    Returns void