Empty results (tried everything on the other closed tickets)
yohio opened this issue · 5 comments
General Information
GeocoderLaravel Version: 4.0.20
Laravel Version: 5.5
PHP Version: 7.1.9
Operating System and Version:
- WAMP on windows
- Ubuntu 18 on vultr with ssl (running LEMP)
** Both behaving the same **
Issue Description
After installing it (did the process twice) and setting it up I run app('geocoder')->geocode('Los Angeles, CA')->get();
and get object(Illuminate\Support\Collection)#994 (1) { ["items":protected]=> array(0) { } }
as the response.
When trying my IP I get object(Illuminate\Support\Collection)#994 (1) { ["items":protected]=> array(1) { [0]=> object(Geocoder\Model\Address)#996 (11) { ["coordinates":"Geocoder\Model\Address":private]=> object(Geocoder\Model\Coordinates)#1003 (2) { ["latitude":"Geocoder\Model\Coordinates":private]=> float(43.4881) ["longitude":"Geocoder\Model\Coordinates":private]=> float(-79.7098) } ["bounds":"Geocoder\Model\Address":private]=> NULL ["streetNumber":"Geocoder\Model\Address":private]=> NULL ["streetName":"Geocoder\Model\Address":private]=> NULL ["subLocality":"Geocoder\Model\Address":private]=> NULL ["locality":"Geocoder\Model\Address":private]=> string(8) "Oakville" ["postalCode":"Geocoder\Model\Address":private]=> NULL ["adminLevels":"Geocoder\Model\Address":private]=> object(Geocoder\Model\AdminLevelCollection)#998 (1) { ["adminLevels":"Geocoder\Model\AdminLevelCollection":private]=> array(1) { [1]=> object(Geocoder\Model\AdminLevel)#995 (3) { ["level":"Geocoder\Model\AdminLevel":private]=> int(1) ["name":"Geocoder\Model\AdminLevel":private]=> string(7) "Ontario" ["code":"Geocoder\Model\AdminLevel":private]=> string(2) "ON" } } } ["country":"Geocoder\Model\Address":private]=> object(Geocoder\Model\Country)#1004 (2) { ["name":"Geocoder\Model\Country":private]=> string(6) "Canada" ["code":"Geocoder\Model\Country":private]=> string(2) "CA" } ["timezone":"Geocoder\Model\Address":private]=> NULL ["providedBy":"Geocoder\Model\Address":private]=> string(10) "geo_plugin" } } }
When inspecting the code it seems that it works with IP only, but I need it to work with an address text so I can get lon-lat.
Steps to Replicate
- Follow the steps of installation from the git repo.
- Add the
Geocoder\Laravel\Providers\GeocoderService::class,
to the providers - Add the environment objects of
GOOGLE_MAPS_API_KEY=***
andGOOGLE_MAPS_LOCALE=en-US
- run
php artisan vendor:publish --provider="Geocoder\Laravel\Providers\GeocoderService" --tag="config"
etc... I followed the process to the letter with 1 exception, didn't set up the redis cache.
Then added the following code:
Address version:
$geocode = app('geocoder')->geocode("Los Angeles, CA")->get();
IP version:
$geocode = app('geocoder')->geocode("45.78.181.210")->get();
After both:
var_dump($geocode);
Results are showing empty for address and a lot of NULL for the IP
Stack Trace
No Errors
I have the same issue with the app('geocoder')->reverse(43.882587,-103.454067)->get();
Results when I dd()
Collection {#563 ▼
#items: []
}
I made sure that the my API key is correct and that geocoding is enabled in Google Cloud Platform
also have the same problem,
works with IP but not with address.
using laravel 5.7 and windows.
Will look into this as soon as possible. Thanks for reporting.
I had this issue but it was due to my API key not being set correctly. I use a different .env key for it so publishing the config and changing the env key fixed it for me. Did you try making a manual http request using your api key?
Hi @yohio @GalLellouche, I think @robbplo might be on to something. I have not been able to replicate your problems. As with #141, I am getting the expected results. This is either something with your config or your service provider account. If you can provide more information to help troubleshoot, please feel free to reopen. However, based on the information provided, this does not appear to be an issue with the package itself, sorry. Good luck!