如何找到有地址的位置。

时间:2011-10-19 09:28:34

标签: blackberry maps

我想在地址的帮助下找到Lat Lon。

我使用以下代码,但无法给出任何回复。

    Coordinates ahmedabad,baroda;
    AddressInfo addr = new AddressInfo();
    addr.setField(addr.EXTENSION, "Flat 5");
    addr.setField(addr.STREET, "10 Washington Street");
    addr.setField(addr.POSTAL_CODE, "XXX XXX");
    addr.setField(addr.CITY, "Palo Alto");
    addr.setField(addr.COUNTY, "Santa Clara County");
    addr.setField(addr.STATE, "California");
    addr.setField(addr.COUNTRY, "United States of America");
    addr.setField(addr.COUNTRY_CODE, "US");Landmark results = null;

    results = new Landmark("AAA", "Description 1", null, addr);
    Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new 
              MapsArguments((Contact) addr,0));

    Coordinates c = results.getQualifiedCoordinates();

2 个答案:

答案 0 :(得分:1)

试试这段代码。

Runnable thread = new Runnable() {

public void run() {
AddressInfo addrInfo = new AddressInfo(); 
addrInfo.setField(AddressInfo.STREET, "601 Whitehead St");
addrInfo.setField(AddressInfo.CITY, "Key West");
addrInfo.setField(AddressInfo.STATE, "FL"); 
addrInfo.setField(AddressInfo.POSTAL_CODE, "33040");
addrInfo.setField(AddressInfo.COUNTRY, "US");
Coordinates startCoords = new Coordinates(0.386087,0.889244, Float.NaN);

try {
Landmark[] results = Locator.geocode(addrInfo, startCoords);
if ( results != null && results.length > 0 )
{
    for(int i=0;i<results.length;i++)
    {
        QualifiedCoordinates c  = results[i].getQualifiedCoordinates();
        lat = c.getLatitude();
        lon = c.getLongitude();
    }
}
}
catch ( LocatorException lex ) {
}
catch (MapServiceException mex) {
}
catch (IllegalThreadStateException itex) {
}
catch(IllegalStateException isex) {
}
}
};
thread.run();

答案 1 :(得分:-1)