geocoder-php / GeocoderLaravel

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

get() returns empty array, all() returns with correct GEO Information #175

Closed njoyjoy closed 4 years ago

njoyjoy commented 4 years ago

General Information

GeocoderLaravel Version: 4.3.2 Laravel Version: 7.16.1 PHP Version: 7.4 Operating System and Version: MacOS, Laravel Homestead Vagrant Provider: Google Maps API

Issue Description

Using app('geocoder')->geocode('Los Angeles, CA')->get(), returns an empty result set from Google Maps API:

 Jun 20 12:03:04 homestead php [2020-06-20 19:03:04] local.WARNING: [{}] 

Using app('geocoder')->geocode('Los Angeles, CA')->all(), returns correctly with the required information in the result set:

Jun 20 12:03:04 homestead php [2020-06-20 19:03:03] local.WARNING: array (
 Jun 20 12:03:04 homestead php   0 => 
 Jun 20 12:03:04 homestead php   Geocoder\Provider\GoogleMaps\Model\GoogleAddress::__set_state(array(
 Jun 20 12:03:04 homestead php      'id' => 'xx,
 Jun 20 12:03:04 homestead php      'locationType' => 'APPROXIMATE',
 Jun 20 12:03:04 homestead php      'resultType' => 
 Jun 20 12:03:04 homestead php     array (
 Jun 20 12:03:04 homestead php       0 => 'locality',
 Jun 20 12:03:04 homestead php       1 => 'political',
 Jun 20 12:03:04 homestead php     ),
 Jun 20 12:03:04 homestead php      'formattedAddress' => 'Los Angeles, CA, USA',
 Jun 20 12:03:04 homestead php      'streetAddress' => NULL,
 Jun 20 12:03:04 homestead php      'intersection' => NULL,
 Jun 20 12:03:04 homestead php      'political' => 'United States',
 Jun 20 12:03:04 homestead php      'colloquialArea' => NULL,
 Jun 20 12:03:04 homestead php      'ward' => NULL,
 Jun 20 12:03:04 homestead php      'neighborhood' => NULL,
 Jun 20 12:03:04 homestead php      'premise' => NULL,
 Jun 20 12:03:04 homestead php      'subpremise' => NULL,
 Jun 20 12:03:04 homestead php      'naturalFeature' => NULL,
 Jun 20 12:03:04 homestead php      'airport' => NULL,
 Jun 20 12:03:04 homestead php      'park' => NULL,
 Jun 20 12:03:04 homestead php      'pointOfInterest' => NULL,
 Jun 20 12:03:04 homestead php      'establishment' => NULL,
 Jun 20 12:03:04 homestead php      'subLocalityLevels' => 
 Jun 20 12:03:04 homestead php     Geocoder\Model\AdminLevelCollection::__set_state(array(
 Jun 20 12:03:04 homestead php        'adminLevels' => 
 Jun 20 12:03:04 homestead php       array (
 Jun 20 12:03:04 homestead php       ),
 Jun 20 12:03:04 homestead php     )),
 Jun 20 12:03:04 homestead php      'partialMatch' => false,
 Jun 20 12:03:04 homestead php      'coordinates' => 
 Jun 20 12:03:04 homestead php     Geocoder\Model\Coordinates::__set_state(array(
 Jun 20 12:03:04 homestead php        'latitude' => 34.0522342,
 Jun 20 12:03:04 homestead php        'longitude' => -118.2436849, etc..

Steps to Replicate

Try get() vs. all() using the documented example.

This worked properly in our code with get() for quite some time, perhaps until we upgraded Laravel. We have confirmed it is hitting the Google Maps API and not throwing and error there.

mikebronner commented 4 years ago

Thanks, I will try to replicate this.

mikebronner commented 4 years ago

@njoyjoy I am unable to replicate this, and the results actually return correct data. Please submit a PR with a failing test, if you are able to replicate it. In the meantime I will close this, as it appears to be an issue with your app. Feel free to reopen if you can provide more details.