feat: Add geocoding functionality for trips and enhance activity search with coordinates
This commit is contained in:
@@ -377,7 +377,9 @@ class ActivityPlacesService {
|
||||
|
||||
/// Recherche d'activités avec pagination (6 par page)
|
||||
Future<Map<String, dynamic>> searchActivitiesPaginated({
|
||||
required String destination,
|
||||
String? destination,
|
||||
double? latitude,
|
||||
double? longitude,
|
||||
required String tripId,
|
||||
ActivityCategory? category,
|
||||
int pageSize = 6,
|
||||
@@ -385,16 +387,29 @@ class ActivityPlacesService {
|
||||
int radius = 5000,
|
||||
}) async {
|
||||
try {
|
||||
print('ActivityPlacesService: Recherche paginée pour: $destination (page: ${nextPageToken ?? "première"})');
|
||||
double lat, lng;
|
||||
|
||||
// Utiliser les coordonnées fournies ou géocoder la destination
|
||||
if (latitude != null && longitude != null) {
|
||||
lat = latitude;
|
||||
lng = longitude;
|
||||
print('ActivityPlacesService: Utilisation des coordonnées pré-géolocalisées: $lat, $lng');
|
||||
} else if (destination != null) {
|
||||
print('ActivityPlacesService: Géolocalisation de la destination: $destination');
|
||||
final coordinates = await _geocodeDestination(destination);
|
||||
lat = coordinates['lat']!;
|
||||
lng = coordinates['lng']!;
|
||||
} else {
|
||||
throw Exception('Destination ou coordonnées requises');
|
||||
}
|
||||
|
||||
// 1. Géocoder la destination
|
||||
final coordinates = await _geocodeDestination(destination);
|
||||
print('ActivityPlacesService: Recherche paginée aux coordonnées: $lat, $lng (page: ${nextPageToken ?? "première"})');
|
||||
|
||||
// 2. Rechercher les activités par catégorie avec pagination
|
||||
if (category != null) {
|
||||
return await _searchByCategoryPaginated(
|
||||
coordinates['lat']!,
|
||||
coordinates['lng']!,
|
||||
lat,
|
||||
lng,
|
||||
category,
|
||||
tripId,
|
||||
radius,
|
||||
@@ -404,8 +419,8 @@ class ActivityPlacesService {
|
||||
} else {
|
||||
// Pour toutes les catégories, faire une recherche générale paginée
|
||||
return await _searchAllCategoriesPaginated(
|
||||
coordinates['lat']!,
|
||||
coordinates['lng']!,
|
||||
lat,
|
||||
lng,
|
||||
tripId,
|
||||
radius,
|
||||
pageSize,
|
||||
|
||||
Reference in New Issue
Block a user