PHP uses Tencent Map to obtain the coordinates of the specified address: longitude and latitude (image, text + video)

藏色散人
Release: 2018-10-20 15:16:59
Original
8379 people have browsed it

This article mainly introduces to you the specific method of PHP using Tencent Map to obtain the coordinates of a specified address.

In the previous article [How to create a key using Tencent Map to obtain the specified address coordinates using PHP], we have already introduced to you how to apply to create a key (developer key). So below we will combine specific code examples to introduce in detail how PHP uses Tencent Maps to obtain specified coordinates, that is, longitude and latitude.

result->location;
echo "经度:".$location->lng."
";// 经度 echo "纬度:".$location->lat."
";// 纬度
Copy after login

Here we define an address $address and a link $url. It should be noted that there are two important parameters in this link, one is the defined $address, and the other is the key created by ourselves (development or key). Then initialize the cURL session through the curl_init function in PHP, and use the curl_setopt function to set the cURL transfer options. Then use the curl_exec function to execute the cURL session.

Then we convert the obtained url data into json format through the json_decode function.

Finally we can get the corresponding location coordinates.

Access through the browser, the result is as follows:

PHP uses Tencent Map to obtain the coordinates of the specified address: longitude and latitude (image, text + video)

As shown in the figure, we obtain the longitude and latitude of the specified address.

This article is about the specific method of using Tencent Maps to obtain specified coordinates in PHP. It is also very simple, so I hope it will be helpful to friends in need!

If you want to know more about PHP, you can follow the PHP Chinese website PHP Video Tutorial, everyone is welcome to refer to and learn!

The above is the detailed content of PHP uses Tencent Map to obtain the coordinates of the specified address: longitude and latitude (image, text + video). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!