百度地圖坐標轉化為GPS坐標


// /**
// * @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;
}
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM