Render user placeline on map

Prerequisite

Follow setup tutorial to initialize mapClass, client and usersClient.

Fetch user placeline

var token = "sk_55fc65eb64c0b10300c54ff79ea3f6ef22981793";
var userId = "44e37638-0bd9-428a-9d74-556092ac712a";
var client = new htClient.HtClient(token);
var usersClient = client.users;
usersClient.placeline.setId(userId)
var placeline$ = usersClient.placeline.data$; //observable emitting latest data every 10 secs.
//Following step is optional. Use this to check with placeline userData is being emitted correctly.
placeline$.subscribe(function(userData) {
  //userData 
})
import {HtClient} from "ht-client";

...
var client = new HtClient(token);
...
  1. usersClient exposes placeline property which contains bunch of functions related to fetching placeline data. Use setId(id: string) function to set id of user for which placeline is to be rendered.
  2. placeline property exposes data$. This is an observable which emits the latest value of placeline every 10 seconds.
  3. If the client.mapClass has been set to mapClass, the users markers will to automatically be rendered on the map
  4. (optional) Subscribe to the data$ to get updated placeline data.

results matching ""

    No results matching ""