当前位置:网站首页>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
边栏推荐
猜你喜欢
随机推荐
C# webpai 路由详解
.Net Core 下使用 Quartz —— 【1】快速开始
1-2 NodeJS的特点
Aperçu de Redux
手动实现简单的Promise及其基础功能
深入理解控制反转和依赖注入
excel快速自动填充空白单元格上一行的内容
1-3 NodeJS的安装之清单配置与跑项目环境
.Net Core 下使用 Quartz —— 【4】作业和触发器之作业属性和异常
window环境下使用小皮面板安装redis
Leak detection and vacancy filling (IV)
Wildcards and special symbols for shell scripts
Overview of node file system and buffer
Node accesses server-side static resources
Add serial number to El table
Promise(四)
DNA reveals surprise ancestry of mysterious Chinese mummies
CentOS8搭建PHP8.0.3运行环境
百度地图3D旋转和倾斜角度的调整
柯里化实现函数连续调用计算累加和