i tried just "p" and through my display route function but i printed out the output to the log and all i got was "p is instance of 'Prediction' "
child: TextField(onTap: () async{
Prediction p = await PlacesAutocomplete.show(
context: context, apiKey: kGoogleApiKey,
language: "en", components: [new Component(Component.country, "mw")]
print("+++++++$p");
displayRoute(p);
);
Pass Prediction object as a parameter to the following function and get latitude , longitude and address of the selected location inside it.
void _getLatLng(Prediction prediction) async {
GoogleMapsPlaces _places = new
GoogleMapsPlaces(apiKey: API_KEY);
PlacesDetailsResponse detail =
await _places.getDetailsByPlaceId(prediction.placeId);
double latitude = detail.result.geometry.location.lat;
double longitude = detail.result.geometry.location.lng;
String address = prediction.description;
}
For Further details check this article .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.