当前位置:网站首页>Baidu map coordinates, Google coordinates and Tencent coordinates are mutually transformed
Baidu map coordinates, Google coordinates and Tencent coordinates are mutually transformed
2022-04-23 06:52:00 【Collect and study by yourself】
<?php
// China Normal GCJ02 coordinate ----> Baidu Maps BD09 coordinate
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);
}
// Baidu Maps BD09 coordinate ----> China Normal GCJ02 coordinate
// Tencent maps also use GCJ02 coordinate
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);
}
?>
版权声明
本文为[Collect and study by yourself]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230555552175.html
边栏推荐
猜你喜欢
随机推荐
SiteServer CMS5.0使用总结
Header内置对象
关于软件的空间占用,安装目录
Thinkphp5 -- object (think \ response \ JSON) to array
WebAPI+Form表单上传文件
2021-09-18
启用AHCI后无法启动系统
freeCodeCamp----prob_calculator练习
freeCodeCamp----arithmetic_arranger练习
Node data flow
EF CORE在ASP.NET CORE项目中基于数据库优先模式生成实体模型
初步认识Promse
file_get_contents 访问 ssl 错误的两种解决方法
Redux概述
Mysql中的索引与视图
WebSocket(基础)
todesk远程控制软件的使用
excel里有文字的数字怎么从小到大排序,而不是首数字排序
.Net Core 下使用 Quartz —— 【2】作业和触发器之初步了解作业
Devexpress Gridview 添加全选列