Anakor Divine
Anakor Divine

Reputation: 33

Get an address for place ID in flutter

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

Answers (2)

IvanPavliuk
IvanPavliuk

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

unbalanced_equation
unbalanced_equation

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

Related Questions