You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

47 lines
1.6 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<?php
namespace tencent\map;
class Travel extends Base
{
/**
* 批量距离计算
* @param string $from 起点坐标,格式: lat,lng[,heading];lat,lng[,heading]…
* @param string $to 终点坐标格式lat,lng;lat,lng...
* @param string $mode 计算方式driving驾车、walking步行 默认driving
* @date 2021-02-04
*/
public function getDistance($from, $to, $mode = 'driving')
{
$key = $this->config['key'];
$url = $url = $this->url . "distance/v1/matrix?mode=$mode&from=$from&to=$to&key=$key";
$result = http_data_get($url);
return $result;
}
/**
* 路线规划(驾车/公交/步骑)
* @param string $from 起点位置坐标格式from=40.034852,116.319820
* @param string $to 终点位置坐标格式lat,lng to=39.771075,116.351395
* @param string $mode 计算方式driving驾车、walking步行、骑行bicycling、公交transit 默认driving
* @param string $waypoints 途经点格式lat1,lng1;lat2,lng2;… 最大支持16个
* @param string $other_param 其他参数拼接
* @date 2021-02-04
*/
public function getTravelRoute($from, $to, $mode = 'driving', $waypoints = '', $other_param = '')
{
$key = $this->config['key'];
$waypoints_param = !empty($waypoints) ? '&waypoints=' . $waypoints : ''; //拼接waypoints参数
$url = $this->url . "direction/v1/$mode/?from=$from&to=$to&key=$key$waypoints_param&$other_param";
$result = http_data_get($url);
return $result;
}
}