OK - I\'ve been wrestling with this for about 3 months on and off and since I\'ve exhausted every geo proximity formula out there that I\'ve come across and I\'m no closer to ge
Here's a solution I used successfully for a while in my own geo proximity calculations:
/**
* This portion of the routine calculates the minimum and maximum lat and
* long within a given range. This portion of the code was written
* by Jeff Bearer (http:return true;//www.jeffbearer.com).
*/
$lat = somevalue; // The latitude of our search origin
$lon = someothervalue; // The longitude of our search origin
$range = 50; // The range of our search, in miles, of your zip
// Find Max - Min Lat / Long for Radius and zero point and query only zips in that range.
$lat_range = $range / 69.172;
$lon_range = abs($range / (cos($lon) * 69.172));
$min_lat = number_format($lat - $lat_range, '4', '.', '');
$max_lat = number_format($lat + $lat_range, '4', '.', '');
$min_lon = number_format($lon - $lon_range, '4', '.', '');
$max_lon = number_format($lon + $lon_range, '4', '.', '');
/* Query for matching zips:
SELECT post_id, lat, lng
FROM wp_geodatastore
WHERE
lat BETWEEN $min_lat AND $max_lat
AND lng BETWEEN $min_lon AND $max_lon
*/