Geolocation data issues

URL of experiment: https://pavlovia.org/nedergaard_au/running_pilot_151119

Description of the problem:
I’m building a novel experiment where participants have to alternate between physically running and solving cognitive tasks. They’ll be running for a minute at a time and one of the dependent variables is how far they manage to run during that minute every trial. In order to calculate that, I need geolocation data which I have managed to get using code like this:

var gps = navigator.geolocation.getCurrentPosition(
      function (position) {
         window.start_lat = position.coords.latitude;
         window.start_long = position.coords.longitude;
         window.start_acc = position.coords.accuracy;
    });

The problem is that using the “window” kind of variables is the only way I can get the data but it appears that it just saves the location once and doesn’t update it again (which makes it quite difficult to calculate how far people run). I would very much appreciate some help with this problem, i.e. how can I save geolocation in a different way?

Thank you in advance,
Johanne