Using Geocoding Services

Geocoding is the process of translating a description of a location into GPS coordinates (latitude, longitude, and sometimes altitude). Geocoding enables you to enter a place name such as Eiffel Tower into Google Maps (http://maps.google.com) and get the appropriate spot on the map. Many geocoding services also have reverse-geocoding abilities, which can translate raw coordinates into some form of address (usually a partial address).

Android devices may or may not have geocoding services available, and geocoding obviously requires a back-end service, and the device must have network connectivity to be able to contact this back-end service. Different geocoding services support different types of descriptions, but the following are some of the most common ones:

► Names of towns, states, and countries

► Various forms of postal-style addresses (full and partial)

► Famous landmarks

Of course, most geocoding services also allow input of raw coordinates (latitude and longitude) as well. Geocoding services are often localized.

Geocoded addresses are often ambiguous, so a geocoding service may return multiple records. For example, if you were to try to resolve the address "Springfield," you would likely get quite a few results because there is a town called Springfield in about 35 states in the United States, and there are even more Springfields abroad. You might also get results for places called East Springfield or Springfield by the Sea, for example. For the best results, choose the geocoding address that is the most specific (for example, use Springfield's zip code instead of its name to resolve the coordinates).

Like other network operations, geocoding services are blocking operations. This means that you'll want to put any calls to geocoding services in a thread separate from the main UI thread.

0 0

Post a comment