1. Go to this page and download the library: Download preee/google-directions library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
preee / google-directions example snippets
php
$apikey = 'my-google-apikey';
$gd = new Palmabit\GoogleDirections\GoogleDirections($apikey);
php
GoogleDirections::setApikey($apikey);
$gd = new GoogleDirections();
php
/*
* Example of API call:
* https://maps.googleapis.com/maps/api/directions/json?origin=Milano&destination=Venezia&key=my-google-apikey
*
* with a timeout of 40s, defaults to 30s if empty
*/
$direction = $gd
->createDirectionAPI()
->setTimeout(4000)
->setOrigin('Milano')
->setDestination('Verona')
->call();
/*
* now you can use all $direction methods
* see above for detailed lists
*/
//get the status
$status = $direction->getStatus();
//get the distance between Milan and Venice
$distance = $direction->getDistance();
//get summary
$summary = $direction->getSummary();
//get steps
$steps = $direction->getSteps();
//get duration
$duration = $direction->getDuration();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.