fluttercommunity / flutter_google_places

Google Places - Google places autocomplete widgets for flutter. No wrapper, use https://pub.dev/packages/google_maps_webservice. Maintainer: @juliansteenbakker
https://pub.dev/packages/flutter_google_places
Other
303 stars 415 forks source link

New way of getting lat and long? #170

Open LeonardoClemente opened 3 years ago

LeonardoClemente commented 3 years ago

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!

jpetro416 commented 2 years ago

I just use this to get lat and lng:

          double latitude = placeDetails!.result.geometry!.location.lat
          double longitude = placeDetails!.result.geometry!.location.lng
obrunsmann commented 2 years ago

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

jpetro416 commented 2 years ago

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?