Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New way of getting lat and long? #170

Open
LeonardoClemente opened this issue Jul 5, 2021 · 3 comments
Open

New way of getting lat and long? #170

LeonardoClemente opened this issue Jul 5, 2021 · 3 comments

Comments

@LeonardoClemente
Copy link

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
Copy link

I just use this to get lat and lng:

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

@obrunsmann
Copy link

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
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants