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 = htClient.initClient(token);
var mapClass = new htMaps.HtMapClass('google');

var usersClient = htClient.usersClientFactory();
usersClient.placeline.setId(userId)
var placeline$ = usersClient.placeline.data$; //observable emitting latest data every 10 secs.

mapClass.placeline.setCompoundData$(usersClient.placeline.data$)

//Following step is optional. Use this to check with placeline userData is being emitted correctly.
placeline$.subscribe(function(userData) {
  //userData 
})
import {initClient, usersClientFactory} from "ht-client";

...
var client = initClient(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. Pass placeline.data$ observable to map via mapClass.placeline.setData$(...) to render the placeline on the map.
  4. (optional) Subscribe to the data$ to get updated placeline data.

results matching ""

    No results matching ""