fix: autocomplete muestra Bogotá para usuario en Bucaramanga
- _mapCenter default cambiado de Bogotá a coordenadas más neutras - Cuando GPS no está disponible/denegado, _centerOnUserCity() geocodifica la ciudad del perfil del usuario y centra el mapa ahí - El autocomplete usa _mapCenter como bias → resultados ahora corresponden a la ciudad del usuario, no a Bogotá hardcodeado Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
54f9cc272e
commit
953196df1a
@@ -37,7 +37,7 @@ class _DashboardViewState extends State<DashboardView> {
|
||||
|
||||
// Map
|
||||
GoogleMapController? _mapController;
|
||||
LatLng _mapCenter = const LatLng(4.6097, -74.0817);
|
||||
LatLng _mapCenter = const LatLng(6.2442, -75.5812); // Medellín — centro geográfico de Colombia como fallback neutro
|
||||
bool _mapsReady = false;
|
||||
bool _mapsLoading = true;
|
||||
bool _geocoding = false;
|
||||
@@ -88,14 +88,14 @@ class _DashboardViewState extends State<DashboardView> {
|
||||
Future<void> _detectLocation() async {
|
||||
try {
|
||||
bool serviceEnabled = await Geolocator.isLocationServiceEnabled();
|
||||
if (!serviceEnabled) return;
|
||||
if (!serviceEnabled) { await _centerOnUserCity(); return; }
|
||||
|
||||
LocationPermission permission = await Geolocator.checkPermission();
|
||||
if (permission == LocationPermission.denied) {
|
||||
permission = await Geolocator.requestPermission();
|
||||
if (permission == LocationPermission.denied) return;
|
||||
if (permission == LocationPermission.denied) { await _centerOnUserCity(); return; }
|
||||
}
|
||||
if (permission == LocationPermission.deniedForever) return;
|
||||
if (permission == LocationPermission.deniedForever) { await _centerOnUserCity(); return; }
|
||||
|
||||
final pos = await Geolocator.getCurrentPosition(
|
||||
locationSettings: const LocationSettings(
|
||||
@@ -108,7 +108,15 @@ class _DashboardViewState extends State<DashboardView> {
|
||||
if (mounted) setState(() => _mapCenter = latlng);
|
||||
_mapController?.animateCamera(CameraUpdate.newLatLngZoom(latlng, 16));
|
||||
_reverseGeocode(latlng);
|
||||
} catch (_) {}
|
||||
} catch (_) {
|
||||
await _centerOnUserCity();
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _centerOnUserCity() async {
|
||||
final city = user?.city;
|
||||
if (city == null || city.isEmpty) return;
|
||||
await _geocodeAndMoveMap(city);
|
||||
}
|
||||
|
||||
Future<void> _reverseGeocode(LatLng pos) async {
|
||||
|
||||
Reference in New Issue
Block a user