geocoder-php / GeocoderLaravel

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

Result sets mostly empty #138

Closed ejrudy closed 6 years ago

ejrudy commented 6 years ago

General Information

GeocoderLaravel Version: 4.0.20 Laravel Version: 5.3.31 PHP Version: 7.2.4 Operating System and Version: Ubuntu 16.04.1

Issue Description

Recently upgraded this package on a project and since then I'm getting seemingly random retrieval of results. I'm not sure what's going on, but I seem to get wildly varying results back from the geocoder (going by address, sometimes getting empty sets on the same queries that worked before). I'm not sure what will work and what won't, obviously its a bit problematic when even the example of 'Los Angeles, CA' returns no results.

Steps to Replicate

To troubleshoot I've just been using tinker. Here are some examples:

>>> app('geocoder')->geocode("1698 Fox Butte Court, Henderson, NV")->get()->first()
=> null
>>> app('geocoder')->geocode("1698 Fox Butte Court, Henderson, Nevada")->get()->first()
=> null
>>> app('geocoder')->geocode("1698 Fox Butte Ct, Henderson, Nevada")->get()->first()
=> null
>>> app('geocoder')->geocode("1698 Fox Butte Ct, Henderson")->get()->first()
=> Geocoder\Provider\GoogleMaps\Model\GoogleAddress {#897}

This one worked in the context of my app and correctly geocoded...but as you can see here, subsequent tries yielded no results:

>>> app('geocoder')->geocode("131 Pensdale St")->get()->first()
=> null
>>> app('geocoder')->geocode("131 Pensdale Street")->get()->first()
=> null
>>> app('geocoder')->geocode("131 Pensdale St, Philadelphia, PA 19127")->get()->first()
=> null
>>> app('geocoder')->geocode("131 Pensdale St Philadelphia PA 19127")->get()->first()
=> null
>>> app('geocoder')->geocode("131 Pensdale St. Philadelphia PA 19127")->get()->first()
=> null

And finally the example code:

>>> app('geocoder')->geocode('Los Angeles, CA')->get()->first();
=> null
>>> app('geocoder')->geocode('Los Angeles, CA')->get();
=> Illuminate\Support\Collection {#871
     all: [],
   }

I had initially incorrectly set my google api key (I was getting 0 results then), but since setting it I get intermittent results back- though still mostly empty results. I appreciate any and all help here!

mikebronner commented 6 years ago

Hi @ejrudy, I'm not sure this is an issue with the package, as GeocoderLaravel is just a Laravel wrapper for the core Geocoded package. I have seen behavior like this when the provider rate-limited queries from a certain IP address. Have you checked your Google Developer Console to see if you are exceeding your quota? I won't be able to look into this myself for a while yet, as I am traveling outside of the country.

ejrudy commented 6 years ago

Thanks for the quick reply @mikebronner- I'll look into that and let you know if this was a false alarm.

ejrudy commented 6 years ago

@mikebronner I double-checked my usage and I seem to be getting back 403 errors from Google. I also tried utilizing the Guzzle adapter to see if that would make any difference (unfortunately not).

Could that be related to the SSL issues that I had seen noted in the docs and some GH issues? I also noticed in the docs something about setting SSL to true when providing a google API key...but no mention of where/how to do it? It still intermittently works correctly...

Anyway, I know you're out of the country so I don't expect a quick response but I do appreciate the help!

humblecoder commented 6 years ago

I'm having a similar problem as well when reverse geocoding. It may be rate-limited, but it also may be due to the fact that I have no earthly idea how to add alternative "unlisted" providers to the Chain. 😖

mikebronner commented 6 years ago

Hi @humblecoder please open a new issue describing your problem and setup in detail.

mikebronner commented 6 years ago

Hi @ejrudy, please check the following: https://duckduckgo.com/?q=google+maps+api+403&t=osx&ia=qa

I suspect you arexceeding your rate limit. If that is not the case, feel free to re-open this issue and I will test your above steps. If they end up working for me, it is likely that is has to do with your Google API account.