腾讯地图和百度地图的PHP相互转换
生活随笔
收集整理的這篇文章主要介紹了
腾讯地图和百度地图的PHP相互转换
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/**
* 百度地圖---->騰訊地圖
* @param double $lat 緯度
* @param double $lng 經度
* @return array();
*/
function Convert_BD09_To_GCJ02($lat,$lng){$x_pi = 3.14159265358979324 * 3000.0 / 180.0;$x = $lng - 0.0065;$y = $lat - 0.006;$z = sqrt($x * $x + $y * $y) - 0.00002 * sin($y * $x_pi);$theta = atan2($y, $x) - 0.000003 * cos($x * $x_pi);$lng = $z * cos($theta);$lat = $z * sin($theta);return array('lng'=>$lng,'lat'=>$lat);
}/**
* 騰訊地圖---->百度地圖
* @param double $lat 緯度
* @param double $lng 經度
*/
function Convert_GCJ02_To_BD09($lat,$lng){$x_pi = 3.14159265358979324 * 3000.0 / 180.0;$x = $lng;$y = $lat;$z =sqrt($x * $x + $y * $y) + 0.00002 * sin($y * $x_pi);$theta = atan2($y, $x) + 0.000003 * cos($x * $x_pi);$lng = $z * cos($theta) + 0.0065;$lat = $z * sin($theta) + 0.006;return array('lng'=>$lng,'lat'=>$lat);
}
?
轉載于:https://www.cnblogs.com/yuan9580/p/10083071.html
總結
以上是生活随笔為你收集整理的腾讯地图和百度地图的PHP相互转换的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 简单的sql注入
- 下一篇: Sql Server XML