Home PHP Libraries Other libraries Convert Tencent map longitude and latitude to Baidu map longitude and latitude PHP class
Convert Tencent map longitude and latitude to Baidu map longitude and latitude PHP class
<?php
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);
}
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);
}
?>

China's normal GCJ02 coordinates---->Baidu map BD09 coordinates

Tencent map also uses GCJ02 coordinates

@param double $lat latitude

@ param double $lng Longitude

Baidu map BD09 coordinates---->China normal GCJ02 coordinates

Tencent map also uses GCJ02 coordinates

@param double $lat latitude

@param double $lng longitude

@return array();



Disclaimer

All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn

Related Article

Baidu map event processing--getting the latitude and longitude (simple use of Baidu map)_html/css_WEB-ITnose Baidu map event processing--getting the latitude and longitude (simple use of Baidu map)_html/css_WEB-ITnose

24 Jun 2016

Baidu Map event processing--getting the latitude and longitude (Baidu Map is simple to use)

How Do I Link Static Libraries That Depend on Other Static Libraries? How Do I Link Static Libraries That Depend on Other Static Libraries?

13 Dec 2024

Linking Static Libraries to Other Static Libraries: A Comprehensive ApproachStatic libraries provide a convenient mechanism to package reusable...

How to Silence TensorFlow\'s Debugging Output? How to Silence TensorFlow\'s Debugging Output?

28 Oct 2024

Suppression of Tensorflow Debugging OutputTensorflow prints extensive information about loaded libraries, found devices, and other debugging data...

How Does jQuery Simplify DOM Manipulation for Web Developers? How Does jQuery Simplify DOM Manipulation for Web Developers?

03 Jan 2025

Overflow: Hidden and Expansion of HeightjQuery distinguishes itself from other JavaScript libraries through its cross-platform compatibility and...

Which native Java image processing library is right for you? Which native Java image processing library is right for you?

30 Oct 2024

Native Java Image Processing Libraries for High-Quality ResultsAs you have encountered limitations with ImageMagick and JAI, let's explore other...

How to Execute Command Line Binaries in Node.js? How to Execute Command Line Binaries in Node.js?

27 Dec 2024

Executing Command Line Binaries in Node.jsExecuting third-party binaries is an essential task when porting CLI libraries from other languages to...

See all articles