我想計算兩個地方之間使用他們的郵政編碼的距離。我想爲此使用Google Map API。如何計算兩地之間的距離(使用郵政編碼+ Google地圖+ PHP)?
所以,請建議我如何做到這一點或建議一個很好的教程/文檔和一個很好的PHP類?
-Thanks提前
我想計算兩個地方之間使用他們的郵政編碼的距離。我想爲此使用Google Map API。如何計算兩地之間的距離(使用郵政編碼+ Google地圖+ PHP)?
所以,請建議我如何做到這一點或建議一個很好的教程/文檔和一個很好的PHP類?
-Thanks提前
$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();
這個答案沒有任何幫助:1)它不使用谷歌API 2)它假設作者有每個郵政編碼的經度和緯度信息3)它測量「作爲一個烏鴉」之間的距離兩點*最可能*不是作者想要的 –
我找到了答案,所以我將其關閉
它在這裏 http://code.google.com/apis/maps/documentation/distancematrix/
您可以獲取引起JSON或XML格式,然後用PHP解析它
謝謝大家試着回答我的問題。
您可以使用搜索:http://stackoverflow.com/questions/2296087/using-php-and-google-maps-api-to-work-out-distance-between-2-post-codes-uk,它相似.. –