Example of PHP calculation of the maximum and minimum longitude and latitude of 4 corners within 3 kilometers of the current coordinates

WBOY
Release: 2016-07-29 09:01:12
Original
1055 people have browsed it

The example in this article describes the PHP method of calculating the maximum and minimum longitude and latitude of 4 corners within 3 kilometers of the current coordinates. Share it with everyone for your reference, the details are as follows:

//$lng 、$lat 经纬度    
$half = 6371;
    $distance = 3; //3公里 
    $dlng = 2 * asin(sin($distance / (2 * $half)) / cos(deg2rad($lat)));
    $dlng = rad2deg($dlng);
    $dlat = $distance / $half;
    $dlat = rad2deg($dlat);
    $fourpoint = array(
      'left-top' => array('lat' => $lat + $dlat, 'lng' => $lng - $dlng),
      'right-top' => array('lat' => $lat + $dlat, 'lng' => $lng + $dlng),
      'left-bottom' => array('lat' => $lat - $dlat, 'lng' => $lng - $dlng),
      'right-bottom' => array('lat' => $lat - $dlat, 'lng' => $lng + $dlng)
);

Copy after login

Readers who are interested in more PHP related content can check out the special topics of this site: "php date and time usage summary", "php object-oriented programming introductory tutorial", "Summary of PHP String Usage", "Introduction Tutorial on PHP+MySQL Database Operation" and "Summary of Common PHP Database Operation Skills"

I hope this article will be helpful to everyone in PHP programming.

The above introduces the example of PHP calculating the maximum and minimum longitude and latitude of 4 corners within 3 kilometers of the current coordinates, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
php
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!