A more accurate geofencing
This commit is contained in:
@@ -407,16 +407,20 @@ class _ScheduleTile extends ConsumerWidget {
|
||||
),
|
||||
);
|
||||
|
||||
final isInside = geofence.hasPolygon
|
||||
? geofence.containsPolygon(position.latitude, position.longitude)
|
||||
: geofence.hasCircle &&
|
||||
Geolocator.distanceBetween(
|
||||
position.latitude,
|
||||
position.longitude,
|
||||
geofence.lat!,
|
||||
geofence.lng!,
|
||||
) <=
|
||||
geofence.radiusMeters!;
|
||||
if (!geofence.hasPolygon) {
|
||||
if (!context.mounted) return;
|
||||
await _showAlert(
|
||||
context,
|
||||
title: 'Geofence missing',
|
||||
message: 'Geofence polygon is not configured.',
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
final isInside = geofence.containsPolygon(
|
||||
position.latitude,
|
||||
position.longitude,
|
||||
);
|
||||
|
||||
if (!isInside) {
|
||||
if (!context.mounted) return;
|
||||
|
||||
Reference in New Issue
Block a user