Question

I feel like I'm being blocked from searching with lat/long in US/Canada some reason.

Any other city in nearly every other continent is returning results, except cities in US/Canada.

I've searched their documentation, there hasn't been anything that's popped up about not working for North America.

What I have working for outside NA:

//Places Search
$apiKey = '';

$url = 'https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=39.0997,94.5786&radius=50000&keyword=car&sensor=false&key=' . $apiKey;

$result = file_get_contents($url);

print_r(json_decode($result, true));

This returns an array:

Array
(
    [html_attributions] => Array
        (
        )

    [results] => Array
        (
        )

    [status] => ZERO_RESULTS
)

Literally putting any city outside of the US/Canada will return a giant array of goodness. What's going on?

Was it helpful?

Solution

Make sure you are providing the latitude and longitude in Decimal format. It is very likely that you are missing the negative (-) sign for your longitude value.

So for something like San Fransisco, which is at 37.7833° N, 122.4167° W, you would want to pass 37.7833,-122.4167

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top