Hello,
I used the code exactly like in your example:
https://dev.fitbit.com/guides/geolocation/
with the method "watchposition()".
First of all I expected to see the sign for GPS like in the Running-Training in the left upper corner - but nothing appeared there.
Then after a walk outside I tried to get some geolocation data to the fitbit app.-- but also nothing was recorded.
How can I store the gps-data of a run with the ionic and transfer it to the fitbit app similair to the trainings? -- Have I to do this all by my own programming or do you have some available functions or methods available for this?
Thanks
Capitano
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
@Capitano I encouter the same struggles as you. Do you have a working geolocation example? I want to use the GPS of the Watch, but haven't managed to do so. getting the current position works but watching position not. According to the documentation the only difference would be to change geolocation.getCurrentPosition to geolocation.watchPosition
@JonFitbit . In general I would expact that a copy paste of example works out of the box.
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
You can use this until the watchPosition() method is working.
import { geolocation } from "geolocation";
function locationSuccess(**ahem**) {
console.log("success: " + JSON.stringify(**ahem**));
}
function locationError(err) {
console.log("error: " + err.message);
};
function locationUpdate() {
geolocation.getCurrentPosition(locationSuccess, locationError);
}
setInterval(locationUpdate, 1000);
Best Answer@JonFitbit I tried this one as well. Simply changed "**ahem**" to "data" as it would not built.
Lasted 4 seconds, and it crashed/closed. Please see log down here.
[5:14:40 PM]error: Position Unavailableapp/index.js:11
[5:14:41 PM]success: {"coords":{"accuracy":40.57,"latitude":40.726347,"longitude":-73.968422,"altitude":7.25,"altitudeAccuracy":null,"heading":89.43,"speed":0.15433319999999998},"timestamp":1508966080000}app/index.js:8
[5:14:43 PM]success: {"coords":{"accuracy":38.65,"latitude":40.726345,"longitude":-73.968457,"altitude":7.27,"altitudeAccuracy":null,"heading":17.7,"speed":0.22121091999999998},"timestamp":1508966081000}app/index.js:8
[5:14:44 PM]success: {"coords":{"accuracy":36.35,"latitude":40.726332,"longitude":-73.968489,"altitude":7.27,"altitudeAccuracy":null,"heading":338.25,"speed":0.18519984},"timestamp":1508966083000}app/index.js:8
[5:14:45 PM]success: {"coords":{"accuracy":35.3,"latitude":40.726334,"longitude":-73.968506,"altitude":7.27,"altitudeAccuracy":null,"heading":327.33,"speed":0.24693312},"timestamp":1508966084000}app/index.js:8
Best Answer
Fitbit Developers oversee the SDK and API forums. We're here to answer questions about Fitbit developer tools, assist with projects, and make sure your voice is heard by the development team.
Sorry, it looks like my code sample was caught by the profanity filter 🙂
It's definitely working here, so unfortunately you may need to wait for the next firmware update. It's coming soon.
Best AnswerHahaha! Love it.
i tested today the watch gps using regular activities, and no problems. Works without crashing. I am not really sure why it is not working when coding geolocation on the studio. I’ll wait for the next firmware and hopefully it will solve it. If anybody managed to have geolocation working so far, please let me know.
Best AnswerIf the interval of the code example is set to 3 seconds, then it will work. See below my working code example.
import { geolocation } from "geolocation";
import document from "document";
var latlonData = document.getElementById("latlon-data");
var speedheadingData = document.getElementById("speedheading-data");
var GPSoptions = {
enableHighAccuracy: true,
maximumAge: Infinity
};
var counter = 0;
setInterval(getPosition, 3000);
function getPosition() {
geolocation.getCurrentPosition(locationSuccess, locationError);
}
var position = {coords:{
latitude:50.123456789,
longitude:4.123456,
heading: 69.9999,
speed:9.56789
},
timestamp:12345567788
};
latlonData.innerText = "Retrieving GPS...";
function locationSuccess(**ahem**) {
counter++;
position = **ahem**;
var lat = position.coords.latitude;
var lon = position.coords.longitude;
var heading = position.coords.heading;
var speed = position.coords.speed;
latlonData.innerText = lat.toFixed(4) + " "+ lon.toFixed(4);
speedheadingData.innerText = speed.toFixed(1)+"m/s "+Math.round(heading)+"°";
}
function locationError(error) {
counter++;
latlonData.innerText = "GPS not found "+counter;
console.log("GPS not found");
console.log(`Error: ${error.code}\nMessage: ${error.message}`);
}
Thanks for the code. I changed mine and it does not crash at 3 sec. I tested 2 seconds and it still crashes.
3 seconds is not accurate enough for some activities, unfortunately. Garmins they all sample at 1 second no issues.
Is this a limitation of the Ionic, or just some growing pain in the firmware?
Best AnswerHey @Pietero
Changed my code to reflect yours.
It is way more stable. But it still crashes. I tried at 1 second, and it lasts almost a minute before crashing. At 3 seconds it crashes about 2 minutes in.
Do you experience the same issue, or is yours perfectly stable over time?
I am not an expert, but it looks like the Ionic reaches the limit of some data buffer. Am I supposed to dump the old data after each successful new geolocation read?
Best AnswerHello,
@Pieterocould also try your code and experienced the same effect. App is running for a couple of seconds (with intervall = 1000ms) and then stopps.
Capitano
Best AnswerHeyy can you tell me the geolocation code in python??
Best Answer