Situm SDK JS
    Preparing search index...

    Class Viewer

    Copyright (c) Situm Technologies. and its affiliates.

    This source code is licensed under the MIT license found in the LICENSE file in the root directory of this source tree.

    Index

    Constructors

    Methods

    • Stop fetching and sending realtime positions to the viewer, and clear the previous positions in the viewer.

      Returns Promise<void>

    • Clears the trajectory from the viewer.

      This function sends a "map.show_trajectory" event to the viewer with an empty data array and a status of "STOP". This will stop the trajectory animation and clear the trajectory from the map.

      Returns Promise<void>

      • If there is an error sending the event to the viewer.
    • Deselects the currently selected poi.

      This function sends a message to the viewer to deselect the currently selected poi. It does not take any parameters.

      Returns Promise<void>

    • Deselects the currently selected poi categories.

      This function sends a message to the viewer to deselect the currently selected poi categories. It does not take any parameters.

      Returns Promise<void>

    • Sets the options for the directions feature of the viewer.

      This function sends a message to the viewer to set the options for the directions feature. It does not return any value.

      Parameters

      • options: { excludedTags?: string[]; includedTags?: string[] }

        The options to set. The options object should contain the following properties:

        • includedTags: An array of tags to include in the directions.
        • excludedTags: An array of tags to exclude in the directions.

      Returns Promise<void>

    • Loads and displays the real-time positions of devices in the Situm dashboard. The positions are updated every refreshRateMs milliseconds.

      Parameters

      • opts: {
            customizeFeatures?: (position: RTDataCustomizer) => RTDataCustomizer;
            filter: { buildingIds?: number[] };
            refreshRateMs?: number;
        }

        The options for loading the real-time positions.

        • OptionalcustomizeFeatures?: (position: RTDataCustomizer) => RTDataCustomizer

          A function that customizes the appearance of the real-time positions on the map. The function is called with the base data of the position as an argument, and should return the customized data or undefined if the position should not be rendered.

        • filter: { buildingIds?: number[] }

          The filter for the real-time positions. Currently only supports filtering by building ID.

        • OptionalrefreshRateMs?: number

          The refresh rate for the real-time positions in milliseconds. Defaults to 10000.

      Returns Promise<void>

    • Loads and displays the trajectory of a user in the Situm dashboard. The trajectory is displayed on the map as a line, with the user's position updated every second.

      Parameters

      • opts: { buildingId: number; fromDate: Date; toDate: Date; userId?: string }

        The options for loading the trajectory.

        • buildingId: number

          The ID of the building the user is in.

        • fromDate: Date

          The start date of the trajectory.

        • toDate: Date

          The end date of the trajectory.

        • OptionaluserId?: string

          The ID of the user. If not provided, the trajectory of all users will be displayed.

      Returns Promise<void>

    • Attaches a callback to a viewer event. The callback will be called when the viewer sends a message with the type matching the event parameter.

      Type Parameters

      Parameters

      • event: T

        The type of the event to listen to.

      • callback: ViewerEventCallback<T>

        The callback to call when the event is triggered.

      Returns void

      viewer.on(ViewerEventType.MAP_IS_READY, () => {
      console.log("Viewer map is ready");
      });
    • Opens the location picker in the viewer.

      This function sends a message to the viewer to open the location picker. It does not return any value.

      Parameters

      • options:
            | {
                initialPosition: {
                    floorIdentifier: number;
                    latitude: number;
                    longitude: number;
                };
            }
            | { poiIdentifier: number }
            | { poiExternalIdentifier: string }

        The options to open the location picker. The options object should contain the following properties:

        • initialPosition: The initial position to set the location picker to.

      Returns Promise<void>

    • Store the user's car position.

      Parameters

      • params: { coordinate: { latitude: number; longitude: number }; floorIdentifier: number }

      Returns Promise<void>

    • Selects a building by its identifier.

      This function sends a message to the viewer to select the building with the given identifier. It does not return any value.

      Parameters

      • id: number

        The identifier of the building to select.

      Returns Promise<void>

    • Selects the saved find my car POI.

      Returns Promise<void>

    • Selects a floor by its identifier and building identifier.

      This function sends a message to the viewer to select the floor with the given identifier and building identifier. It does not return any value.

      Parameters

      • id: number

        The identifier of the floor to select.

      Returns Promise<void>

    • Selects a poi by its identifier.

      Parameters

      • id: number

        The identifier of the poi to select.

      Returns Promise<void>

    • Selects multiple POI categories by their identifiers.

      This function sends a message to the viewer to select the POI categories with the given identifiers. It does not return any value.

      Parameters

      • categoryId: number

      Returns Promise<void>

    • Sends a "app.set_auth" event to the viewer with the given jwt string.

      This function can be used to set the authentication token in the viewer.

      Parameters

      • jwt: string

        The jwt string to set as the authentication token.

      Returns Promise<void>

    • Sets the camera of the viewer.

      This function sends a message to the viewer to set the camera. It does not return any value.

      Parameters

      • options: Camera

        The options to set the camera. The options object should contain the following properties:

        • zoom: The zoom level of the camera.
        • bearing: The bearing of the camera.
        • pitch: The pitch of the camera.
        • transitionDuration: The duration of the camera transition.
        • center: The center of the camera.

      Returns Promise<void>

    • Sends a "app.set_config_item" event to the viewer with the given key and value.

      This function can be used to set configuration items in the viewer, such as the language or the units.

      Parameters

      • key: string

        The key of the configuration item to set.

      • value: unknown

        The value of the configuration item to set.

      Returns Promise<void>

      • If there is an error sending the event to the viewer.
    • Sets whether the camera should follow the user in the viewer.

      If set to true, the camera will move to the user's position when the user moves. If set to false, the camera will stay in its current position.

      Parameters

      • enabled: boolean

        Whether the camera should follow the user.

      Returns Promise<void>

      • If there is an error sending the event to the viewer.
    • Sets the UI mode of the viewer.

      This function sends a message to the viewer to set the UI mode. It does not return any value.

      Parameters

      • options: { mode: ViewerUIMode }

        The options to set the UI mode. The options object should contain the following properties:

        • mode: The mode to set.

      Returns Promise<void>

    • Sets the user's location on the map.

      This function sends a message to the viewer to update the user's location on the map. The location is specified by the options object which should contain the following properties:

      • x: The x coordinate of the user's location.
      • y: The y coordinate of the user's location.
      • latitude: The latitude of the user's location.
      • longitude: The longitude of the user's location.
      • floorIdentifier: The identifier of the floor that the user's location is on.
      • buildingIdentifier: The identifier of the building that the user's location is in.
      • accuracy: The accuracy of the user's location in meters. Optional.
      • bearing: The bearing of the user's location. Optional.
      • hasBearing: A boolean indicating whether the user's location has a bearing or not. Optional. but required to see the arrow.

      Parameters

      • options: {
            accuracy: number;
            bearing: { radians: number };
            buildingIdentifier: number;
            floorIdentifier: number;
            hasBearing: boolean;
            latitude: number;
            longitude: number;
            x: number;
            y: number;
        }

      Returns Promise<void>

    • Calculates a static route between two points.

      This function sends a message to the viewer to start the directions feature. It does not return any value.

      Parameters

      • options: { navigationFrom: number; navigationTo: number; routeType?: RouteType }

        The options to start the directions feature. The options object should contain the following properties:

        • navigationFrom: The identifier of the starting position of the directions.
        • navigationTo: The identifier of the ending position of the directions.
        • routeType: The type of route to calculate. Optional.

      Returns Promise<void>