skelviny / google-distance-matrix
谷歌距离矩阵API - 估算多个起点和终点的旅行时间和距离。
dev-master
2023-12-12 13:17 UTC
Requires
- php: >=7.0
- guzzlehttp/guzzle: ^7.8
This package is auto-updated.
Last update: 2024-09-12 15:03:18 UTC
README
估算多个终点的旅行时间和距离。
要求
需要PHP 7.0或更高版本。
安装
安装cirovargas/google-distance-matrix的最佳方式是使用Composer
$ composer require cirovargas/google-distance-matrix
入门
$distanceMatrix = new GoogleDistanceMatrix('YOUR API KEY'); $distance = $distanceMatrix->setLanguage('cs') ->addOrigin('49.950096, 14.668544') ->addOrigin('49.950096, 15.668544') ->addDestination('50.031817, 14.490880') ->addDestination('51.031817, 14.490880') ->sendRequest();
$distanceMatrix = new GoogleDistanceMatrix('YOUR API KEY'); $distance = $distanceMatrix ->setOrigin('K Habrovci 447, 251 63 Strančice, Česká republika') ->setDestination('Roztylská 2321/19, Chodov, 148 00 Praha-Praha 11, Česká republika') ->setMode(GoogleDistanceMatrix::MODE_WALKING) ->setLanguage('en-US') ->setUnits(GoogleDistanceMatrix::UNITS_IMPERIAL) ->setAvoid(GoogleDistanceMatrix::AVOID_HIGHWAYS) ->sendRequest();
更多信息,请访问 https://developers.google.com/maps/documentation/distance-matrix/