Retrieve location information for an address that is stored in address fields
A request for information invoking Locator.geocode() can result in a LocationException if the request fails.
- Import the following classes:
- javax.microedition.location.AddressInfo
- javax.microedition.location.Coordinates
- net.rim.device.api.lbs.Locator
- javax.microedition.location.Landmark
- javax.microedition.location.LocationException
- Create an AddressInfo object.
AddressInfo ai = new AddressInfo();
- Configure the fields of the AddressInfo object.
ai.setField(AddressInfo.STREET, “main street”);
ai.setField(AddressInfo.CITY, “Waterloo”);
ai.setField(AddressInfo.STATE, “Ontario”);
ai.setField(AddressInfo.POSTAL_CODE, “XXX XXX”);
ai.setField(AddressInfo.COUNTRY, “Canada”);
- Create a Coordinates object that the locator server for location based services uses as a starting location to search for location information for an address.
Coordinates co = new Coordinates(43.46518, -80.52237, 0);
- Invoke Locator.geocode(AddressInfo address, Coordinates startCoords) and assign the value that the method returns to a Landmark array.
Landmark[] lm = Locator.geocode(ai,co);
Was this information helpful? Send us your comments.