Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Journey Recording using GPS Tracking

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")&#46;html('Latitude: ' + data&#46;coords&#46;latitude + '<br>' +
'Longitude: ' + data&#46;coords&#46;longitude + '<br>' +
'Altitude: ' + data&#46;coords&#46;altitude + '<br>' +
'Accuracy: ' + data&#46;coords&#46;accuracy + '<br>' +
'Timestamp: ' + data&#46;timestamp + '<br>');
if(!paused) {
if(oldTime != 0) {
var dist = findDistance(oldLat, oldLng, data&#46;coords&#46;latitude, data&#46;coords&#46;longitude);
totalDist += dist;
totalTime += data&#46;timestamp - oldTime;
}
oldTime = data&#46;timestamp;
oldLat = data&#46;coords&#46;latitude;
oldLng = data&#46;coords&#46;longitude;
Appery("totalDistLabel")&#46;text("Distance: " + round(totalDist) + ' km');
Appery("totalTimeLabel")&#46;text("Time: " + mSecToTime(totalTime));
if (totalTime>0) {
Appery("avrSpeedLabel")&#46;text("Average speed: " + round(totalDist&#47;(totalTime&#47;(1000*3600))) + " km&#47;h");
} else {
Appery("avrSpeedLabel")&#46;text("Average speed: 0 km&#47;h");
}

Code: Select all

 var coordsArray = []; 
 try { 
     coordsArray = JSON&#46;parse(localStorage&#46;getItem("coordsArray")); 
     if ({}&#46;toString&#46;call(coordsArray) !== "[object Array]") { 
     coordsArray = []; 
 } 
 }catch ( e ){ 
     coordsArray = []; 
 } 
 var speed = totalTime!=0 ? round(totalDist&#47;(totalTime&#47;(1000*3600))) : 0; 
 var timeStamp = new Date(data&#46;timestamp)&#46;getTime(); 
 coordsArray&#46;push({'time': timeStamp, 'lat': data&#46;coords&#46;latitude, 'lng': data&#46;coords&#46;longitude, 'speed': speed}); 
 localStorage&#46;setItem("coordsArray", JSON&#46;stringify(coordsArray)); 

}
updateMarker(data&#46;coords&#46;latitude, data&#46;coords&#46;longitude);/code

Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Journey Recording using GPS Tracking

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!

Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Journey Recording using GPS Tracking

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?

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Journey Recording using GPS Tracking

We'll update.

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Journey Recording using GPS Tracking

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&#46;push([(coordsArray&#46;time - startTime) &#47; 1000, coordsArray&#46;speed]);/codewith the following:codepoints&#46;push([(coordsArray&#46;time - startTime) &#47; 1000 &#47; 60, coordsArray&#46;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?

Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Journey Recording using GPS Tracking

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!

Kateryna Grynko
Posts: 0
Joined: Thu Nov 15, 2012 9:13 am

Journey Recording using GPS Tracking

We'll take a look.

Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Journey Recording using GPS Tracking

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?

Joe Paisley
Posts: 0
Joined: Thu Mar 14, 2013 8:41 pm

Journey Recording using GPS Tracking

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?

Return to “Issues”