Home >Backend Development >PHP Tutorial >PHP Tencent map longitude and latitude conversion to Baidu map longitude and latitude implementation ideas and examples sharing

PHP Tencent map longitude and latitude conversion to Baidu map longitude and latitude implementation ideas and examples sharing

黄舟
黄舟Original
2017-08-21 17:33:003703browse

I recently used Tencent Maps and encountered a small problem. The longitude and latitude of the user are determined based on the location entered by the user. The longitude and latitude provided by Baidu is its own unique set, which is different from those of Google and Tencent, so it is involved. Regarding the problem of latitude and longitude conversion, today I will introduce to you the PHP Tencent Map Longitude and Latitude Conversion to Baidu Map Longitude and Latitude class, which can convert the longitude and latitude of Baidu Map to the corresponding longitude and latitude of Tencent Map/Google.

First download what we need for this course PHP Tencent map longitude and latitude to Baidu map longitude and latitude class: http://www.php.cn/xiazai/leiku/642

After the download is complete, find the php class file we need, unzip it to our local directory, and create New php file!

After completion, we need to call this class in the new php file and instantiate the class:

<?php
include_once "baiduditu.php";//引入类文件
$lat=116.420079;
$lng=39.998117;
//中国正常GCJ02坐标---->百度地图BD09坐标
print_r($obj = Convert_GCJ02_To_BD09($lat,$lng));
echo "<br>";
//百度地图BD09坐标---->中国正常GCJ02坐标
print_r($obj = Convert_BD09_To_GCJ02($lat,$lng));

?>

The running result is as shown below:

PHP Tencent map longitude and latitude conversion to Baidu map longitude and latitude implementation ideas and examples sharing

The above is the detailed content of PHP Tencent map longitude and latitude conversion to Baidu map longitude and latitude implementation ideas and examples sharing. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn