I have stored latitude and longitude again each Company's address in database. I have to show those Company record that comes under certain miles.
For example:
I search on City,State,Country and get the latitude and longitude using Google Map API. Then I get the distance using below code latitude longitude by adding subtracting.
$difference = 0.07;
$distance=$distanceKilometers!=0?ceil($this->miles2kms($distanceKilometers)/111):0;
latitude_from = floatval($lat) - $difference - $distance;
$latitude_to = floatval($lat) + $difference + $distance;
$longitude_from = floatval($lng) - $difference - $distance;
$longitude_to = floatval($lng) + $difference + $distance;
It does not work for me as It show lot of company records that does not come under N miles.
Could any one help me on this to get fix this issue? as I'm trying to fix since last 2 days and have tried many solutions available on different forums