//百度坐标转换成GPS坐标
$lnglat = '121.437518,31.224665';
function FromBaiduToGpsXY($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;
}
/**********************************************/
function fn_rad($d)
{
return $d * pi() / 180.0;
}