Specifying the source of GPS location information....................................................................................................................3
Get location information from cell site towers...................................................................................................................3
Get location information from GPS satellites using PDE..................................................................................................4
Get location information from GPS satellites and the GPS receiver on a BlackBerry device.......................................4
Get location information from the GPS receiver on a BlackBerry device........................................................................5
Specify a response time for getting the location of the BlackBerry device.....................................................................6
Get the location information for a BlackBerry device........................................................................................................6
Get the speed of the BlackBerry device, in meters per second........................................................................................6
Get the course of the BlackBerry device, in degrees..........................................................................................................7
Get the number of GPS satellites that a BlackBerry device tracks..................................................................................7
Get the time that a BlackBerry device application retrieved GPS information..............................................................7
Maintain a connection with GPS satellites.........................................................................................................................7
Get continuous GPS readings using the cell site mode.....................................................................................................7
Get GPS information during a call.......................................................................................................................................7
Get location information updates........................................................................................................................................8
Change the criteria for obtaining location information.....................................................................................................8
Displaying location information on a BlackBerry device............................................................................................................9
Displaying location information in BlackBerry Maps.........................................................................................................9
Open BlackBerry Maps to display the default map view...................................................................................................12
Open BlackBerry Maps to display a location on a map.....................................................................................................13
Open BlackBerry Maps to display multiple locations on a map.......................................................................................14
Open BlackBerry Maps to display a route between locations on a map.........................................................................15
Open BlackBerry Maps to display a custom map view......................................................................................................17
Open BlackBerry Maps to display the location for an address in the contact list..........................................................17
Start a BlackBerry device application from BlackBerry Maps...........................................................................................19
Displaying location information in your application...................................................................................................................23
Work with a map that displays in a UI field.........................................................................................................................23
Converting latitudinal and longitudinal coordinates to pixel values...............................................................................24
Requesting location information for an address.........................................................................................................................25
Retrieve location information for an address stored in address fields.............................................................................25
Retrieve location information for an address stored in a String.......................................................................................26
Cancel a request for location information for an address.................................................................................................26
Determine why a request for location information was unsuccessful.............................................................................26
Open BlackBerry Maps from the browser....................................................................................................................................26
Clearing data from the map...........................................................................................................................................................27
Clear data from a location document with an id attribute................................................................................................27
Clear data from all location documents with an id attribute............................................................................................27
Clear data from specific location documents with an id attribute...................................................................................28
Clear all location data from a map.......................................................................................................................................28
4 Provide feedback.........................................................................................................................................................................30
You can create a BlackBerry® device application to display the current latitudinal and longitudinal position of a BlackBerry device.
Depending on the mode for getting location information that you specify, the BlackBerry device application can also display
information such as the speed and route information. To create a BlackBerry device application to get location information, you
can use the Location API for Java® ME in the javax.microedition.location package (JSR 179).
The time it takes to retrieve the location of the BlackBerry device for the first time depends on several factors, such as the mode
for getting location information and the GPS signal strength. In autonomous mode, typical times are less than 2 minutes. In
assisted mode, typical times are less than 30 seconds.
To retrieve and display GPS location information, the BlackBerry device must support GPS technology and a valid SIM card must
be inserted in the BlackBerry device.
1
Specifying the source of GPS location information
GPS location information might be unavailable if the BlackBerry® device cannot receive signals from GPS satellites. This situation
can occur when something is obstructing the signals, such as buildings or dense clouds.
To specify the source of GPS location information, you specify the mode by creating an instance of the
javax.microedition.location.Criteria class, invoke the appropriate set methods, and then pass the instance
to LocationProvider.getInstance().
•cell site: Use this mode to get location information from cell site towers. This mode allows a BlackBerry device application
to retrieve location information faster than the assisted and autonomous modes. However, the accuracy of the location
information is low-level and does not provide tracking information such as speed or route information. Using this mode
requires wireless network coverage and that both the BlackBerry device and the wireless service provider support this mode.
•assisted: Use this mode to get location information from satellites using a PDE. This mode allows a BlackBerry device
application to retrieve location information faster than the autonomous mode and more accurately than the cell site mode.
To use this mode requires wireless network coverage, and the BlackBerry device and the wireless service provider must
support this mode.
•autonomous: Use this mode to get location information from the GPS receiver on the BlackBerry device without assistance
from the wireless network. This mode allows a BlackBerry device application to retrieve location information that has highaccuracy, and does not require assistance from the wireless network. However, the speed at which this mode retrieves
location information is slower than the other modes.
Get location information from cell site towers
1.Create an instance of a Criteria object.
Criteria criteria = new Criteria();
3
Development Guide
2.Invoke criteria.setHorizontalAccuracy(NO_REQUIREMENT) to specify longitudinal accuracy is not
required.
3.Invoke criteria.setVerticalAccuracy(NO_REQUIREMENT) to specify latitudinal accuracy is not
required.
4.Invoke criteria.setCostAllowed(true) to specify that this mode can incur cost.
5.Invoke setPreferredPowerConsumption(POWER_USAGE_LOW) to specify power consumption is low.
6.Invoke LocationProvider.getInstance(), storing the returned object in a LocationProvider object.
Get location information from GPS satellites using PDE
1.Create an instance of a Criteria object.
Criteria criteria = new Criteria();
2.Invoke criteria.setHorizontalAccuracy(NO_REQUIREMENT) to specify longitudinal accuracy is not
required.
3.Invoke criteria.setVerticalAccuracy(NO_REQUIREMENT) to specify latitudinal accuracy is not
required.
4.Invoke criteria.setCostAllowed(true) to specify that this mode can incur cost.
5.Invoke criteria.setPreferredPowerConsumption(int level) using one of
POWER_USAGE_MEDIUM, or NO_REQUIREMENT as the parameter to specify power consumption is medium or not
required.
6.Invoke LocationProvider.getInstance(), storing the returned object in a LocationProvider object.
criteria.setPreferredPowerConsumption(int level) using
one of POWER_USAGE_MEDIUM, POWER_USAGE_HIGH, or
NO_REQUIREMENT as the parameter.
Getting GPS location information
Getting GPS location information
Specify a response time for getting the location of the BlackBerry device
Invoke Criteria.setPreferredResponseTime(), and specify the response time, in milliseconds.
Get the location information for a BlackBerry device
In a non-event thread, invoke LocationProvider.getLocation(int), providing a timeout, in seconds.
try {
// Specify -1 to have the implementation use its default timeout value
// for this provider.
Location location = provider.getLocation(-1);
} catch (Exception e) {
// handle LocationException, InterruptedException, SecurityException
// and IllegalArgumentException
}
Get the speed of the BlackBerry device, in meters per second
Get the number of GPS satellites that a BlackBerry device tracks
1.Invoke the Location.getExtraInfo() method using the NMEA MIME type as a parameter. The method returns
an encoded String that contains information on the number of GPS satellites.
Get continuous GPS readings using the cell site mode
Invoke the LocationProvider.getLocation() method within code that simulates the retrieval of GPS
information at fixed intervals.
Get GPS information during a call
Use the autonomous mode to retrieve GPS information.
7
Development Guide
Getting GPS location information
Get location information updates
You can associate only one LocationListener object with a particular provider for GPS location information. The
BlackBerry® device application typically listens for updates on a separate thread.
1.Implement the LocationListener interface.
2.To register your implementation, invoke LocationProvider.setLocationListener().
Change the criteria for obtaining location information
1.Create a new Criteria object.
Criteria criteria2 = new Criteria();
2.Invoke the setHorizontalAccuracy(), setVerticalAccuracy(), setCostAllowed(), and
setPreferredPowerConsumption() methods of the new Criteria object to specify the new criteria.
6.Specify the LocationListener.
provider.setLocationListener(LocationListener listener, int interval, int
timeout, int maxAge);
8
Development Guide
BlackBerry Maps location information
BlackBerry Maps location information
You can create a BlackBerry® device application that interacts with BlackBerry® Maps. The BlackBerry Maps is a map and location
client application that can display a map for a location, the location of the BlackBerry device, a route from a starting location to
a specific ending location, and points of interest on a map. The BlackBerry Maps uses latitudinal and longitudinal integer values
that are 100,000 times the double values specified by JSR 179, which uses WGS 84 specifications for the longitudinal and
latitudinal values.
A BlackBerry device application can interact with the BlackBerry Maps in the following ways:
•start the BlackBerry Maps from a BlackBerry device application
•add a menu item to the BlackBerry Maps that opens a BlackBerry device application
The BlackBerry Maps is included on BlackBerry devices that run BlackBerry® Device Software version 4.2 or later.
2
Displaying location information on a BlackBerry device
Displaying location information in BlackBerry Maps
The BlackBerry® Maps uses a location document to display location information on a map, such as locations and routes. A location
document is a String that contains a set of XML elements with attributes that specify information about the location or route.
You can include information for ten locations in one location document.
XML element: <lbs>
The <lbs> and </lbs> elements encapsulate the information in a location document. The opening and closing <lbs>
elements contain all other location document elements.
BlackBerry Java
AttributeTypeDescriptionRequired
idString
clearString
the id of a location documentno4.5.0 or later
the action to perform on the
information in a map
NONE: clears no information
no4.5.0 or later
Development
Environment version
9
Loading...
+ 24 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.