When using a service for business purpose, you will receive a business account from Google. This one allows you to
bypass Google limitation according to your billing plan. In order to use this feature, you will need an
Fungio\GoogleMap\Services\BusinessAccount
:
use Fungio\GoogleMap\Services\BusinessAccount;
$businessAccount = new BusinessAccount('client_id', 'secret');
$clientId = $businessAccount->getClientId();
$businessAccount->setClientId($clientId);
$secret = $businessAccount->getSecret();
$businessAccount->setSecret($secret);
Note that the client identifier is not prefixed by gme-
(it is automatically prepended by the library).
Additionally, you can use channel:
$businessAccount = new BusinessAccount('client_id', 'secret', 'my_channel');
$channel = $businessAccount->getChannel();
$businessAccount->setChannel($channel);
If you want to use the geocoder service with a Google business account, you need to set it on the provider and then, everything is done automatically:
use Fungio\GoogleMap\Services\BusinessAccount;
use Fungio\GoogleMap\Services\Geocoding\Geocoder;
use Fungio\GoogleMap\Services\Geocoding\GeocoderProvider;
use Geocoder\HttpAdapter\CurlHttpAdapter;
$provider = new GeocoderProvider(new CurlHttpAdapter())
$provider->setBusinessAccount(new BusinessAccount('client_id', 'secret'));
$businessAccount = $provider->getBusinessAccount();
$geocoder = new Geocoder();
$geocoder->registerProviders(array($provider));
$response = $geocoder->geocode('1600 Amphitheatre Parkway, Mountain View, CA');
If you want to go back the normal behavior (anonymous), you need to reset the business account to null
:
$geocoder->setBusinessAccount(null);
If you want to use the directions service with a Google business account, you need to set it on the service and then, everything is done automatically:
use Fungio\GoogleMap\Services\BusinessAccount;
$directions->setBusinessAccount(new BusinessAccount('client_id', 'secret'));
$businessAccount = $directions->getBusinessAccount();
$response = $directions->route('Lille', 'Paris')
If you want to go back the normal behavior (anonymous), you need to reset the business account to null
:
$directions->setBusinessAccount(null);
If you want to use the distance matrix service with a Google business account, you need to set it on the service and then, everything is done automatically:
use Fungio\GoogleMap\Services\BusinessAccount;
$distanceMatrix->setBusinessAccount(new BusinessAccount('client_id', 'secret'));
$businessAccount = $distanceMatrix->getBusinessAccount();
$response = $distanceMatrix->process(array('Vancouver BC'), array('San Francisco'));
If you want to go back the normal behavior (anonymous), you need to reset the business account to null
:
$distanceMatrix->setBusinessAccount(null);