citrit / iMapInvasiveSpeciesApp

iMap invasive species app for field entry. iMapInvasives provides an on-line, GIS-based data management system to assist citizen scientists and natural resource managers working to protect natural resources from the threat of invasive species.
3 stars 0 forks source link

Investigate location behavior when editing a record #60

Closed jlmarino closed 6 years ago

jlmarino commented 6 years ago

Some users have reported that when editing a record that is in the upload queue, the location of the record updates to their current location instead of remaining static at the location where the user was when the record was saved. Perhaps this is by design, but this can be a problem when editing a record far away from the original location.

citrit commented 6 years ago

This will only happen if the Edit Observation has the toggle GPS checkbox on when editing observations. Checking and unchecking this will fire off iMapApp.iMapMap.startGPSTimer and iMapApp.iMapMap.stopGPSTimer, I have seen in the past that the stop does not completely stop the timer. I thought I fixed this but some testing may be in order. Check to make sure when the edit obervation is picked that the toggle checkbox is off and the timer is set to off.

I know I sprinkled the stop GPS timer call around but maybe missed a spot.

jlmarino commented 6 years ago

Great, thanks Tom – will do.

jlmarino commented 6 years ago

After a bit of tinkering I believe that I have determined the issue.

When the startGPSTimer function ran, it invoked navigator.geolocation.watchPosition and assigned its instance to the iMapApp.iMapMap.timerVar variable. However, if the watchPoisition function returned error code 3, a new instance of navigator.geolocation.watchPosition was invoked, updating the timerVar to a new value. Then, if the stopGPSTimer function was invoked, it was only clearing the new instance of the watchposition (referenced by the new timerVar value) – the original instance was still running in the background.

To correct the problem, I replaced the handling of watchPosition error code 3 to trigger the stopGPSTimer function followed by startGPSTimer.