Hi Joe,
please check here http://www.movable-type.co.uk/scripts..., should help
Hi Joe,
please check here http://www.movable-type.co.uk/scripts..., should help
Thanks! That does help a little. Math isn't my strong skill (and I thought programming would be fun, silly me).
That definitely makes more sense to me than the Wikipedia link that Katya gave me, but I'm not exactly sure how to incorporate it. I don't need all of those calculations, do I? Which do I need to include?
Also, will this calculate distance from point to point, or along a path? If I ride my bike in a loop, or along a curvy road, will it still calculate time/disance/speed accurately?
Hi Joe,
You would need to write an app that calls Geolocation Service every few seconds (for example 5-10).
In localeStorage you can store previous coordinates (latitude and longitude), the total distance travelled, total time.
After each call Geolocation you should:
1) calculate the distance from the previous location to the current
2) increase the total distance traveled by the distance obtained above
3) increase the total time counter
4) record the current position in the localeStorage instead of the previous coordinates.
Average speed in each moment is (total distance / total time).
Exactly! So how do I write the javascript to call geolocation at a 5 to 10 second interval? How do I record that into localStorage, and how do I write the javascript so those equations are included and calls upon previously stored data? I'm sorry I'm not much more help, but that is exactly what I would love to learn how to do.
Also, on a less important note, later, I would like to incorporate elevation per this interval as well.
Hi Joe - we will need some time to think how best to do it. We'll update soon.
You are all the best!
Would something along these lines be useful?
codefunction autoUpdate() {
navigator.geolocation.getCurrentPosition(function(position) {
var newPoint = new google.maps.LatLng(position.coords.latitude,
position.coords.longitude);
if (marker) {
// Marker already created - Move it
marker.setPosition(newPoint);
}
else {
// Marker does not exist - Create it
marker = new google.maps.Marker({
position: newPoint,
map: map
});
}
// Center the map on the new position
map.setCenter(newPoint);
});
// Call the autoUpdate() function every 5 seconds
setTimeout(autoUpdate, 5000);
}
autoUpdate();
/code
Hi Joe,
We're working on it. We'll test and update tomorrow.