valerian/google-distance-matrix

Google distance matrix API - Estimate travel time and distance for multiple destinations.

v0.0.1 2016-12-02 15:49 UTC

This package is not auto-updated.

Last update: 2024-04-22 11:45:09 UTC


README

Estimate travel time and distance for multiple destinations.

Requirements

Requires PHP 5.5.0 or higher.

Installation

The best way to install valerian/google-distance-matrix is using Composer:

$ composer require valerian/google-distance-matrix

Getting Started

$distanceMatrix = new GoogleDistanceMatrix('YOUR API KEY');
$distance = $distanceMatrix->setLanguage('cs')
    ->setOrigin('49.950096, 14.668544')
    ->setDestination('50.031817, 14.490880')
    ->sendRequest();
$distanceMatrix = new GoogleDistanceMatrix('YOUR API KEY');
$distance = $distanceMatrix->setLanguage('cs')
    ->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-GB')
    ->setUnits(GoogleDistanceMatrix::UNITS_IMPERIAL)
    ->setAvoid(GoogleDistanceMatrix::AVOID_HIGHWAYS)
    ->sendRequest();

For more info, please visit https://developers.google.com/maps/documentation/distance-matrix/