Skip to content

MapBox Provider issue issue? #178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
devs-ryan opened this issue Jul 27, 2020 · 5 comments
Closed

MapBox Provider issue issue? #178

devs-ryan opened this issue Jul 27, 2020 · 5 comments
Assignees

Comments

@devs-ryan
Copy link

devs-ryan commented Jul 27, 2020

General Information

GeocoderLaravel Version:
Laravel Version: 6.18.27
PHP Version: 7.4.5
Operating System and Version: Homestead box

Issue Description

[describe what is going wrong in plain english]

Steps to Replicate

  • install package
  • publish config file (contents below)
  • set map box key in .env
  • clear cash and config
  • php artisan tinker
  • app('geocoder')->geocode('Los Angeles, CA')->get();
<?php

use Geocoder\Provider\Chain\Chain;
use Geocoder\Provider\Mapbox\Mapbox;
use Http\Client\Curl\Client;

return [
    'cache' => [
        'store' => null,
        'duration' => 9999999,
    ],
    'providers' => [
        Chain::class => [
            Mapbox::class => [
                env('MAPBOX_LOCALE', 'en-US'),
                env('MAPBOX_ACCESS_TOKEN'),
            ]
        ],
    ],
    'adapter'  => Client::class,
    'reader' => null,
];
### Stack Trace
[2020-07-27 13:50:02] local.ALERT: Provider "{providerName}" could not geocode address: "{address}". {"exception":"[object] (Geocoder\\Exception\\InvalidCredentials(code: 0):  at /home/vagrant/code/vendor/geocoder-php/common-http/Provider/AbstractHttpProvider.php:91)
[stacktrace]
#0 /home/vagrant/code/vendor/geocoder-php/common-http/Provider/AbstractHttpProvider.php(63): Geocoder\\Http\\Provider\\AbstractHttpProvider->getParsedResponse()
#1 /home/vagrant/code/vendor/geocoder-php/mapbox-provider/Mapbox.php(269): Geocoder\\Http\\Provider\\AbstractHttpProvider->getUrlContents()
#2 /home/vagrant/code/vendor/geocoder-php/mapbox-provider/Mapbox.php(202): Geocoder\\Provider\\Mapbox\\Mapbox->fetchUrl()
#3 /home/vagrant/code/vendor/geocoder-php/chain-provider/Chain.php(71): Geocoder\\Provider\\Mapbox\\Mapbox->geocodeQuery()
#4 /home/vagrant/code/vendor/willdurand/geocoder/ProviderAggregator.php(67): Geocoder\\Provider\\Chain\\Chain->geocodeQuery()
#5 /home/vagrant/code/vendor/willdurand/geocoder/ProviderAggregator.php(96): Geocoder\\ProviderAggregator->geocodeQuery()
#6 /home/vagrant/code/vendor/toin0u/geocoder-laravel/src/ProviderAndDumperAggregator.php(193): Geocoder\\ProviderAggregator->geocode()
#7 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Cache/Repository.php(383): Geocoder\\Laravel\\ProviderAndDumperAggregator->Geocoder\\Laravel\\{closure}()
#8 /home/vagrant/code/vendor/toin0u/geocoder-laravel/src/ProviderAndDumperAggregator.php(195): Illuminate\\Cache\\Repository->remember()
#9 /home/vagrant/code/vendor/toin0u/geocoder-laravel/src/ProviderAndDumperAggregator.php(93): Geocoder\\Laravel\\ProviderAndDumperAggregator->cacheRequest()
#10 /home/vagrant/code/vendor/psy/psysh/src/ExecutionLoopClosure.php(55) : eval()'d code(1): Geocoder\\Laravel\\ProviderAndDumperAggregator->geocode()
#11 /home/vagrant/code/vendor/psy/psysh/src/ExecutionLoopClosure.php(55): eval()
#12 /home/vagrant/code/vendor/psy/psysh/src/ExecutionClosure.php(96): Psy\\{closure}()
#13 /home/vagrant/code/vendor/psy/psysh/src/Shell.php(370): Psy\\ExecutionClosure->execute()
#14 /home/vagrant/code/vendor/psy/psysh/src/Shell.php(341): Psy\\Shell->doInteractiveRun()
#15 /home/vagrant/code/vendor/symfony/console/Application.php(147): Psy\\Shell->doRun()
#16 /home/vagrant/code/vendor/psy/psysh/src/Shell.php(316): Symfony\\Component\\Console\\Application->run()
#17 /home/vagrant/code/vendor/laravel/tinker/src/Console/TinkerCommand.php(80): Psy\\Shell->run()
#18 [internal function]: Laravel\\Tinker\\Console\\TinkerCommand->handle()
#19 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(32): call_user_func_array()
#20 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Container/Util.php(37): Illuminate\\Container\\BoundMethod::Illuminate\\Container\\{closure}()
#21 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(90): Illuminate\\Container\\Util::unwrapIfClosure()
#22 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Container/BoundMethod.php(34): Illuminate\\Container\\BoundMethod::callBoundMethod()
#23 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Container/Container.php(590): Illuminate\\Container\\BoundMethod::call()
#24 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Console/Command.php(134): Illuminate\\Container\\Container->call()
#25 /home/vagrant/code/vendor/symfony/console/Command/Command.php(255): Illuminate\\Console\\Command->execute()
#26 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Console/Command.php(121): Symfony\\Component\\Console\\Command\\Command->run()
#27 /home/vagrant/code/vendor/symfony/console/Application.php(1000): Illuminate\\Console\\Command->run()
#28 /home/vagrant/code/vendor/symfony/console/Application.php(271): Symfony\\Component\\Console\\Application->doRunCommand()
#29 /home/vagrant/code/vendor/symfony/console/Application.php(147): Symfony\\Component\\Console\\Application->doRun()
#30 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Console/Application.php(93): Symfony\\Component\\Console\\Application->run()
#31 /home/vagrant/code/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(131): Illuminate\\Console\\Application->run()
#32 /home/vagrant/code/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle()
#33 {main}
","providerName":"mapbox","address":"Los Angeles, CA"} 
@mikebronner
Copy link
Member

@raysirsharp Can you please provide the GeocoderLaravel package version as defined in your composer.lock file? I just pushed release 4.3.4 that should address this.

@devs-ryan
Copy link
Author

Thanks for the quick response. I did have 4.3.0 and just updated to 4.3.4. Still getting the same error. @mikebronner

@mikebronner
Copy link
Member

mikebronner commented Jul 27, 2020

@raysirsharp thanks for getting back to me. Looks like this is an issue with the MapBox Provider credentials, according to the exception. Can you try with Google, and see if it works there? I'm thinking this is down to your Mapbox configuration.

I believe you need to pass in the arguments for the MapBox Provider as follows:

<?php

use Geocoder\Provider\Chain\Chain;
use Geocoder\Provider\Mapbox\Mapbox;
use Http\Client\Curl\Client;

return [
    'cache' => [
        'store' => null,
        'duration' => 9999999,
    ],
    'providers' => [
        Chain::class => [
            Mapbox::class => [
                env('MAPBOX_ACCESS_TOKEN'),
                // country
            ]
        ],
    ],
    'adapter'  => Client::class,
    'reader' => null,
];

Please reference the MapBox Provider code: https://github.com/geocoder-php/mapbox-provider/

@devs-ryan
Copy link
Author

devs-ryan commented Jul 27, 2020

@mikebronner you are right, switching the order fixed it, like this:
Mapbox::class => [
env('MAPBOX_ACCESS_TOKEN'),
env('MAPBOX_LOCALE', 'us')
],

Thanks for the help!

@mikebronner
Copy link
Member

@raysirsharp awesome, glad you got it working! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants