geocoder-php / GeocoderLaravel

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

unable to use geocoder in laravel 5.3 #118

Closed nigam214 closed 6 years ago

nigam214 commented 6 years ago

General Information

GeocoderLaravel Version: 4.0.5 Laravel Version: 5.3.29 PHP Version: PHP 7.0.25 Operating System and Version: Linux ubuntu-xenial 4.4.0-112-generic #135-Ubuntu SMP Fri Jan 19 11:48:36 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux ; on Vagrant

Issue Description

I am getting error in Chain when trying to initiate Geocoder::using('google_maps').

Steps to Replicate

composer require toin0u/geocoder-laravel Geocoder::using('google_maps');

Stack Trace

ErrorException: Object of class Geocoder\Provider\Chain\Chain could not be converted to string in /vagrant/laravel.api/vendor/willdurand/geocoder/Exception/ProviderNotRegistered.php:29 Stack trace:

0 /vagrant/laravel.api/vendor/sentry/sentry/lib/Raven/Breadcrumbs/ErrorHandler.php(34): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(4096, 'Object of class...', '/vagrant/larave...', 29, Array)

1 [internal function]: Raven_Breadcrumbs_ErrorHandler->handleError(4096, 'Object of class...', '/vagrant/larave...', 29, Array)

2 /vagrant/laravel.api/vendor/willdurand/geocoder/Exception/ProviderNotRegistered.php(29): implode(', ', Array)

3 /vagrant/laravel.api/vendor/willdurand/geocoder/ProviderAggregator.php(148): Geocoder\Exception\ProviderNotRegistered::create('google_maps', Array)

4 /vagrant/laravel.api/vendor/toin0u/geocoder-laravel/src/ProviderAndDumperAggregator.php(179): Geocoder\ProviderAggregator->using('google_maps')

5 /vagrant/laravel.api/bootstrap/cache/compiled.php(6468): Geocoder\Laravel\ProviderAndDumperAggregator->using('google_maps')

6 /vagrant/laravel.api/app/Libraries/LibCore/LibGeocoder.php(23): Illuminate\Support\Facades\Facade::__callStatic('using', Array)

7 /vagrant/laravel.api/routes/console.php(56): App\Libraries\LibCore\LibGeocoder::getAddressDetail('31.2631006', '62.9837423')

8 /vagrant/laravel.api/routes/console.php(44): processAddress('https://www.goo...')

9 [internal function]: Illuminate\Foundation\Console\ClosureCommand->{closure}()

10 /vagrant/laravel.api/bootstrap/cache/compiled.php(1375): call_user_func_array(Object(Closure), Array)

11 /vagrant/laravel.api/vendor/laravel/framework/src/Illuminate/Foundation/Console/ClosureCommand.php(55): Illuminate\Container\Container->call(Object(Closure), Array)

12 /vagrant/laravel.api/vendor/symfony/console/Command/Command.php(261): Illuminate\Foundation\Console\ClosureCommand->execute(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

13 /vagrant/laravel.api/vendor/laravel/framework/src/Illuminate/Console/Command.php(155): Symfony\Component\Console\Command\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

14 /vagrant/laravel.api/vendor/symfony/console/Application.php(817): Illuminate\Console\Command->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

15 /vagrant/laravel.api/vendor/symfony/console/Application.php(185): Symfony\Component\Console\Application->doRunCommand(Object(Illuminate\Foundation\Console\ClosureCommand), Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

16 /vagrant/laravel.api/vendor/symfony/console/Application.php(116): Symfony\Component\Console\Application->doRun(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

17 /vagrant/laravel.api/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(121): Symfony\Component\Console\Application->run(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

18 /vagrant/laravel.api/artisan(35): Illuminate\Foundation\Console\Kernel->handle(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))

19 {main}

mikebronner commented 6 years ago

Can you post you geocoder configuration file as well? That would help a lot. :) Thanks

nigam214 commented 6 years ago

I have used default configuration file. I mean, I didn't load the local configuration file for geocoder.

Update:

Case 1: Geocoder::using('google_maps')->reverse($latitude, $longitude); This gives error as given above

Case 2: Geocoder::reverse($latitude, $longitude); This works without error

mikebronner commented 6 years ago

You need to add the google maps configuration outside the chain provider, if you want to use it explicitly. Anything inside the chain provider is not available to using(), except via using('chain').

My recommendation is to publish and customize the config file by adding a second google maps provider entry outside of the chain provider.

Let me know how that works for you.

nigam214 commented 6 years ago

Got the point. I have continued my project without using() for now as I want to use google maps which comes with default. Thank you for the information.