if (!function_exists('gdEncrypt')) {
//BD-09(百度)坐标转换成GCJ-02(火星,高德)坐标
//@param $longitude 百度经度
//@param $latitude 百度纬度
function gdEncrypt($longitude, $latitude)
{
$x_pi = 3.14159265358979324 * 3000.0 / 180.0;
$x = $longitude - 0.0065;
$y = $latitude - 0.006;
$z = sqrt($x * $x + $y * $y) - 0.00002 * sin($y * $x_pi);
$theta = atan2($y, $x) - 0.000003 * cos($x * $x_pi);
$longitude = $z * cos($theta);
$latitude = $z * sin($theta);
$data['lng'] = round($longitude, 6);
$data['lat'] = round($latitude, 6);
return $data;
}
}
【PHP】百度转高德经纬度
于 2022-08-24 09:16:28 首次发布