PHP calculates the maximum and minimum longitude and latitude of the four corners in the current coordinate 3 km. The current longitude and latitude
This article describes how PHP calculates the maximum, minimum, latitude, and longitude of the four corners within 3 kilometers of the current coordinate. 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 ));