flyToCurrentLocation method
void
flyToCurrentLocation()
Implementation
void flyToCurrentLocation() async {
if (_currentPosition != null && _cameraController != null) {
if (DebugSettings.showCameraLogs) {
debugPrint('[CAMERA] Flying to current location: ${_currentPosition!.lat}, ${_currentPosition!.lng}');
}
// Ensure we can move to the current location directly
try {
await _cameraController!.stopCameraAnimation();
} catch (e) {
debugPrint('[DEBUG] Error stopping camera animation: $e');
}
// In navigation mode, respect the current orientation setting
if (isNavigating && _isOverTheShoulderMode) {
await _cameraController!.flyToLocationWithBearing(
_currentPosition!,
bearing: _currentBearing,
zoom: _otsZoom,
pitch: _otsPitch,
duration: 200, // Shorter duration for more responsive feeling
);
} else {
await _cameraController!.flyToLocation(
_currentPosition!,
zoom: 15.0,
duration: 200, // Shorter duration for more responsive feeling
);
}
// Update camera position after movement completes
await _updateCameraPosition();
} else {
debugPrint('[DEBUG] Current position is null, initializing location');
await _initializeLocation();
}
}