开发者

How to calculate distance between two places(Using Post Code+Google Map+PHP)?

I want to calculate distanc开发者_运维百科e 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


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.


$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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜