I am using Geocoding .I want to get address or location using longitude and latitude .But when I used bedford .It is showing Atlantic ocean every time.
package mypackage;
import javax.microedition.location.AddressInfo;
import javax.microedition.location.Landmark;
import net.rim.device.api.lbs.Locator;
import net.rim.device.api.lbs.LocatorException;
import net.rim.device.api.system.Application;
import net.rim.device.api.ui.component.Dialog;
import net.rim.device.api.ui.component.LabelField;
import net.rim.device.api.ui.container.MainScreen;
public class myReverseGeocode extends MainScreen
{
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)(52.135973);
int longitude = (int)(-0.466655);
try
{
Landmark[] results = Locator.reverseGeocode
(latitude, longitude, Locator.ADDRESS );
if ( results != null && results.length > 0 )
addrInfo = results[0].getAddressInfo();
synchronized(Application.getEventLock())
{
add(new LabelField("------------------------"+addrInfo));
add(new LabelField("------------------------"+addrInfo.getField(addrInfo.BUILDING_FLOOR)));
add(new LabelField("------------------------"+addrInfo.getField(addrInfo.CITY)));
add(new LabelField("------------------------"+addrInfo.hashCode()));
add(new LabelField("------------------------"+addrInfo.getField(addrInfo.BUILDING_NAME)));
add(new LabelField("------------------------"+addrInfo.getField(addrInfo.COUNTRY)));
add(new LabelField("------------------------"+addrInfo.getField(addrInfo.STREET)));
}
// add(new LabelField("---"+addrInfo));
}
catch ( LocatorException lex )
{
synchronized(Application.getEventLock())
{
System.out.print("EVENT THREAD\n");
Dialog.inform("Posted!"+lex);
}
}
}
};
}
That reverseGeocode method takes two ints as parameters, but these are " decimal degrees to five decimal places, multiplied by 100000 " according to the docs.
Just create a new Coordinates
instance and use the second version of that method:
Coordinates coords = new Coordinates(52.135973, -0.466655, 0);
Landmark[] results = Locator.reverseGeocode(coords, Locator.ADDRESS );
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.