Goaler444
Goaler444

Reputation: 2621

How to use GeoNames Web Services using PHP

I have read this post and it looks very promising. However, the answer does not go in detail with regards the implementation.

Basically, given the latitude and longitude, how can I use the GeoNames Web Service to get the country. I would like the returned result to be stored in a variable so that I can then continue working with it as I wish.

Thanks in advance

Upvotes: 0

Views: 4020

Answers (1)

David Müller
David Müller

Reputation: 5351

Do you have to use javascript for that? Geonames doesn't seem to offer a javascript api for doing your exact query (see here: http://www.geonames.org/export/JSON-webservices.html). And remote file fetching via javascript is not a joy.

If you could use php for that, it would be as easy as

$country = file_get_contents("http://ws.geonames.org/countryCode?lat=49.03&lng=10.2");

Upvotes: 2

Related Questions