当前位置:网站首页>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
边栏推荐
- mysql密码过期的方法
- excel快速自动填充空白单元格上一行的内容
- leetcode刷题之x的算术平方根
- Navicat 连接 oracle library is not loaded的解决方法
- 百度地图案例-修改地图样式
- C language structure specifying initialization
- 数据可视化百度地图进一步优化
- Leak detection and vacancy filling (III)
- TP5中的getField()方法变化,tp5获取单个字段值
- Counts the number of occurrences of each character in the string
猜你喜欢
随机推荐
ASP.NET CORE配置选项(下篇)
Navicat 连接 oracle library is not loaded的解决方法
【ORACLE与mysql的区别】
PHP 无限极分类和树形
百度地图基础案例
js查找字符串中出现了三次的字符
excel里有文字的数字怎么从小到大排序,而不是首数字排序
leetcode刷题之x的算术平方根
元编程,代理Proxy与反射Reflect
Parse PSD files and map them into components
DNA reveals surprise ancestry of mysterious Chinese mummies
几款笔记软件的优缺点
Scientists say Australian plan to cull up to 10,000 wild horses doesn’t go far enough
thinkphp5 ---- object(think\response\Json)转数组
1-3 组件与模块
数据可视化百度地图进一步优化
ASP.NET CORE3.1 Identity注册用户后登录失败的解决方案
启用AHCI后无法启动系统
Leak detection and vacancy filling (III)
条形码与二维码的生成









