Well fellow programmers,
I got myself in a situation.
I am currently developing an API for a taxi application. The taxi want's to show advertisements from the current area. Now i need to specify in the Admin panel what the banner image is and the main location. Aswell as a radius in KM to show this ad aswell.
My question. Is there a simple API which i can fill in my current location and get all nearby citynames within the radius i provide aswell?
i am looking for something like this : http://www.travelmath.com/cities-within/10+km/of/Rotterdam,+Netherlands but then an API with JSON return.
/**
* @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;
}
Got it working.