百度、腾讯地图坐标系互相转化 2022-07-22百度、腾讯地图坐标系互相转化12345678910111213141516/** * 中国正常GCJ02坐标---->百度地图BD09坐标 * 腾讯地图用的也是GCJ02坐标 * @param double $lat 纬度 * @param double $lng 经度 */function Convert_GCJ02_To_BD09($lng,$lat){ let $x_pi = 3.14159265358979324 * 3000.0 / 180.0; let $x = $lng; let $y = $lat; let $z = Math.sqrt($x $x + $y $y) + 0.00002 * Math.sin($y * $x_pi); let $theta = Math.atan2($y, $x) + 0.000003 * Math.cos($x * $x_pi); $lng = $z * Math.cos($theta) + 0.0065; $lat = $z * Math.sin($theta) + 0.006; return array('lng'=>$lng,'lat'=>$lat);} 1234567891011121314151617/** * 百度地图BD09坐标---->中国正常GCJ02坐标 * 腾讯地图用的也是GCJ02坐标 * @param double $lat 纬度 * @param double $lng 经度 * @return array(); */function Convert_BD09_To_GCJ02($lng,$lat){ let $x_pi = 3.14159265358979324 * 3000.0 / 180.0; let $x = $lng - 0.0065; let $y = $lat - 0.006; let $z = Math.sqrt($x $x + $y $y) - 0.00002 * Math.sin($y * $x_pi); let $theta = Math.atan2($y, $x) - 0.000003 * Math.cos($x * $x_pi); $lng = $z * Math.cos($theta); $lat = $z * Math.sin($theta); return ['lng'=>$lng,'lat'=>$lat];}I'm so cute. Please give me money.Post author: dimsumPost link: http://example.com/2022/07/22/%E7%99%BE%E5%BA%A6%E3%80%81%E8%85%BE%E8%AE%AF%E5%9C%B0%E5%9B%BE%E5%9D%90%E6%A0%87%E7%B3%BB%E4%BA%92%E7%9B%B8%E8%BD%AC%E5%8C%96/Copyright Notice: All articles in this blog are licensed under unless otherwise stated.