cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about PTC Community Badges. Engage with PTC and see how many you can earn! X

Javascript Example: Dynamically control Tracking Indicator

No ratings

You can control the Tracking Indicator that is used to mark the ThingMark position. The Tracking Indicator is a green hexagon, in the screenshot below the red arrow points to it.

TWXViewScreen.png

You can control the display of this tracking indicator via the Display Tracking Indicator property of the ThingMark widget:

TWXStudio_ControlTrackingIndicator.png

But you can also get fancier. Here is an exmaple that shows the tracking indicator for 3 seconds when the tracking has started and then hides it automatically. To achieve such a behavior you'll have to use a bit of Javascript. We'll first create a function hideIn3Sec() in the javascript section of our view and then add it to the javascript handler of the Tracking Acquired event of the ThingMark widget.

Step 1:

TWXStudio_ControlTrackingIndicator_JS.png

Here is the code for copy/paste convenience:

$scope.hideIn3Sec=function(){

  // The $timeout function has two arguments: the function to execute (defined inline here)

  // and the time in msec after which the function is invoked.

  $timeout( function hide(){

    // you may have to change 'thingMark-1' by the id of the ThingMark in your own experience

    $scope.app.view['Home'].wdg['thingMark-1']['trackingIndicator']=false;

  },

  3000);

}

Step 2:

TWXStudio_ControlTrackingIndicator_JSHandler.png

That's it. Have fun!

Comments

Hi Moritz von Hasselbach,

Thank you for the post. I was wondering if it is possible to send some alert to the composer when tracking is successful. If in an experience someone tracks a thingmark, then is it possible to update some value of a thing...

Thanx & regards,

Dipika Sengupta

Yeah that is possible. For example, in Moritz's project, on tracking acquired there is a function (hideIn3Sec), within that function we can execute a thingworx service that inturn updates the property of a thing. FYI, $scope.app.mdl['<thingname>'].svc['<servicename>']; can be used to execute the thingworx service.

Thanks giri... It works!!

Version history
Last update:
‎Dec 30, 2016 10:09 AM
Updated by:
Labels (2)