react-native-background-geolocation icon indicating copy to clipboard operation
react-native-background-geolocation copied to clipboard

Provide extra field per location

Open darksnow opened this issue 2 years ago • 5 comments

Not a bug report so the template didn't seem relevant, I hope that's OK.

I was wondering if there's a way to set the extra field for every location. The location event seems to get the location data but a there's no location returned I guess I can't change the location in there.

My use case is that I need to do a lookup using the latitude and longitude and they include the ID of the nearest linestring in the API call to the server, sending the location. If I can do that and include it in the location data structure then it would be stored locally when offline and sent to the server when online. The reason for this is to find which road I'm on and tag each API call with that road. How I actually find which road I'm on, locally and offline, if another problem and out of the scope of this library.

darksnow avatar Oct 16 '23 21:10 darksnow

was wondering if there's a way to set the extra field for every location

No. It's impossible.

Anyway, reverse geolocation is a task best done on your server, since it requires an extra http request and http requests consume energy.

christocracy avatar Oct 16 '23 21:10 christocracy

Thanks for the quick reply.

My use case is for an offline first app so I guess I'm looking for a workaround or another library to do this. Is there a way to intercept the HTTP calls perhaps? Or modify the internal SQLite DB before locations are sent?

darksnow avatar Oct 16 '23 22:10 darksnow

Or modify the internal SQLite DB before locations are sent

Yes, but not with JavaScript. It can only be done by implementing an undocumented method in pure Obj-c (iOS)/ Java (Android) then implementing your reverse-geocoding using pure native code.

christocracy avatar Oct 16 '23 22:10 christocracy

Thanks for the insights Chris, your library is amazing so I very much want to use it for my app. I guess I have a difficult problem to solve :)

If I can get a number from an async JS call, given the latitude and longitude, not an API request or anything like that, can you think of a way I can add that to my API call when the library goes back online?

Perhaps I need to remove the URL so requests don't go at all, then control offline handling myself and pre-process each location when the API requests are made. Seems complicated but if there's no way to influence what's going on interally then perhaps that's what I need to do.

Anyway, thanks again for the responses. It's late here so I'll sleep on it.

darksnow avatar Oct 16 '23 22:10 darksnow

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] avatar May 03 '24 01:05 github-actions[bot]

This issue was closed because it has been inactive for 14 days since being marked as stale.

github-actions[bot] avatar May 18 '24 01:05 github-actions[bot]