flutter_google_places
flutter_google_places copied to clipboard
New way of getting lat and long?
Hey there,
I was using flutter_google_places to query lat and lon information from locations but it seems the new version has changed the way to use the widgets.
In the previous version I was doing something like this
GooglePlaceAutoCompleteTextField(
textEditingController:textControllerReport,
googleAPIKey: "apikey",
inputDecoration: InputDecoration(
hintText: 'Direccion del Reporte'
),
debounceTime: 800, // default 600 ms,
countries: ["mx"],// optional by default null is set
isLatLngRequired:true,// if you required coordinates from place detail
getPlaceDetailWithLatLng: (prediction) {
// this method will return latlng with place detail
print(prediction.description);
print("placeDetails" + prediction.lng.toString());
print("placeDetails" + prediction.lat.toString());
}, // this callback is called when isLatLngRequired is true
itmClick: (prediction) {
print(prediction);
textControllerReport.text=prediction.description;
textControllerReport.selection = TextSelection.fromPosition(TextPosition(offset: prediction.description.length));
},
)
Is there a way to do the same on version 3 of google_places? Thanks!
I just use this to get lat and lng:
double latitude = placeDetails!.result.geometry!.location.lat
double longitude = placeDetails!.result.geometry!.location.lng
I just use this to get lat and lng:
double latitude = placeDetails!.result.geometry!.location.lat double longitude = placeDetails!.result.geometry!.location.lng
Have you used this on the latest version as well? PlacesAutocomplete.show()
now returns a Future of Response which has no lat/lng :/ https://pub.dev/documentation/google_maps_webservice/0.0.20-nullsafety.5/google_maps_webservice.places/Prediction-class.html
I just use this to get lat and lng:
double latitude = placeDetails!.result.geometry!.location.lat double longitude = placeDetails!.result.geometry!.location.lng
Have you used this on the latest version as well?
PlacesAutocomplete.show()
now returns a Future of Response which has no lat/lng :/ https://pub.dev/documentation/google_maps_webservice/0.0.20-nullsafety.5/google_maps_webservice.places/Prediction-class.html
I'm using flutter_google_places: ^0.3.0
Does await
do anything for that?