// /**
// * @date:2017-07-12 10:57
// * @auth:百度地圖文檔
// * 百度坐標系轉換成標准GPS坐系
// * @param float $lnglat 坐標(如:106.426, 29.553404)
// * @return string 轉換后的標准GPS值:
// */
function BD09LLtoWGS84($lnglat){ // 經度,緯度
$lnglat = explode(',', $lnglat);
list($x,$y) = $lnglat;
$Baidu_Server = "http://api.map.baidu.com/ag/coord/convert?from=0&to=4&x={$x}&y={$y}";
$result = @file_get_contents($Baidu_Server);
$json = json_decode($result);
if($json->error == 0){
$bx = base64_decode($json->x);
$by = base64_decode($json->y);
$GPS_x = 2 * $x - $bx;
$GPS_y = 2 * $y - $by;
return $GPS_x.','.$GPS_y;//經度,緯度
}else{
return $lnglat;
}
}