finalbytes / google-distance-matrix-api
Google距离矩阵API - 估算多个目的地的旅行时间和距离。
dev-master
2019-06-07 13:53 UTC
Requires
- php: >=7.1
- guzzlehttp/guzzle: ^6.2
This package is not auto-updated.
Last update: 2024-09-24 23:00:49 UTC
README
估算多个目的地的旅行时间和距离。
需求
需要PHP 7.1或更高版本。
安装
安装finalbytes/google-distance-matrix-api的最佳方式是使用Composer
$ composer require finalbytes/google-distance-matrix-api
入门
$distanceMatrix = new GoogleDistanceMatrix('YOUR API KEY'); $distance = $distanceMatrix ->setLanguage('nl-NL') ->addOrigin('51.458428,6.0541768') ->addDestination('48.139212,11.581721') ->addDestination('36.721184,-4.420084') ->sendRequest();
$distanceMatrix = new GoogleDistanceMatrix('YOUR API KEY'); $distance = $distanceMatrix ->addOrigin('Van Bronckhorststraat 94, 5961SM Horst, The Netherlands') ->addDestination('Maistraße 10, 80337 München, Deutschland') ->setMode(GoogleDistanceMatrix::MODE_DRIVING) ->setLanguage('nl-NL') ->setUnits(GoogleDistanceMatrix::UNITS_METRIC) ->setAvoid(GoogleDistanceMatrix::AVOID_FERRIES) ->sendRequest();
更多信息,请访问 https://developers.google.com/maps/documentation/distance-matrix/