Retrieve an address by using reverse geocoding
You can retrieve an address by invoking Locator.reverseGeocode(). When you invoke Locator.reverseGeocode(), you must specify the latitude and longitude coordinates by using two int fields, or by using a Coordinates object. The values for the coordinates
are passed as decimal degrees, to five decimal places, with the values multiplied by 100,000.
Your application must request reverse geocoding information outside of the event dispatch thread. The process uses the LBS Locate Server over the wireless radio or Wi-Fi®. A successful request for reverse geocoding information will return an array of Landmark objects.
Code sample: Retrieving an address by using reverse geocoding
import net.rim.device.api.lbs.*;
import javax.microedition.location.*;
public class myReverseGeocode
{
private Thread reverseGeocode;
public myReverseGeocode()
{
reverseGeocode = new Thread(thread);
reverseGeocode.setPriority(Thread.MIN_PRIORITY);
reverseGeocode.start();
}
Runnable thread = new Runnable()
{
public void run()
{
AddressInfo addrInfo = null;
int latitude = (int)(45.423488 * 100000);
int longitude = (int)(-80.32480 * 100000);
try
{
Landmark[] results = Locator.reverseGeocode
(latitude, longitude, Locator.ADDRESS );
if ( results != null && results.length > 0 )
addrInfo = results[0].getAddressInfo();
}
catch ( LocatorException lex )
{
}
}
};
}
Parent topic: Geocoding and reverse geocoding