Holds an API token and environment. Can be used to access an axios instance for REST API calls, or openStream() for opening a tag stream. You can create multiple API instances in case you want to use multiple tokens (e.g. to show data from multiple locations or organizations on a single page).

Example

// Basic usage
const api = new MeridianSDK.API({
token: "<TOKEN GOES HERE>"
});

// Multiple APIs at once
const apiOrg1 = new MeridianSDK.API({
token: "Insert Org 1 token here"
});
MeridianSDK.createMap(elementOrg1, {
api: apiOrg1,
locationID: "Insert Org 1 location ID here",
floorID: "Insert Org 1 floor ID here"
});

const apiOrg2 = new MeridianSDK.API({
token: "Insert Org 2 token here"
});
MeridianSDK.createMap(elementOrg2, {
api: apiOrg2,
locationID: "Insert Org 2 location ID here",
floorID: "Insert Org 2 floor ID here"
});

Constructors

Properties

debouncedPlacemarkSearchBeta: ((options) => Promise<null | Record<string, any>[]>) = ...

[async] Returns an array of results or null when a request is cancelled or debounced. Cancellation happens when a new request is made before the previous request completes. The Debounce wait time is 6ms and the function is invoked with the last arguments provided.

Both cancelled and debounced requests will eventually resolve with an array of results (possibly empty).

Requests that throw an exception will return an empty array and output a warning message to the Web console.

Local/Nearby Search integration. If both refFloorID AND refPoint are provided, a second API call will be made and the results will be ordered where placemarks closest to the refPoint (x/y) will appear first.

Placemark Search defaults to a single instance per API. This should work fine for most use cases, but if you need to make multiple unique search calls simultaneously, each will need a unique API instance like shown below.

// Search Widget One API Instance.
const apiInstance1 = new MeridianSDK.API({
token: "<TOKEN GOES HERE>"
});

// Search Widget Two API Instance
const apiInstance2 = new MeridianSDK.API({
token: "<TOKEN GOES HERE>"
});

Type declaration

    • (options): Promise<null | Record<string, any>[]>
    • Experimental

      [async] Returns an array of results or null when a request is cancelled or debounced. Cancellation happens when a new request is made before the previous request completes. The Debounce wait time is 6ms and the function is invoked with the last arguments provided.

      Both cancelled and debounced requests will eventually resolve with an array of results (possibly empty).

      Requests that throw an exception will return an empty array and output a warning message to the Web console.

      Local/Nearby Search integration. If both refFloorID AND refPoint are provided, a second API call will be made and the results will be ordered where placemarks closest to the refPoint (x/y) will appear first.

      Placemark Search defaults to a single instance per API. This should work fine for most use cases, but if you need to make multiple unique search calls simultaneously, each will need a unique API instance like shown below.

      // Search Widget One API Instance.
      const apiInstance1 = new MeridianSDK.API({
      token: "<TOKEN GOES HERE>"
      });

      // Search Widget Two API Instance
      const apiInstance2 = new MeridianSDK.API({
      token: "<TOKEN GOES HERE>"
      });

      Parameters

      Returns Promise<null | Record<string, any>[]>

environment: EnvOptions

Meridian environment ("production" or "eu"). Defaults to "production".

language: undefined | "no" | "en" | "ar" | "ca" | "es" | "cs" | "de" | "fr" | "it" | "iw" | "ja" | "ko" | "nl" | "pt" | "ru" | "sv" | "uk" | "vi" | "zh-cn" | "zh-tw"

Language code that matches a supported language for this location. Note: The LanguageCodes Type includes all possible language codes. See "Translations" in Meridian Editor to learn exactly what languages are supported for this location.

token: string

Meridian API token. Make sure to create a READ ONLY token for security. Otherwise anyone using your page could take your token and modify all of your Meridian data.

Accessors

  • get axios(): AxiosInstance
  • Returns AxiosInstance

    Deprecated

    Use the fetch methods instead

Methods

  • [async] Returns the data of specified floor

    Parameters

    • locationID: string
    • floorID: string

    Returns Promise<FloorData>

  • [async] Returns an array of all floors at the specified location

    Parameters

    • locationID: string

    Returns Promise<LocationData[]>

  • [async] Returns an array of all placemarks on the specified location and floor

    Parameters

    • locationID: string
    • floorID: string

    Returns Promise<FloorData[]>

  • [async] Returns an array of all placemarks at the specified location

    Parameters

    • locationID: string

    Returns Promise<FloorData[]>

  • [async] Returns an object URL for the given SVG URL

    This object URL can be used as the src for an img tag.

    This method fetches the SVG URL using your API token, since img tags can't pass API tokens. The SVG URL can be obtained from the svg_url property on a floor. When you're finished using this URL, you should call URL.revokeObjectURL with the URL, so the browser can save memory by releasing the data.

    Parameters

    • svgURL: string

    Returns Promise<string>

  • [async] Returns dynamicly updated data for a specific tag.

    Parameters

    • mac: string

    Returns Promise<TagData>

  • [async] Returns an array of all tags on the specified location and floor

    Parameters

    • locationID: string
    • floorID: string

    Returns Promise<TagData[]>

  • [async] Returns an array of all tags at the specified location

    Parameters

    • locationID: string

    Returns Promise<TagData[]>

  • [async] Returns an Object with routes to the destination (endPlacemarkID)

    Parameters

    Returns Promise<Record<string, any>>

  • Opens a tag stream for a given location and floor. onInitialTags is called with the full list of tags for that floor.

    Note: When resourceType is set to "ZONE", onTagUpdate is called when a tag/resource exits or enters the zone. Otherwise, onTagUpdate is called every time a tag/resource is updated.

    Parameters

    Returns Stream

    Example

    const api = new MeridianSDK.API({
    token: token,
    environment: "production"
    });

    const stream = api.openStream({
    locationID: locationID,
    floorID: floorID,
    onInitialTags: (tags) => {
    console.log("tags", tags);
    },
    onTagUpdate: (tag) => {
    console.log("update", tag);
    }
    });

    // Tag Zones

    const stream = api.openStream({
    locationID: locationID,
    floorID: floorID,
    resourceIDs: ["1218"],
    resourceType: "ZONE",
    onTagUpdate: (tag) => {
    console.log("update", tag);
    }
    });

    // call `stream.close()` when switching pages to avoid leaving the stream
    // open and wasting bandwidth in the background

Generated using TypeDoc