开发者

Cities Near By a City Webservice or PHP code

I am building an application which takes 'City','State' ( For USA Only) and distance ( radius ) as 开发者_JS百科user inputs and the output will be all the cities in that radius . Is there any free or paid web service available for this ?

Thanks for your help Regards Kaveri


I personally use lat and lng to define such a radius. Take a look at my code if you need help coverting an city to coordinates Google Geocode can be really helpfull. or just reply and we'll take a look.

/**
 * @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;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜