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")&#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


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

We'll update.


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&#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?


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

We'll take a look.


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?