ffwdme / ffwdme.js

[DEPRECATED!] 🛑 A JavaScript toolkit that aims to bring interactive GPS driving directions to the mobile browser
http://ffwdmejs.org
MIT License
152 stars 36 forks source link

About geoposition:update... #8

Closed Neoespecialistas closed 8 years ago

Neoespecialistas commented 9 years ago

Hi overthere, My device is updating the geoposition a lot of times per second. I can see that each new geoposition is enquewed, i can't skip some of them... Are there any way to set the interval to take the gps values ? where ? I'm using the simple recorder sample as base. Thanks a bunch in advance, Greetings from Buenos Aires, Argentina David

fabrik42 commented 9 years ago

Hi,

could you describe the problem more in detail? Usually - it is normal that you get multiple geoposition updates per second. This is also a wanted feature, because people want to update their UI as often as possible.

Do you face problems with the ffwdme framework itself (do you want to process the events less often in general) or is it a problem with your own handling of the events and it would be sufficient if you would implement some kind of throtteling there?

Best, Christian

Neoespecialistas commented 9 years ago

Hi Christian, Thanks for your fast answer.

Mobile app captures gps data and sends it to a remote program (pc based) that retrieves the geolocation into a map in screen.

if the user of the mobile goes slow, or is stopped, i receive dozens of coordinates very very closed, or in the same point...

In fact, the map has too pins of the same user in the same place.

I think if gps captures could be fired between 5 - 10 seconds, the result ( in my case ) could be better.

Any ideas ?

Thanks again, David

fabrik42 commented 9 years ago

In this case you could throttle the events that are sent to your server.

I can think of two solutions:

1) Based on time: Look up "function throttle" or "function debounce" e.g. https://remysharp.com/2010/07/21/throttling-function-calls and https://css-tricks.com/the-difference-between-throttling-and-debouncing/

2) Based on the geoposition (only update the position on the server if it changed more than x meters). The ffwdme.utils.Geo.distance can help you there: https://github.com/ffwdme/ffwdme.js/blob/master/src/core/utils/geo.js#L16

I hope this helps. Let me know, if you have further questions.

Best, Christian

Neoespecialistas commented 8 years ago

Thanks again !

David