I have different vendors saved with their own latitudinal and longitudinal positions in my database.
I then use google maps to pin point them on a map, however you also have a search function where you can input any address you want with a 5/10/20 km/miles "around".
So for example when i search London and 10 km around, i would expect to get all the vendors from the london returned lat and long + 10km around that point.
right now i have the function worked out with a slight difference (obviously without the radius option)
private function findServicesNearLocation($filter = array(), $lat, $lng) {
// set radius
$difference = 0.07;
// build filter
$latitude_from = floatval($lat) - $difference;
$latitude_to = floatval($lat) + $difference;
$longitude_from = floatval($lng) - $difference;
$longitude_to = floatval($lng) + $difference;
$filter[] = "a.gps_latitude >= {$latitude_from}";
$filter[] = "a.gps_latitude <= {$latitude_to}";
$filter[] = "a.gps_longitude >= {$longitude_from}";
$filter[] = "a.gps_longitude <= {$longitude_to}";
// return services
return $this->vendors->getVendors(implode(' AND ', $filter));
}
How would i have to change the above function to make an appropriate estimate and to select all the vendors from a specific "10 km around" those lat and long.
Thank you