Open BlackBerry Maps to display a custom map view
A
MapView
object represents the view that the BlackBerry® Maps displays. The
MapView
object contains the latitude and
longitude that the BlackBerry Maps uses as the center of the map and the zoom and rotation values for the map that it displays.
1.
Import the
net.rim.blackberry.api.maps.MapView
class.
import net.rim.blackberry.api.maps.MapView;
2.
Create an instance of a
MapView
object.
MapView mapView = new MapView();
3.
Modify the latitude, longitude, and zoom values for the
MapView
object.
mapView.setLatitude(4331168);
mapView.setLongitude(-8055339);
mapView.setZoom(10);
4.
Invoke
invokeApplication()
using the
APP_TYPE_MAPS
constant parameter, and a new
MapsArguments
object that uses the
MapView
object you created.
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments
(mapView));
View a sample application that displays a custom map view
1.
From the BlackBerry® Integrated Development Environment, launch the
BlackBerryMapsDemo
project.
2.
In the BlackBerry Smartphone Simulator, click
BlackBerry Maps Demo
.
3.
Open the menu and click
Invoke Map View
.
4.
Open the menu and click
View Map
.
Open BlackBerry Maps to display the location for an address in the contact list
You can create a BlackBerry® Application that displays a map for the address of a contact in the contact list. The address for the
contact must be a valid address.
1.
Import the
javax.microedition.pim.PIM
class and the
javax.microedition.pim.Contact
interface.
import javax.microedition.pim.PIM;
import javax.microedition.pim.Contact ;
2.
Create a
Contact
object.
Contact c = null;
3.
In a try block, get the contact list.
try {
ContactList contactList = (ContactList)PIM.getInstance().openPIMList
(PIM.CONTACT_LIST, PIM.READ_WRITE);
Development Guide
Displaying location information on a BlackBerry device
17