Help Center

Local Navigation

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.

  1. 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
  2. Create an AddressInfo object.
    AddressInfo ai = new AddressInfo();
  3. 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”);
    
  4. 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);
  5. 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.