1. Go to this page and download the library: Download martijnoud/distancematrix 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/ */
martijnoud / distancematrix example snippets
use MartijnOud\DistanceMatrix\DistanceMatrix;
$distanceMatrix = new DistanceMatrix(YOUR_API_KEY_HERE);
$distance = $distanceMatrix->distance([
'origins' => 'Prof. van der Waalsstraat 2 Alkmaar',
'destinations' => 'Paleis Noordeinde Den Haag'
]);
if ($distance > 0) {
echo round($distance / 1000, 2) . "km"; // 84.5km
}
use MartijnOud\DistanceMatrix\DistanceMatrix;
$distanceMatrix = new DistanceMatrix(YOUR_API_KEY_HERE);
$distance = $distanceMatrix->distance([
'origins' => 'Leith',
'destinations' => 'Arques',
'mode' => 'walking',
'language' => 'en-GB',
]);
if ($distance > 0) {
echo "I would walk " . $distance * 0.00062137119 . " miles"; // I would walk 493.88322020532 miles
}
use MartijnOud\DistanceMatrix\DistanceMatrix;
$distanceMatrix = new DistanceMatrix();
$image = $distanceMatrix->map([
'origins' => 'Prof. van der Waalsstraat 2 Alkmaar', //
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.