2
votes

Am using google maps places api to mark nearby gas stations , but am not getting the price details in response as we see in actual google maps and also i need the distance information. how do i get it.?

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=39.833851,-74.871826&radius=5000&types=gas_station&rankBy=distance&sensor=true&key=API_KEY

1

1 Answers

0
votes

The price information currently isn't available in the APIs. I'd recommend filing a feature request for it here:

https://issuetracker.google.com/issues/new?component=188872&template=789309

As for the distance information, you will need use either the directions API or distance matrix API to get distance from your origin to the destination (the gas station selected). I'll use the place ID for the first gas station returned in your query as an example:

https://maps.googleapis.com/maps/api/directions/json?origin=39.833851,-74.871826&destination=place_id:ChIJc44A2jYxwYkR9_42tATl9n0&key=MY_API_KEY

I hope this helps!