1

我正在构建一个应用程序,它将 'City'、'State' (仅适用于美国)和距离( radius )作为用户输入,输出将是该 radius 中的所有城市。是否有任何免费或付费的网络服务可用于此?

感谢您的帮助问候卡弗里

4

1 回答 1

1

我个人使用 lat 和 lng 来定义这样的半径。如果您需要帮助覆盖一个城市以协调 Google 地理编码,请查看我的代码非常有帮助。或者只是回复,我们会看看。

/**
 * @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 回答