Adding a map to an application
You can add a map to an application by using the MapField class and RichMapField class, which are provided in the net.rim.device.api.lbs.maps.ui package. For example, you can create an application that displays a map showing the BlackBerry device user's current location and points of interest in the surrounding area.
The MapField class extends the net.rim.device.api.ui.Field class. You can use MapField to add the following functionality to your application:
- Rendering a map in a UI field
- Panning and zooming the map by using the keyboard, trackpad, trackball, or touch screen.
- Setting styles that define the visual characteristics of mappable objects
- Determining when mappable objects receive focus, or when points on a map are selected
The RichMapField class extends the functionality of MapField. You can use RichMapField to add the following features to your application:
- Adding utility fields, such as a center target, zoom indicator, and a hint field
- Overlaying fields on a map
- Sharing focus with other UI components on a screen to allow users to navigate through map field components to other components on the screen
Each MapField or RichMapField instance uses one thread to render a map. For example, if an application has two MapField instances running at the same time, two threads are used. The thread ends when the MapField instance is processed for garbage collection. Make sure the application does not exceed the limit of available threads. To end the thread for the MapField or RichMapField instance, you must invoke close(), which removes the field as a listener from specific classes and starts garbage collection.