This package allows you to use get simple the duration and distance between two addresses by the Google Distance Matrix API
This package requires PHP 7.2 and Laravel 5.8 or higher.
composer require programic/laravel-distance-matrix
use \Programic\DistanceMatrix\DistanceMatrix
class DistanceController {
public function index(DistanceMatrix $distanceMatrix)
{
$response = $distanceMatrix->from($from)->to($to)->calculate();
$distance = $response->toArray();
}
}
See the Exceptions folder for more information. Except for the InvalidKeyException, these Exceptions are all taken from the Google Distance Matrix API documentation.
use Programic\DistanceMatrix\Exceptions\InvalidKeyException;
use Programic\DistanceMatrix\Exceptions\InvalidRequestException;
use Programic\DistanceMatrix\Exceptions\MaxDimensionsExceededException;
use Programic\DistanceMatrix\Exceptions\MaxElementsExceededException;
use Programic\DistanceMatrix\Exceptions\OverDailyLimitException;
use Programic\DistanceMatrix\Exceptions\OverQueryLimitException;
use Programic\DistanceMatrix\Exceptions\RequestDeniedException;
use Programic\DistanceMatrix\Exceptions\UnknownErrorException;
composer test
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security-related issues, please email [email protected] instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.