2011-10-19 14 views
2

アドレスの助けを借りて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(); 

答えて

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(); 
関連する問題