codingphase/google-distance

谷歌距离矩阵API - 估计多个目的地的旅行时间和距离。

v1.0.1 2019-05-15 14:10 UTC

This package is not auto-updated.

Last update: 2024-09-13 15:06:42 UTC


README

估计多个目的地的旅行时间和距离。

需求

需要PHP 7.0或更高版本。

安装

安装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/