1

「City」、「State」(米国のみ)、および距離(radius)をユーザー入力として使用するアプリケーションを構築しています。出力は、その半径内のすべての都市になります。このために利用できる無料または有料のWebサービスはありますか?

よろしくお願いしますKaveri

4

1 に答える 1

1

私は個人的に緯度と経度を使用してそのような半径を定義します。都市を座標に変換するのに助けが必要な場合は、私のコードを見てください。Google Geocode は本当に役に立ちます。または、返信していただければ確認いたします。

/**
 * @author Stefano Groenland
 * @return string
 *
 * Uses the geobyte API for nearby cities in a radius arround the lat & long coords of a given location.
 */
public function getLocationsInRadius(){
    $radius = Input::get('radius');
    $lat = Input::get('lat');
    $lng = Input::get('lng');

    $radius = $radius * 0.62137; //km to miles
    $url = 'http://gd.geobytes.com/GetNearbyCities?radius='.$radius.'&Latitude='.$lat.'&Longitude='.$lng.'&limit=999';

    $response_json = file_get_contents($url);

    $response = json_decode($response_json, true);

    return $response;
}
于 2016-04-05T11:43:02.107 に答える