Open BlackBerry Maps by using a landmark

You can open BlackBerry® Maps to display the location of a landmark on a map by specifying an array of Landmark objects. A landmark object can contain a display label name, a description, the geospatial coordinates, and a street address.

If you do not specify the coordinates, BlackBerry Maps can use the address to find the coordinates. If the coordinates and address are invalid, BlackBerry Maps does not display the location of the landmark.

  1. Import the required classes.
    import net.rim.blackberry.api.invoke.*;
    import javax.microedition.location.*;
  2. Create a class and constructor to use to invoke BlackBerry Maps.
    public class invokeMaps
    {
        public invokeMaps ()
        {
        }
    }
  3. In the constructor, create an array of Landmark objects that you can use to add the landmark information to.
    Landmark[] landMarks = new Landmark[3];
  4. In the constructor, create an AddressInfo array and invoke AddressInfo.setField() to specify the street address. Add the AddressInfo array to the Landmark array.
    AddressInfo addressInfo = new AddressInfo();
    addressInfo.setField(AddressInfo.STREET, "455 Phillip St");
    addressInfo.setField(AddressInfo.CITY, "Waterloo");
    addressInfo.setField(AddressInfo.STATE, "Ontario");
    landMarks[0] = new Landmark("AAA", "Description 1", null, addressInfo);
  5. In the constructor, create an instance of the QualifiedCoordinates class and specify the coordinates. Add the QualifiedCoordinates to the Landmark array.
    QualifiedCoordinates coordinates =
      new QualifiedCoordinates(45.4, -75.1, 0, 0, 0);
    landMarks[1] = new Landmark("BBB", "Description 2", coordinates, null);
    coordinates = new QualifiedCoordinates(45.3,-75.3,0,0,0);
    landMarks[2] = new Landmark("CCC", "Description 3", coordinates, null);
  6. In the constructor, create an instance of the MapsArguments class using the Landmarks array as an argument. Invoke Invoke.invokeApplication() to open BlackBerry Maps. Pass in the MapsArguments object.
    MapsArguments ma = new MapsArguments(landMarks);            
    Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, ma);

Code sample: Opening BlackBerry Maps by using a landmark

import net.rim.blackberry.api.invoke.*;
import javax.microedition.location.*;

public class invokeMaps
{
    public invokeMaps ()
    {
        Landmark[] landMarks = new Landmark[3];

        AddressInfo addressInfo = new AddressInfo();
        addressInfo.setField(AddressInfo.STREET, "455 Phillip St");
        addressInfo.setField(AddressInfo.CITY, "Waterloo");
        addressInfo.setField(AddressInfo.STATE, "Ontario");

        landMarks[0] = new Landmark("AAA", "Description 1", null, addressInfo);

        QualifiedCoordinates coordinates =
          new QualifiedCoordinates(45.4, -75.1, 0, 0, 0);

        landMarks[1] = new Landmark("BBB", "Description 2", coordinates, null);

        coordinates = new QualifiedCoordinates(45.3,-75.3,0,0,0);

        landMarks[2] = new Landmark("CCC", "Description 3", coordinates, null);

        MapsArguments ma = new MapsArguments(landMarks);
        Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, ma);
  }
}

Was this information helpful? Send us your comments.