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