This article describes how PHP calculates the maximum and minimum latitude and longitude of the current coordinate in four corners within 3 kilometers. it involves PHP mathematical computation related skills and has some reference value, for more information about how to use PHP to calculate the maximum and minimum latitude and longitude of Four Corners within 3 kilometers, see the example in this article. We will share this with you for your reference. The details are as follows:
// $ Lng, $ lat longitude and latitude $ half = 6371; $ distance = 3; // 3 km $ dlng = 2 * asin (sin ($ distance/(2 * $ half)/cos (deg 2rad ($ 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 ));