How google show nearby places?

hi any one know how google show nearby places , which api is used to show the near by places.

Here ya go, the Google Nearby Places API, found with Google! :slight_smile:

The Google Places API - Google Maps API Web Services - Google Code

but when i request it shows request denied ,example also didnt work.why?

Did you put your own API key in the request?[long url]sensor=false&key=[your API key goes here]

yes,i used my own api key it show same message as request denied

Did you enable your API key for the Places API?

Log in at and make sure Places API is ‘on’ on the Services page.

I’ve attached a screenshot of the API console, it might take a while before it’s approved though.

I just tried a request using my own key, and it works fine.

thank you , now it show near by places. it display based one some types like hotel,harbour etc. i want to display near by area which is around 5 km from my current location. could you give some idea to do.

It tells you on the page I linked to earlier how you can do that (The Google Places API - Google Maps API Web Services - Google Code).

But what you need to do is to work out your current position, and then place the latitude and longitude in the URL. Also change the radius to 5000 (as that’s the number of meters in your 5KM).

thank u once again Immerse. it display the nearby places. if want to get result in miles means how to change the radius value. is there any calculation. sorry if it is silly question.

compare to google results with the api result nearby location are varies ,can you tell why.

1 mile = 1.6 kilometers, so 5 km is 3.125 Miles.

Not sure why you’re getting a different results…

so i have to convert the miles to km then give as radius in querystring.
did you check results with that it giving correct result?

i want nearby cities , is there option to add type as cities , or have to increase radius

Here are all the types: Google Places API: Supported Place Types - Google Maps API Web Services - Google Code

You probably need locality (or maybe postal_town). Documentation is awesome :wink:

thank you i saw, i read the result using curl , but it returns u why is any other way to read the results

$url="placesearch url";

curl_setopt($ch, CURLOPT_URL,$url); 

curl_setopt($ch, CURLOPT_HEADER,1); 

curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);

echo $data = curl_exec($ch); //execute curl


Try running curl_error(), it will tell you why curl_exec failed.

it shows the following error

 error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed

this show some secure data

Try adding these two options to your cURL code:

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,  2);

It basically tells cURL not to check if the ssl’s certificate is valid for the host you’re querying. :o

hi i have added like this it works fine. your code also works fine. thank you for your support.

curl_setopt ($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, 0);

i have parse the data to display the results , using json_decode($data) but it return null when i put var_dump($jsondata); how to display the results

i got the result as array using


thanks immerse

You’re welcome :slight_smile: