Well, there is a pretty confusing way to get the points which are in the radius of another point.
$center_lat = $_GET["lat"]; //insert the lat of where you are
$center_lng = $_GET["lng"]; //insert the lng of where you are
$radius = $_GET["radius"]; //insert the radius of KM that you want to search
$multiplier=3959; //miles
$multiplier=($multiplier*1.609344); //use km instead
$users = get_users(array('meta_query' => array(
array(
'key' => 'latitude',
'value' => 'XXX', //insert a value just to be safe about https://core.trac.wordpress.org/ticket/23268
'compare' => 'EXISTS'
)
)
));
//now we got all our users that have latitude (i assume they also have longitude ^^)
$nearbyusers = array();
foreach($users as $user){
$lat = get_user_meta($user->ID,'latitude',TRUE); //assuming the user latitude is a meta field named "latitude"
$lng = get_user_meta($user->ID,'longitude',TRUE); //assuming the user longitude is a meta field named "longitude"
$distance = ( $multiplier * acos( cos( deg2rad($center_lat) ) * cos( deg2rad( $lat ) ) * cos( deg2rad( $lng ) - deg2rad($center_lng) ) + sin( deg2rad($center_lat) ) * sin( deg2rad( $lat ) ) ) );
if($distance<$radius) {
$nearbyusers[] = $user;
}
}
//now all near by users are in the array $nearbyusers. Do stuff with it! ;)
Happy Coding,
Kuchenundkakao