programic/laravel-distance-matrix

在Laravel中使用Google Distance Matrix

v1.1.0 2023-04-26 06:36 UTC

This package is auto-updated.

Last update: 2024-09-26 09:48:18 UTC


README

Latest Version on Packagist Total Downloads

此软件包允许您通过Google Distance Matrix API轻松获取两个地址之间的距离和时间。

安装

此软件包需要PHP 7.2和Laravel 5.8或更高版本。

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();
    }
    
} 

可用的异常

有关更多信息,请参阅异常文件夹。除InvalidKeyException外,这些异常均来自Google Distance Matrix API文档

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

变更日志

请参阅变更日志以了解最近的变化。

贡献

请参阅贡献指南以获取详细信息。

安全

如果您发现任何安全相关的问题,请通过电子邮件info@programic.com联系,而不是使用问题跟踪器。

鸣谢

许可

MIT许可(MIT)。有关更多信息,请参阅许可文件