I'm planning a custom WordPress theme where the Custom Post Type (CPT) will have latitude and longitude coordinate as it's meta value. The latitude and longitude will be displayed as a Marker in a Google Map.
So far I don't have any problem in showing the Google Map and the CPT as it's Marker. That is if I query the CPT using the default order.
The problem occurs when I need n CPTs that is closest to a coordinate whether it is current user position or a location clicked on the map. Another situation is to query all CPTs that is in x km radius of a coordinate.
The question is : How do I query posts based on latitude-longitude value that is saved on the post meta?
I'm not really sure how to do it, but I think the latitude and longitude value should be saved in a separate custom field.
Thank you in advance.