Is it possible to make an HTML5 Trip Meter that tracks distance traveled?
-
I'm trying to develop a webapp that users can run on their mobile phone to track the distance they've traveled. Think of it as something like RunKeeper, but in webapp form. The following article describes an easy way to create a Trip Meter with HTML5 and and the Geolocation API. http://www.html5rocks.com/en/tutorials/geolocation/trip_meter/ However, this just seems to calculate the distance between point A and point B. I suppose I could use something like JavaScript's setTimeout to track the distance traveled every 5 seconds, then calculate the total at the end. However, when the webapp is running in the background (or the phone is locked), this JS won't be executed. Is there any sort of solution to this problem?
-
Answer:
You don't need to use setTimeout, the http://dev.w3.org/geo/api/spec-source.html#watch-position will fire the callback function every time the location is updated. However, you are correct that the JavaScript will only run when the web app is not in the background and the phone is not locked. You may be able to write an HTML5 app then convert it to native with something like http://docs.phonegap.com/en/1.0.0/phonegap_geolocation_geolocation.md.html.
Matt Raible at Stack Overflow Visit the source
Related Q & A:
- Is it possible to make CHKDSK print the files that are affected?Best solution by Super User
- is it possible to make comment appear faster in excel?Best solution by Super User
- Is it possible to make bend with google maps polyline?Best solution by stackoverflow.com
- Is it possible to make life-size mannequins using paper mache?Best solution by Yahoo! Answers
- An express train leaves one station at 9:02 and arrives at the next station at 9:08. If the distance traveled?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.