mv / roadlength
PHP连接器,用于计算地点间的公路距离
1.0
2020-08-11 08:44 UTC
Requires
- php: >=7.0
This package is auto-updated.
Last update: 2024-09-11 17:50:35 UTC
README
此API用于通过公路计算两点之间的距离。
安装
composer require mv/roadlength
示例
使用邮政地址
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();
享受它!
待续...