PHP code example of mv / roadlength

1. Go to this page and download the library: Download mv/roadlength 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/ */

    

mv / roadlength example snippets


use Mv\RoadLength\Api\HereApi;
use Mv\RoadLength\Geo\Location;
use Mv\RoadLength\Geo\Distance;

$hereApi = new HereApi('---Your HERE API KEY---');

$origin = Location::createByAddress('mairie de hyeres 83400 HYERES', $hereApi);
$destination = Location::createByAddress('mairie de sollies-toucas 83210 SOLLIES-TOUCAS', $hereApi);

$distance = new Distance($hereApi);
$distance->setStartLocation($origin);
$distance->setEndLocation($destination);

$distanceInMeters = $distance->getDistance();

use Mv\RoadLength\Api\HereApi;
use Mv\RoadLength\Geo\Location;
use Mv\RoadLength\Geo\Distance;

$hereApi = new HereApi('---Your HERE API KEY---');

$origin = Location::createByCoords(43.119840, 6.129904);
$destination = Location::createByCoords(43.206368, 6.026157);

$distance = new Distance($hereApi);
$distance->setStartLocation($origin);
$distance->setEndLocation($destination);

$distanceInMeters = $distance->getDistance();