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) );
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.