Smartphone Development Page 4 - How to Incorporate Location into Your BlackBerry Applications |
Now that we know the XML elements and attributes that make up a location document, we can create one. There are two types of location document that we can create. The first is one that uses only required elements: "<lbs> <location y= 'latitude' x ='longitude' label ='MyLabel' description='This is my description' /> <location y= 'latitude' x ='longitude' label ='MyLabel' description='This is my description' /> <location y= 'latitude' x ='longitude' label ='MyLabel' description='This is my description' /> </lbs>" The second type of location document is one that uses both required and optional elements: "<lbs> <location y= 'latitude' x ='longitude' label ='MyLabel' description='This is my description' zoom='MAX_ZOOM' address='address' rating='3' /> <lbs>" Displaying the Data The last step in the process is to actually display the data on a map. To do so, create a new string and feed it the location information for your location: String document = "<location-document><location x=' -3942102' y='1234567' label ='New Mexico, USA' description='New Mexico' zoom='5' /> </location-document>"; Next, you will need to Invoke the following: Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments(MapsArguments.ARG_LOCATION_DOCUMENT, Document)); It's that simple. While it is beyond the scope of this article, it should also be noted that geoencoding and route generation are both supported. One other important thing to note is a feature that makes the BlackBerry stand out from the crowd - namely, ephemeris information. In Standalone mode, the user's device must scan the entire sky to find satellites. With ephemeris information, BlackBerry devices are updated every 3-4 days with the approximate location of the satellites, resulting in a much faster first fix in Standalone mode. Conclusion We have literally only touched the tip of the iceberg when it comes to incorporating location into your BlackBerry apps, but I think this is a good starting point. We'll continue looking at how to display location, and other location retrieval techniques, in an upcoming article, so be sure to drop by often.
blog comments powered by Disqus |
|
|
|
|
|
|
|