Reverse Geocoding

Must Read

Planning Ahead For the Biggest Shopping Day

Planning ahead is always a good idea, especially when you are talking about Black Friday. Black Friday 2009 is...

Superior Financing With Home Equity Lines Of Credit!

Home equity lines of credit have emerged as a new option in the world of finances. A Home equity...

How to Obtain a College Degree Without Getting a Student Loan

One of the first college degrees that most people go for is the associate's degree. Going for this type...

Unless you are displaying a map, providing an address or nearby points of interest is more tangible than latitude and longitude.

Reverse geocoding is the process of reverse-coding a point location to fetch a readable address and place name. It is widely used in combination with location-based services (LBS) to retrieve local weather data or business information, as well as by public safety services such as Enhanced 911. Such information is not immediately available, but there are free services that provide it.

The Yahoo! Geocoding API is well documented and reliable. You need to apply for an application ID that is required as an argument in your requests. It is not exclusive to mobile use and can be used in the browser, assuming it has a way to detect location. Go to and read the “How Do I Get Started” section to request an ID. You need to log in with a Yahoo! account and fill out the form. Provide the URL of a website, even though it will not be used on the device.

First, add the permission to go out to the Internet:

<uses-permission android:name=”android.permission.INTERNET” />

In this example, I am receiving the latitude and longitude data from Geolocation Event and passing it along with my required applicationID and gFlags = R for reverse geocoding:

import flash.sensors.Geolocation;
var geolocation:Geolocation;
const YAHOO_URL:String = “”;
const applicationID:String = “GET_YOUR_ID_ON_YAHOO_SITE”;
var loader:URLLoader;

Set the geolocation listener:

if (Geolocation.isSupported) {
geolocation = new Geolocation();
geolocation.addEventListener(GeolocationEvent.UPDATE, onTravel);

Request reverse geolocation data from the Yahoo! service passing the coordinates:

function onTravel(event:GeolocationEvent):void {
var request:URLRequest = new URLRequest(YAHOO_URL);
var variables:URLVariables = new URLVariables();
variables.q = event.latitude.toString() + “n”
+ event.longitude.toString();
variables.gflags = “R”;
variables.appid = applicationID; = variables;
request.method = URLRequestMethod.GET;
loader = new URLLoader();
loader.addEventListener(Event.COMPLETE, onLocationLoaded);
loader.addEventListener(IOErrorEvent.IO_ERROR, onLocationLoaded);
function onError(event:IOErrorEvent):void {
trace(“error”, event);

Parse the XML received from the service to get city and country information:

function onLocationLoaded(event:Event):void {
loader.removeEventListener(Event.COMPLETE, onLocationLoaded);
geolocation.removeEventListener(GeolocationEvent.UPDATE, onTravel);
var xml:XML = new XML(;
var city:String =;
var country:String =;

The XML comes back with a ResultSet.Result node, which includes a street address, city, and country. For example, this is the result for my office building located in New York City’s Times Square:

<name>40.7576303 -73.98716655000001</name>
<line1>230 Rodgers &amp; Hammerstein Row</line1>
<line2>New York, NY 10036-3906</line2>
<line4>United States</line4>
<street>Rodgers &amp; Hammerstein Row</street>
<city>New York</city>
<county>New York County</county>
<state>New York</state>
<country>United States</country>

This address is actually correct for this particular location. It is not my postal address, but it is where I am currently sitting on the west side of the building.

Other interesting data in the XML is woeid and woetype (“woe” is short for Where On Earth). GeoPlanet ( was developed by Yahoo! as a way to identify some features on Earth in a unique, language-neutral manner. This is particularly important because many places in the world have the same name, such as Paris, France, and Paris, Texas.

woeid is a 32-bit unique and nonrepetitive identifier. Numbers follow a hierarchy such as country, state, and city. woetype is the type used to identify a place—in this case, 11 refers to the postal code

Twitter and Flickr are currently using the GeoPlanet system.

Previous articleAIR and Android
Next articleMaps


Please enter your comment!
Please enter your name here

Latest News

Top 10 Provinces of Thailand Not to be missed for Travel

10 SuratthaniThe source of the proverbial Chaiya salted egg. Surat Thani is a province with many attractions,...

Underlight As Accent, For Power and The Main Light for Photography

Underlighting, in which fill or accent light comes from under the topic, is not widely used technique in the traditional Portraits, even though it will have...

How To Fix Overexposure As A Creative Tool, The Complete Guide

As an creative tool, overexposure is sort of underrated. What I’m close to propose could be a deliberate and well thought out technique for...

7D Mark II is Canon’s best DSLR cameras without full-frame sensor.

The expected long-awaited Canon EOS 7D Mark II are shipping in November for $ 1,799 without a lens. With a higher price tag, you...

Low key photography and How to isolate your subject.

Low key photography doesn’t depend on underexposure to make its point; the key to low key is that the majority of tones, even correctly...

More Articles Like This