add list adress from v6 mapbox and searchbox
This commit is contained in:
parent
03f3e1c55b
commit
43124d9cb9
@ -173,14 +173,8 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
final mapboxAccessToken = dotenv.env['MAPBOX_ACCESS_TOKEN'] ?? '';
|
||||
|
||||
// Searchbox API for geocoding the place (No session token)
|
||||
final searchboxUrl =
|
||||
Uri.parse('https://api.mapbox.com/search/searchbox/v1/retrieve/')
|
||||
.replace(queryParameters: {
|
||||
'access_token': mapboxAccessToken,
|
||||
'query': place,
|
||||
'limit': '1',
|
||||
'types': 'place,address',
|
||||
});
|
||||
final searchboxUrl = Uri.parse(
|
||||
'https://api.mapbox.com/search/geocode/v6/forward?access_token=${mapboxAccessToken}&q=${place}');
|
||||
|
||||
final searchboxResponse = await http.get(searchboxUrl);
|
||||
|
||||
@ -197,7 +191,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
|
||||
// Extract place details from the searchbox response
|
||||
final firstFeature = searchboxData['features'][0];
|
||||
place = firstFeature['place_name'];
|
||||
place = firstFeature['properties']["full_address"];
|
||||
final coordinates = firstFeature['geometry']['coordinates'];
|
||||
final longitude = coordinates[0];
|
||||
final latitude = coordinates[1];
|
||||
@ -345,8 +339,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
.map((feature) => {
|
||||
'name': feature['name'],
|
||||
'full_address': feature[
|
||||
'place_formatted'], // Adjusted to match the data structure
|
||||
'context': feature['context'], // Additional context data
|
||||
'full_address'] // Adjusted to match the data structure
|
||||
})
|
||||
.toList();
|
||||
});
|
||||
@ -402,7 +395,7 @@ class _UpdateeventImageState extends State<UpdateeventImage>
|
||||
print("suggestion tapped : ${suggestions[index]}");
|
||||
|
||||
setState(() {
|
||||
geographicalZone = suggestions[index]['name'];
|
||||
geographicalZone = suggestions[index]['full_address'];
|
||||
inputGeo.text = geographicalZone;
|
||||
suggestions.clear();
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user