The implementation principle first calculates the four points of the rectangle around the point, and then uses latitude and longitude to directly match the records in the database. //get around coordinates public function returnsquarepoint ($lng, $lat, $ distance = 0.5) { $earthRadius = 6378138; $dlng = 2 * asin (sin ($ distance / (2 * $earthRadius)) / cos (Deg2rad ($lat))); $dlng = rad2deg ($dlng); $dlat = $distance/$earthRadius; $dlat = rad2deg ( $dlat); return array ( ' Left-top ' =>array (' lat ' = $lat + $dlat, ' lng ' = $lng-$dlng),      &NBsp; ' Right-top ' =>array (' lat ' = = $lat + $dlat, ' LNG ' + ' $dlng $lng, ' Left-bottom ' =>array (' lat ' = $lat - $dlat, ' lng ' = $lng - $ DLNG), ' Right-bottom ' =>array (' lat ' = $lat - $dlat, ' lng ' = $LNG + $dlng) ); } Calculates a straight line distance of two coordinates public function getdistance ($lat 1, $lng 1, $lat 2, $lng 2) { $earthRadius = 6378138; //approximate earth radius meters // convert to radians $lat 1 = ($lat 1 * pi ()) / 180; $lng 1 = ($lng 1 * pi ()) / 180; $lat 2 = ($lat 2 * pi ()) / 180; $lng 2 = ($ Lng2 * pi ()) / 180; // Use the semi-normal vector formula calculate $calcLongitude with ruler gauges = $lng 2 - $lng 1; $calcLatitude = $lat 2 - $lat 1; $stepOne = pow (sin ($ CALCLATITUDE / 2), 2) + cos ($lat 1) * cos ($lat 2) * pow (sin ($calcLongitude / 2),  2); $stepTwo = 2 * asin (min (1,  SQRT ($stepOne))); $calculatedDistance = $earthRadius * $stepTwo; return round ($calculatedDistance); }
PHP uses a given latitude and longitude point to make a nearby location query – the rational use of the algorithm