Skip to content

phpmike/Roadlength

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

MvRoadlength

This API is to calc distance between two points by road.

Install

composer require mv/roadlength

Examples

With postal address

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();

With geoloc coordinates

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();

Enjoy it!

To be continued...

About

Library to calc distance between location by road

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages