Reputation: 1923
I'm writing an app that keeps track of your position while running. The issue is that I can only start/stop the tracking only once. I have to kill the app to restore functionality.
$("#startRunning").live('click', function ()
{
watch_id = navigator.geolocation.watchPosition( function (position)
{
tracking_data.push(position);
element.innerHTML = 'Aantal metingen: ' + aantalMeetingen;
},
function (error)
{
console.log(error);
},
{
enableHighAccuracy: true, maximumAge: 5000, timeout: 7000,
});
track_id = loopNummer;
});
$("#stopRunning").live('click', function ()
{
window.localStorage.setItem(track_id, JSON.stringify(tracking_data));
alert(watch_id);
//Reset the values and clearWatch
navigator.geolocation.clearWatch(watch_id);
aantalMeetingen = 0;
watch_id = null;
tracking_data = null;
showResult();
});
I have no I idea how to fix this issue, because my code (should) be working normally.
Upvotes: 0
Views: 133
Reputation: 19987
Just a guess, but instead of
tracking_data = null;
try
tracking_data = [];
otherwise tracking_data.push(position);
is bound to cause a null pointer error.
Let me know :)
Upvotes: 2