precision medium - more fast geolocation
This commit is contained in:
@@ -141,19 +141,33 @@ class _MapboxPagesState extends State<MapboxPages> with ShowErrorDialog {
|
||||
"Location permissions are permanently denied. Enable them in settings.");
|
||||
return;
|
||||
}
|
||||
LocationSettings locationSettings = LocationSettings(
|
||||
accuracy: LocationAccuracy.high,
|
||||
distanceFilter:
|
||||
10, // Optional: Minimum distance (in meters) to trigger location update
|
||||
);
|
||||
|
||||
Position position = await Geolocator.getCurrentPosition(
|
||||
locationSettings: locationSettings,
|
||||
);
|
||||
setState(() {
|
||||
userPosition = LatLng(position.latitude, position.longitude);
|
||||
isUserPositionInitialized = true;
|
||||
});
|
||||
const LocationSettings locationSettings = LocationSettings(
|
||||
accuracy: LocationAccuracy.medium, timeLimit: Duration(seconds: 5));
|
||||
Position? position;
|
||||
try {
|
||||
position = await Geolocator.getCurrentPosition(
|
||||
locationSettings: locationSettings);
|
||||
} on LocationServiceDisabledException {
|
||||
// Handle location services disabled
|
||||
print('Location services are disabled.');
|
||||
position = await Geolocator.getLastKnownPosition();
|
||||
if (position == null) {
|
||||
print('No last known position available.');
|
||||
}
|
||||
} catch (e) {
|
||||
// Handle other errors
|
||||
print('Failed to get location: $e');
|
||||
position = await Geolocator.getLastKnownPosition();
|
||||
if (position == null) {
|
||||
print('No last known position available.');
|
||||
}
|
||||
}
|
||||
if (position != null) {
|
||||
setState(() {
|
||||
userPosition = LatLng(position!.latitude, position!.longitude);
|
||||
isUserPositionInitialized = true;
|
||||
});
|
||||
}
|
||||
_initToken();
|
||||
_getEventInfo();
|
||||
} catch (e) {
|
||||
|
Reference in New Issue
Block a user