问题
I could really use some help improving the accuracy of the Geofencing feature. If you look at the following screenshots you can see my location and the location of circle and marker which share the same latLng coordiantes and radius as my geofence.
Link to the image
If I run the following lines within the app.js file:
const taskName = "front_door";
const latLng = { latitude: -37.820711, longitude: 144.994264 };
const radius = 5;
Permissions.askAsync(Permissions.LOCATION);
Location.startGeofencingAsync(taskName, [
{
...latLng,
radius
}
]);
TaskManager.defineTask(taskName, task => {
if (task.data.eventType === Location.GeofencingEventType.Enter) {
console.log("entered");
}
console.log(task.data.region.state);
return;
});
Which is returning entered and 1 (explanation).
Given my current location being outside of the geofence I would expect entered to fire only once I had inside of the geofence and task.data.region.state to equal 2 (explanation).
If I change:
const latLng = { latitude: -37.820711, longitude: 144.994264 };
To:
const latLng = { latitude: -37, longitude: 144 };
The geofence is far enough away that entered is never output and the task.data.region.state equals 2.
This leads me to believe that the issue is related to the accuracy set of Location however, I cannot find a way to increase the accuracy when using the startGeofencingAsync method.
If I was not using geofencing I would do something like this:
Location.startLocationUpdatesAsync(taskName, {
accuracy: Location.Accuracy.Highest
});
But I can't see how to access the options object when using Location.startGeofencingAsync(taskName, regions)
If you know how to achieve this please do let me know as I am pulling my hair out over it! Thanks in advance :)
来源:https://stackoverflow.com/questions/56630816/expo-increase-location-accuracy-with-geofence