//计算距离:https://lbs.qq.com/service/webService/webServiceGuide/webServiceDistance
//$url = 'https://apis.map.qq.com/ws/distance/v1/?mode=driving&from=39.983171,116.308479&to=39.996060,116.353455&key=腾讯地图key';
$url = 'https://apis.map.qq.com/ws/distance/v1/?mode=driving&from='.$from_lat.','.$from_lng.'&to='.$to_lat.','.$to_lng.'&key=腾讯地图key';
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_ENCODING ,'gb2312');
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; // 获取数据返回
$result = curl_exec($ch);
curl_close($ch);
$result = json_decode($result);
//print_r($result);
$distance = $result->result->elements[0]->distance;