Skip to content

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

License

Notifications You must be signed in to change notification settings

iAlex97/google-distance-matrix

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Google Distance Matrix API

Estimate travel time and distance for multiple destinations.

Requirements

Requires PHP 7.0 or higher.

Installation

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

$ composer require ialex97/google-distance-matrix

Getting Started

First of all autoload and then include its namespace:

require __DIR__ . '/vendor/autoload.php';
use IonescuAlex\GoogleDistanceMatrix\GoogleDistanceMatrix;
$distanceMatrix = new GoogleDistanceMatrix('YOUR API KEY');
$distance = $distanceMatrix->setLanguage('en-US')
    ->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();

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

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 100.0%