[Pedometer] Function to Calculate Distance Covered By User

[Pedometer] Function to Calculate Distance Covered By User

  
Forge Component
(1)
Published on 2017-11-16 by Atul Patel
1 vote
Published on 2017-11-16 by Atul Patel

Hello,

I've been trying to display the distance being covered by the user using pedometer plugin..But onClick Start the Distance variable shows Undefined. Kindly help to rectify the issue. I'm Posting Js Code Below.


Code :

var successHandler = function (pedometerData) {
    // pedometerData.startDate; -> ms since 1970
    // pedometerData.endDate; -> ms since 1970
    document.getElementById($parameters.Steps_InputId).innerHTML = pedometerData.numberOfSteps;
    document.getElementById($parameters.Distance_InputId).innerHTML = pedometerData.distance;
    $resolve();
    // pedometerData.floorsAscended;
    // pedometerData.floorsDescended;
   

};

var onError = function() {
    alert('error');
    $resolve();

}

pedometer.startPedometerUpdates(successHandler, onError);