Page 8 of 21
Journey Recording using GPS Tracking
Posted: Tue Jun 04, 2013 4:36 pm
by Kateryna Grynko
Hi Joe,
There is an error on geolocation1 service success event on page "recordride". Replace it with the following code:
codeAppery("errorLabel").hide();
invokeTimes++;
Appery("dataLabel").html('Latitude: ' + data.coords.latitude + '<br>' +
'Longitude: ' + data.coords.longitude + '<br>' +
'Altitude: ' + data.coords.altitude + '<br>' +
'Accuracy: ' + data.coords.accuracy + '<br>' +
'Timestamp: ' + data.timestamp + '<br>');
if(!paused) {
if(oldTime != 0) {
var dist = findDistance(oldLat, oldLng, data.coords.latitude, data.coords.longitude);
totalDist += dist;
totalTime += data.timestamp - oldTime;
}
oldTime = data.timestamp;
oldLat = data.coords.latitude;
oldLng = data.coords.longitude;
Appery("totalDistLabel").text("Distance: " + round(totalDist) + ' km');
Appery("totalTimeLabel").text("Time: " + mSecToTime(totalTime));
if (totalTime>0) {
Appery("avrSpeedLabel").text("Average speed: " + round(totalDist/(totalTime/(1000*3600))) + " km/h");
} else {
Appery("avrSpeedLabel").text("Average speed: 0 km/h");
}
Code: Select all
var coordsArray = [];
try {
coordsArray = JSON.parse(localStorage.getItem("coordsArray"));
if ({}.toString.call(coordsArray) !== "[object Array]") {
coordsArray = [];
}
}catch ( e ){
coordsArray = [];
}
var speed = totalTime!=0 ? round(totalDist/(totalTime/(1000*3600))) : 0;
var timeStamp = new Date(data.timestamp).getTime();
coordsArray.push({'time': timeStamp, 'lat': data.coords.latitude, 'lng': data.coords.longitude, 'speed': speed});
localStorage.setItem("coordsArray", JSON.stringify(coordsArray));
}
updateMarker(data.coords.latitude, data.coords.longitude);/code
Journey Recording using GPS Tracking
Posted: Tue Jun 04, 2013 5:50 pm
by Joe Paisley
Looks great! Except how do I change the scale on the axis? The y-axis reads in tens of thousands m/h and the journey time is in thousands of seconds. Can that be in increments of 1 mph and journey time in minutes?
Also, what's the best way to share this data socially?
It's nearly done!
Journey Recording using GPS Tracking
Posted: Tue Jun 04, 2013 7:27 pm
by Joe Paisley
And how can I make the "initialize" button automatically prompt the device to toggle on the cell phone's GPS tracking ability so that the ride may be accurately recorded?
Journey Recording using GPS Tracking
Posted: Tue Jun 04, 2013 7:29 pm
by Kateryna Grynko
Journey Recording using GPS Tracking
Posted: Wed Jun 05, 2013 5:23 pm
by Kateryna Grynko
Hi Joe,
1) You can change output data as you need. For example to change the time scale from seconds to minutes on the "plot" Page show event change 2 lines in JS code.
Replace:codepoints.push([(coordsArray.time - startTime) / 1000, coordsArray.speed]);/codewith the following:codepoints.push([(coordsArray.time - startTime) / 1000 / 60, coordsArray.speed]);/code
and:codelabel:'Journey time (sec)',/codewith the line below:codelabel:'Journey time (minutes)',/code
2) As for "best way to share this data socially" - you have to decide what data you want to share and through which services. Look our tutorials - there are many useful things.
3) As for "make the "initialize"button automatically prompt the device to toggle on the cell phone's GPS tracking ability so that the ride may be accurately recorded" - not sure we understand the question. Could you clarify?
Journey Recording using GPS Tracking
Posted: Wed Jun 05, 2013 8:33 pm
by Joe Paisley
Thanks Katya! I'll also look into the tutorials.
As for number 3, what I mean is that I must manually drag down the top bar on my android, click to enable GPS, and then press "initialize." Is there no way that pressing "initialize" will check the device's current GPS state, and prompt the user to enable GPS if it is not already enabled?
I'm very excited to almost be finished!
Journey Recording using GPS Tracking
Posted: Wed Jun 05, 2013 8:48 pm
by Kateryna Grynko
Journey Recording using GPS Tracking
Posted: Thu Jun 06, 2013 1:49 pm
by Joe Paisley
Do you have a link to the social sharing tutorial? For instance if I simply wanted to share the panel data on the "plot" page, Can I simply edit the html in the panel to include the code for a "like" button and a "tweet" button?
Journey Recording using GPS Tracking
Posted: Thu Jun 06, 2013 4:24 pm
by Kateryna Grynko
Journey Recording using GPS Tracking
Posted: Fri Jun 07, 2013 12:18 pm
by Joe Paisley
So you're saying that you can't share the graph via facebook/twitter api, and cordova only allows you to like a single url or tweet a single url once you create the html buttons in the panel component?