GeoNames Search (1)
Geonames.org is a great resource for free geographic information. It is a collection of millions of locations that can be searched online or downloaded for offline use. In this project, we will build a simple application to query the Geonames web service and display the results in a table and on a map.
The Geonames web service accepts a query as a URL and returns an XML or JSON document. For example…
http://ws.geonames.org/search?q=detroit&maxRows=3
returns an XML document with the top 3 results for Detroit. As expected, the city of Detroit in the State of Michigan (USA) is returned first which is probably what the search was intended to find.
The query can be confined to a particular country like this…
http://ws.geonames.org/search?q=detroit&maxRows=3&country=US
Geonames offers a number of other web services, including recent earthquakes, weather conditions, and reverse geocoding. While we may explore these later, for now let’s focus on obtaining latitude and longitude information for places.
The results above are returned as XML in your web browser. This sort of display is fine for casual viewing but not for custom mapping applications. Fortunately, C# provides an easy framework for obtaining and working with XML documents.