transistorsoft / react-native-background-geolocation

Sophisticated, battery-conscious background-geolocation with motion-detection
http://shop.transistorsoft.com/pages/react-native-background-geolocation
MIT License
2.55k stars 425 forks source link

Feature request: onGeofence event to return default long and lat #2022

Closed sirusbaladi closed 2 weeks ago

sirusbaladi commented 2 weeks ago

Hi,

The onGeofence event right now returns within the location field the longitude and latitude of where the user is within the geofence. It would be nice if it also returned the longitude and latitude of the geofence center itself.

Having this would make the object more complete and would help in making the code cleaner. I have some use-cases where I exactly need this.

Thanks.

christocracy commented 2 weeks ago

See api docs .getGeofence(identifier) to fetch the desired geofence info.

sirusbaladi commented 2 weeks ago

See api docs .getGeofence(identifier) to fetch the desired geofence info.

it makes a lot of sense to add it in the object returned by onGeofence. For now, I'm adding it in the extra field of the object.

christocracy commented 2 weeks ago

It is not inefficient to simply use .getGeofence.

I don’t plan on providing the geofence to the event.

christocracy commented 2 weeks ago

You’re always free to add any arbitrary meta data to the geofence event via Geofence.extras, including the geofence lat/lng. It’s what I do in the demo app.

sirusbaladi commented 2 weeks ago

You’re always free to add any arbitrary meta data to the geofence event via Geofence.extras, including the geofence lat/lng. It’s what I do in the demo app.

For now, I'm adding it in the extra field of the object.

Yes that's what I've ended up doing. I think it cleaner than calling getGeofence again. Still think that should come within the geofence field in event but it works. - > event : {..., geofence {object}}

christocracy commented 2 weeks ago

Still think that should come within the geofence field

It doesn’t matter. There are multiple ways to get the desired information required by a minority of users.