Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get place from Google Places API using ID

I can get place details from Google places API when I know the reference by using:

https://maps.googleapis.com/maps/api/place/details/json?reference=CmRYAAAAciqGsTRX1mXRvuXSH2ErwW-jCINE1aLiwP64MCWDN5vkXvXoQGPKldMfmdGyqWSpm7BEYCgDm-iv7Kc2PF7QA7brMAwBbAcqMr5i1f4PwTpaovIZjysCEZTry8Ez30wpEhCNCXpynextCld2EBsDkRKsGhSLayuRyFsex6JA6NPh9dyupoTH3g&sensor=true&key=API_KEY_HERE

However, I want to get the same information by using the ID instead. So the same place in the query above would be something like:

https://maps.googleapis.com/maps/api/place/details/json?id=4f89212bf76dde31f092cfc14d7506555d85b5c7&sensor=true&key=API_KEY_HERE

Is such a thing possible?

This will be part of a search filter I'm building, part of which is location. My search parameters are passed to the url, so I plan to do the same with the selected location from the places autocomplete. Using id is much shorter than reference, so more suitable for the querystring. Unless there is a better way to do it?

like image 518
iltdev Avatar asked Mar 25 '13 18:03

iltdev


2 Answers

You can search Place data by PlaceID

https://maps.googleapis.com/maps/api/place/details/json?placeid=ChIJF7QkuDsDLz4R0rJ4SsxFl9w&key=YOUR_KEY
like image 83
Azhar Avatar answered Nov 09 '22 09:11

Azhar


It is now possible to fetch place data by placeId:

https://developers.google.com/maps/documentation/javascript/examples/place-details

like image 36
Jeremy Eaton Avatar answered Nov 09 '22 09:11

Jeremy Eaton