Which produces an output of something like this: Nearby Cities
| Miles | Kms | City | Bearing | Direction |
|---|
function getIP() {
foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key) {
if (array_key_exists($key, $_SERVER) === true) {
foreach (explode(',', $_SERVER[$key]) as $ip) {
if (filter_var($ip, FILTER_VALIDATE_IP) !== false) {
return $ip;
}
}
}
}
}
$tags=json_decode(file_get_contents('http://getnearbycities.geobytes.com/GetNearbyCities?radius=100&locationcode='. getIP()), true);
print_r($tags);
echo PHP_EOL ;
Parameters
| Parameter | Discription | Example Value |
|---|---|---|
| locationcode | Either of * Geobytes Location Code * Fully Qualified City Name * IP Address defaults to the location of current connection based on IP Address if optional Latitude and Longitude not provided |
geobyteslocationcode or geobytesfqcn or geobytesipaddress |
| callback | Used by JSON-P AJAX Calls. If unsure, just pass in a question mark as the call back | ? |
| limit | Optionally limit the number of rows returned defaults to 10 |
10 |
| radius | Limits the results to cities within the given radius defaults to 40km or 25 miles |
60mi or 100km |
| minradius | Excludes cities that are closer than the minradius from the results defaults to 0 |
60mi or 100km |
| latitude | Latitude of nominated location defaults to location of current connection based on IP Address if Geobytes Location Code not provided |
geobyteslatitude |
| longitude | Longitude of nominated location defaults to location of current connection based on IP Address if Geobytes Location Code not provided |
geobyteslongitude |
Returns
The response is a list of cities in the form of a JSON array of arrays - with each array being the following details of the nearby city. This link will open a new window containing sample results based on your current location.| Array Element |
Contains | Description |
|---|---|---|
| [0] | Bearing | The compass bearing in degrees from the nominated city to the nearby city |
| [1] | City Name | The name of the nearby city |
| [2] | Region or State Code | The two letter region or state code |
| [3] | Country Name | The name of the nearby city's country |
| [4] | Direction | The rough direction rounded to one of the ordinal (or intercardinal) directions |
| [5] | Nautical Miles | Distance in Nautical Miles |
| [6] | Internet Code | The two letter Internet Code of the nearby City's Country |
| [7] | Kilometres | The distance in Kilometres |
| [8] | Latitude | The Latitude of the nearby city |
| [9] | Geobytes Location Code | The Geobytes Location Code of the nearby city |
| [10] | Longitude | The Longitude of the nearby city |
| [11] | Miles | The distance in Miles |
| [12] | Region or State | The name of the region or state of the nearby city |