0

I have been using esri's LocateButton on a map for almost a year now and it works well. I'm now trying to enable the Tracking option to create a moving map for staff and I can't seem to get it working properly. This example works for me and is what i'm looking to achieve. Essentially I have the option enabled and it does continue to centre the map as expected. The problem comes when I try to turn the function off. With the clearOnTrackStop set to true the dot is removed and if I check the properties I can see that Tracking is set to off but my GPS dot reappears as soon as a new location is found.

Why? It's almost as if there's another function running somewhere that triggers the locate to renable but I can't find it.

I have stripped down version of my map running here if you'd care to look at my code.

http://maps.ducks.ca/archive/PMV/

  • Just to add more confusion I asked a co-worker to test this and on his machine it works as expect in FireFox, chrome and IE. On my laptop it works in Chrome and IE but not FireFox? – Andrew Pratt Feb 10 '15 at 22:14
1

One way to solve this would be to avoid using Esri's Locate Button, and looking into the Geolocation API (I am sure Esri's functionality is built using that one anyways). It is very easy to use and it gives you direct control over the stopping part. Basically, anytime you start tracking, your geolocation call is given an ID. You can then use that same ID to end tracking. I would assume that in your app that exact part is what is failing.

Should you go that route then anytime you acquire a new position, you would use its coordinates to create a new point vector that would then be displayed on the map. Or if you want to show the entire route, you would have to push the coordinates into an array, which you then loop through and use as vertices for your line.

Maybe there is a way to fetch the ID that the ArcGIS JS API is using; I can look into it tomorrow!

  • I believe the ID is there but isn't being populated as it was blank in the Console log. I could look into setting the ID and then calling the stop but it seems to work properly so long as you don't have the automatic location setting enabled. – Andrew Pratt Feb 11 '15 at 14:55
0

It seems that if I enable the Always Allow setting for location services in FireFox it behaves as outlined above. If I set FireFox to always ask it works properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.