计算 Google 距离矩阵 API

v1.0.3 2019-09-09 03:39 UTC

This package is auto-updated.

Last update: 2024-09-22 12:53:03 UTC


README

StyleCI

需求

  • PHP >= 7.1.3
  • GuzzleHttp >= 6.3

安装

使用 composer 需要此包。

composer require pnlinh/google-distance

用法

<?php

require_once __DIR__ . '/vendor/autoload.php';

use Pnlinh\GoogleDistance\Factory\GoogleDistance;

$distance = GoogleDistance::make('YOUR_GOOGLE_API_KEY')
                            ->setOrigins('From Address')
                            ->setDestinations('To Address')
                            ->calculate();


echo "Distance value is: ". $distance . PHP_EOL;

测试

composer test

致谢

更多信息,请访问 https://developers.google.com/maps/documentation/distance-matrix/