diff --git a/covas_mobile/lib/pages/UpdateEventImage.dart b/covas_mobile/lib/pages/UpdateEventImage.dart index 5532b92..df19763 100644 --- a/covas_mobile/lib/pages/UpdateEventImage.dart +++ b/covas_mobile/lib/pages/UpdateEventImage.dart @@ -315,15 +315,15 @@ class _UpdateeventImageState extends State } Future searchSuggestions(String input) async { - var uuid = Uuid(); + String sessionToken = uuid.v4(); await dotenv.load(fileName: ".env"); // Load .env file - final mapboxAccessToken = dotenv.env['MAPBOX_ACCESS_TOKEN'] ?? ''; + final ApiTokenGoogle = dotenv.env['GEMINI_API_KEY'] ?? ''; // Define the Searchbox API URL final searchboxUrl = Uri.parse( - 'https://api.mapbox.com/search/searchbox/v1/suggest?q=${input}&limit=5&language=en&types=place,poi,address&session_token=${sessionToken}&access_token=${mapboxAccessToken}'); + 'https://maps.googleapis.com/maps/api/place/textsearch/json?query=${input}&key=${ApiTokenGoogle}'); // Perform the request final response = await http.get(searchboxUrl); @@ -335,11 +335,11 @@ class _UpdateeventImageState extends State setState(() { // Map the results to extract name and full_address - suggestions = (data['suggestions'] as List) + suggestions = (data['results'] as List) .map((feature) => { 'name': feature['name'], - 'full_address': feature[ - 'full_address'] // Adjusted to match the data structure + 'formatted_address': feature[ + 'formatted_address'] // Adjusted to match the data structure }) .toList(); }); @@ -390,12 +390,12 @@ class _UpdateeventImageState extends State itemBuilder: (context, index) { return ListTile( title: Text(suggestions[index]['name']), - subtitle: Text(suggestions[index]['full_address']), + subtitle: Text(suggestions[index]['formatted_address']), onTap: () async { print("suggestion tapped : ${suggestions[index]}"); setState(() { - geographicalZone = suggestions[index]['full_address']; + geographicalZone = suggestions[index]['formatted_address']; inputGeo.text = geographicalZone; suggestions.clear(); });