I am using Wordpress ACF plugin, and there's a field type of Google Map. It stored the Lat,Long and Address.
Now, i have some user's latitude and longitude. I need a way to get only the objects that are no more than 10km in distance.
This is a server Wordpress question. For now, i am simply getting ALL the gyms i wanted instead of only the nearest (10 km maximum) gym around the user current position. There is a field called "gym_location" which is a Google Map type. The problem is, i don't know the math formula.
// get all objects
$query_for_ojektaxi_user = new WP_Query( array(
'post_type' => 'gyms',
'meta_query' => array(
array(
'key' => 'open_or_closed',
'value' => 1,
'compare' => '=',
)
)
));
You won't be able to make direct (and useful) use of lng or lat "subfields" of the googlemap advanced custom field inside the SQL query. The values are serialized in the mysql "meta_value" (text) column of the post_meta table.