[HTML / jQuery]Any way to force a GeoLocation update?

Associate
Joined
18 Nov 2008
Posts
2,430
Location
Liverpool
Hi all, I'm building a web app that will track things like running, cycling and walking. To do so I'm using the the GeoLocation function watchPosition. This works fine but in order to regularly test it I need it to give me a few results without me having to physically go out and simulate a change in position.

What I mean is, the function calls another function, lets call it newPosition, when I move, but as I'm indoors, I would have to go outside to simulate movement, which isn't ideal while I'm building.

Is there any function to simulate a change in location? All I can think of currently, is to set a JS timer for every x seconds, and have it run newPosition, manually inserting the resulting object of getPosition, which will work fine (I hope), but makes it feel like the final version will be slightly different.

Hope this makes sense :p
 
Well, following my original idea I've gotten a workaround going based on the whole timer thing. Not ideal but it'll do till I can come up with a real solution.

Code:
setInterval(function(){navigator.geolocation.getCurrentPosition(newPosition)}, 1000);
 
Back
Top Bottom