flutter_google_places icon indicating copy to clipboard operation
flutter_google_places copied to clipboard

New way of getting lat and long?

Open LeonardoClemente opened this issue 3 years ago • 3 comments

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!

LeonardoClemente avatar Jul 05 '21 18:07 LeonardoClemente

I just use this to get lat and lng:

          double latitude = placeDetails!.result.geometry!.location.lat
          double longitude = placeDetails!.result.geometry!.location.lng

jpetro416 avatar Jan 22 '22 21:01 jpetro416

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

obrunsmann avatar Mar 21 '22 14:03 obrunsmann

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?

jpetro416 avatar Mar 28 '22 04:03 jpetro416