insight-media/google-distance-matrix-api

Google距离矩阵API - 为多个目的地估算旅行时间和距离。

dev-master 2021-04-22 13:42 UTC

This package is auto-updated.

Last update: 2024-09-27 01:43:56 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/