Get location information from cell site towers........................Get location information from GPS satellites using PDE....................Get location information from GPS satellites and the GPS receiver on a BlackBerry device........Get location information from the GPS receiver on a BlackBerry device................
Page 4
Retrieve location information for an address stored in a String..................Cancel a request for location information for an address....................Determine why a request for location information was unsuccessful................Open BlackBerry Maps from the browser............................ Clearing data from the map................................Clear data from a location document with an id attribute....................
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.
Invoke LocationProvider.getInstance(), storing the returned object in a LocationProvider object. LocationProvider provider = LocationProvider.getInstance(criteria); Get location information from GPS satellites and the GPS receiver on a BlackBerry device Create an instance of a Criteria object. Criteria criteria = new Criteria();...
Get location information from the GPS receiver on a BlackBerry device Create an instance of a Criteria object. Criteria criteria = new Criteria(); Complete one of the following tasks to get location information using the GPS receiver on a BlackBerry device : Task Steps Specify a level of accuracy, Invoke criteria.setHorizontalAccuracy(int accuracy) using...
Invoke LocationProvider.getInstance(), storing the returned object in a LocationProvider object. LocationProvider provider = LocationProvider.getInstance(criteria); 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.
Maintain a connection with GPS satellites You can configure a BlackBerry® device application to query the Location API for GPS location information in an interval less than 10 seconds. Define a LocationListener with an interval value that is less than 10 seconds.
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. Implement the LocationListener interface. To register your implementation, invoke LocationProvider.setLocationListener().
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.
Page 12
Development Guide Displaying location information on a BlackBerry device BlackBerry Java Attribute Type Description Required Development Environment version DOCS: clears location or route information from all location documents with a id attribute set to a value LOCATIONS: clears location information from the map...
Page 13
Development Guide Displaying location information on a BlackBerry device BlackBerry Java Attribute Type Description Required Development Environment version String label a label that is displayed 4.2.0 or later beside a location on a description String description information 4.2.0 or later...
Invoke invokeApplication()using a new MapsArguments object that does not contain any arguments. View a sample application that displays the default map From the BlackBerry® Integrated Development Environment, launch the BlackBerryMapsDemo project. In the BlackBerry Smartphone Simulator, click BlackBerry Maps Demo.
Development Guide Displaying location information on a BlackBerry device Open BlackBerry Maps to display a location on a map Import the following classes: • net.rim.blackberry.api.invoke.Invoke • net.rim.blackberry.api.invoke.MapsArguments Create a String that contains location information for one location. String document = "<location-document><location lon='-7938675' lat='4367022' label='Toronto, ON' description='Toronto' zoom='10'/></...
Displaying location information on a BlackBerry device View a sample application that displays a location on a map From the BlackBerry® Integrated Development Environment, launch the BlackBerryMapsDemo project. In the BlackBerry Smartphone Simulator, click BlackBerry Maps Demo. Open the menu and click Invoke Location Document.
In the BlackBerry Smartphone Simulator, click BlackBerry Maps Demo. Open the menu and click Invoke Location Document. Open the menu and click View Multiple Locations. Open BlackBerry Maps to display a route between locations on a map Import the following classes: • net.rim.blackberry.api.invoke.Invoke •...
Page 18
( MapsArguments.ARG_LOCATION_DOCUMENT,document)); View a sample application that displays a route between locations on a map From the BlackBerry® Integrated Development Environment, launch the BlackBerryMapsDemo project. In the BlackBerry Smartphone Simulator, click BlackBerry Maps Demo. Open the menu and click Invoke Location Document.
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.
Page 20
View a sample application that displays the location for an address in the contact list Before you begin: On a BlackBerry® device, open the contact list. If there are no addresses in the contact list, the sample will display the default view in the BlackBerry® Maps.
Start a BlackBerry device application from BlackBerry Maps You can add a menu item to BlackBerry® Maps that makes a MapView context object available based on the current location. When a BlackBerry device user selects the menu item, the MapView context object is passed to the menu item’s run() method.
Page 22
Development Guide Displaying location information on a BlackBerry device public String toString() return "Menu Item Demo"; * Code that executes when a BlackBerry smartphone user clicks the menu item. * @param context A MapView object. * @return null public Object run(Object context) if (context instanceof MapView ) _mv = (MapView)context;...
Page 23
Development Guide Displaying location information on a BlackBerry device // The ApplicationMenuItem invoked App . Call the default // constructor for the GUI version of the application and enter the application into the main event thread. MapsMenuItemDemo app = new MapsMenuItemDemo();...
Page 24
(latitude > 9000000 || latitude < -9000000 || longitude >= 18000000 || longitude < -18000000) throw new IllegalArgumentException (); _mapview.setLatitude(latitude); _mapview.setLongitude(longitude); // Invoke BlackBerry Maps with a MapView object. Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments(_mapview)); close(); catch(RuntimeException re) // An exception is thrown when any of the following...
Displaying location information in your application A BlackBerry® device application can use the MapField class to display a map in a UI field. For a BlackBerry device application to use the MapField class, BlackBerry® Maps must be installed on the BlackBerry device and the BlackBerry device must be able to download data from the map server for location-based services.
Converting latitudinal and longitudinal coordinates to pixel values You can create a BlackBerry® device application to convert latitudinal and longitudinal coordinates to pixel values. For latitude, north is a positive value, and south is a negative value. For longitude, east is a positive value and west is a negative value.
XYPoint worldOut). Configure the display size of a MapField A BlackBerry® device application can control the display size of a MapField to make other UI components visible on the screen of a BlackBerry device. If you configure the preferred size of MapField, you override the dimension values passed in layout(). The height and width values are in pixels.
Open BlackBerry Maps from the browser A BlackBerry® device user can use the browser on a BlackBerry device to access location information on a web server and display that information in BlackBerry Maps. You store location information in .xloc files and place the .xloc files on a web server. When a BlackBerry device user accesses the link for the .xloc file, for example http://servername/Filename.xloc, the browser opens...
Clearing data from the map You can use the id and clear attributes of the <lbs> element to remove data from a map. When you want BlackBerry Maps to no longer display certain location data, in the next location document you send to BlackBerry Maps, configure the clear attribute to the value of the id attribute of the location document with the location data to remove.
Development Guide Clearing data from the map You can only remove data from a location document that has an id attribute set to a value. Create a String that configures the clear attribute to Docs. String document = "<lbs clear='Docs' ><location lon='-7938675' lat='4367022' label='Toronto, ON' description='Toronto' zoom='10'/></lbs>";...
Development Guide Glossary Glossary application programming interface Global Positioning System Java® Specification Request MIME Multipurpose Internet Mail Extensions NMEA National Marine Electronics Association Position Determination Entity Subscriber Identity Module World Geodetic System Extensible Markup Language...
Page 34
Some airtime service providers might not offer Internet browsing functionality with a subscription to the BlackBerry® Internet Service. Check with your service provider for availability, roaming arrangements, service plans and features. Installation or use of Third Party Products and Services with RIM's products and services may require one or more patent, trademark, copyright, or other licenses in order to avoid infringement or violation of third party rights.
Page 35
Development Guide Legal notice The terms of use of any RIM product or service are set out in a separate license or other agreement with RIM applicable thereto. NOTHING IN THIS DOCUMENTATION IS INTENDED TO SUPERSEDE ANY EXPRESS WRITTEN AGREEMENTS OR WARRANTIES PROVIDED BY RIM FOR PORTIONS OF ANY RIM PRODUCT OR SERVICE OTHER THAN THIS DOCUMENTATION.