ThomasDhaen
ThomasDhaen

Reputation: 71

Get a place ID on tap Google Maps Android

I built in google maps into my app. If you zoom close enough you will see places (see screenshot)

https://i.sstatic.net/rYCWl.png

I need to get the place ID for those places (ie when a user taps on it), thought this would be straightforward but unfortunately I cannot find it.

It would be similar as the official google maps app, if you click a place, it will load all the place information.

Upvotes: 3

Views: 630

Answers (2)

Sagar Nayak
Sagar Nayak

Reputation: 2216

i will come straight to the point . follow the steps as i say.

first on the onMapClickListener() you will get the latlng and we will use this to get a place id for that place.

use this url to get the place id . the url will return json data and you can check it on browser that this gives a place id for that place. then you have to parse it in your app accordingly . the url is as follows-

https://maps.googleapis.com/maps/api/place/autocomplete/json?input=your_latitude,your_longitude&sensor=false&key=your_api_key

give it a try and let me know.

thank you

Upvotes: 1

Neo
Neo

Reputation: 1201

Have a look at the PlacePicker.

https://developers.google.com/places/android-api/placepicker

Upvotes: 0

Related Questions