0

I want to calculate distance between two places using their post codes.I want to use Google Map API with PHP for this purpose.

So please suggest me how can i do this or suggest a good tutorial/documentation on this and a good PHP class?

-Thanks in advance

Peeyush
  • 4,728
  • 16
  • 64
  • 92
  • you can use search: http://stackoverflow.com/questions/2296087/using-php-and-google-maps-api-to-work-out-distance-between-2-post-codes-uk, it's similar .. – Mihai Iorga Aug 16 '11 at 08:36

2 Answers2

1

I found the answer so i am closing it

it's here http://code.google.com/apis/maps/documentation/distancematrix/

you can fetch result in json or xml format then parse it using PHP

Thanks everyone for try to answer my question.

Peeyush
  • 4,728
  • 16
  • 64
  • 92
-2
$longitude = Request::post('longitude');
$latitude = Request::post('latitude');

$radius = 10;

// Latitude calculation
$limit = (1 / 69.1703234283616) * $radius;
$latitude_min = $latitude - $limit;
$latitude_max = $latitude + $limit;

// Longitude calculation
$limit = (1 / (69.1703234283616 * cos($userLat * (pi/180)))) * $radius;
$longitude_min = $longitude - $limit;
$longitude_max = $longitude + $limit;

$item = new Item;
$items = $item->filter("longitude BETWEEN '{$longitude_min}' AND '{$longitude_max}' 
          AND latitude BETWEEN {$latitude_min} AND {$latitude_max}")->all();
  • This answer doesn't help in any way: 1) it doesn't use Google API 2) it assumes the author has latitude and longitude information on each zipcode 3) it measures "as a crow flies" distance between two points which *most probably* not what the author wants – Eduard Sukharev Feb 03 '16 at 15:50