Reputation: 33
am new to flutter
Am working on a project that uses places API and Google map. I want the users to be able to get a place address when they input the place id.
I have been able to retrieve the place id using geocode.
Please how to I get the place address using the place id
Upvotes: 2
Views: 5822
Reputation: 1790
You can read all information about Place IDs from the official doc: https://developers.google.com/maps/documentation/places/web-service/place-id
Just make a GET request:
https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJrTLr-GyuEmsRBfy61i59si0&key=YOUR_API_KEY
Upvotes: 1
Reputation: 889
Use google_maps_webservice package:
final geocoding = GoogleMapsGeocoding(
apiKey: '...........');
final response = await geocoding.searchByPlaceId('ChIJd8BlQ2BZwokRAFUEcm_qrcA');
final result = response.results[0].formattedAddress;
// Result will be: 277 Bedford Ave, Brooklyn, NY 11211, USA
Remember to enable the service from the Developer Console.
Upvotes: 3