geocoder-php / GeocoderLaravel

Geocoder service provider for Laravel
http://geocoder-php.org/GeocoderLaravel/
MIT License
706 stars 102 forks source link

reverse() returning empty collection / null #141

Closed ghost closed 6 years ago

ghost commented 6 years ago

General Information

GeocoderLaravel Version: 4.0 Laravel Version: 5.6 PHP Version: 7.2.4 Operating System and Version: WAMP on Windows 10

Issue Description

app('geocoder')->reverse(52.773613,-108.297923)->get() is returning an empty collection.

app('geocoder')->geocode('5.43.168.58')->get() works fine.

The problem is when I try to do a reverse()

I have followed documentation for install, I ensured my API key allows Geocoding API, and have given access to my IP.

I have tried clearing cache, composer dump-autoload. Still no luck. No matter what I do I get an empty collection.

I tried using the url https://maps.googleapis.com/maps/api/geocode/json?latlng=52.773613,-108.297923&region=en-US&key=[MY_API_KEY] to see if it is my API key causing the problem, but I get the proper data returned based on the coordinates using that url.

hassan-bazzi commented 6 years ago

Same issue here

brentscholl commented 6 years ago

I am also having the same problem. reverse() returns an empty collection. No error messages

The link @xperiuminc posted using my API key returns the correct json data.

mikebronner commented 6 years ago

I'll look into this, thanks for reporting.

mikebronner commented 6 years ago

@xperiuminc @brentscholl @hassan-bazzi I am unable to reproduce this error. My initial suspicions is that there is something wrong with your config file, or you have exceeded Google's API limit. I tried your exact query above app('geocoder')->reverse(52.773613,-108.297923)->get() and got results. I'm not sure if your locale setting might affect this if you have it set to something other then the default (English, United States).

I will close this for now, as this does not appear to be an issue with the package itself. If you can provide further information that would help troubleshoot this, please feel free to reopen.

ghost commented 6 years ago

Shouldn't there at least be some sort of error thrown? Not sure how I can go about troubleshooting this problem.

mikebronner commented 6 years ago

@xperiuminc The package isn't erring out ... it is probably getting an empty result set back from the provider (Google Maps, I presume). The package has no way of knowing an error occurred. Double-check that the API token is set correctly, as well as Google Developer Console to make sure you haven't exceeded your quota.

ghost commented 5 years ago

For anyone who stumbles on this. I was able to solve this problem by using Laravel Homestead instead of wamp.

I was using Wamp and php artisan serve to serve the site on my local machine. The problem may be with wamp.

After switching to Laravel Homestead using Vagrant and Virtual Box, app('geocoder')->reverse(52.773613,-108.297923)->get() works

I'm not sure what was causing the problem in wamp. If it is possible to add more error messages to this package, that may be helpful for future developers.

samatcd commented 4 years ago

For what it's worth, I had this issue and it was indeed due to incorrectly configured google maps API key.

However, even though I've resolved the problem with the API key, I'm still getting null / empty collection returned for the lat,long that I was testing with — If I change even one decimal place, I get results.

I'm presuming this has something to do with cached results, however I still get empty results for those original coordinates, even after running php artisan cache:clear.