The example in this article describes the PHP method of calculating the maximum and minimum longitude and latitude of four 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: "Summary of PHP date and time usage", "PHP object-oriented programming introductory tutorial", "php string (string) usage summary", "php mysql database operation introductory tutorial" and "php common database operation skills summary"
I hope this article will be helpful to everyone in PHP programming.