Invoking Blackberry Map application with address details
I am working with version 4.6 of the blackberry OS.
I am attempting to invoke the Maps application using the following:
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments(MapsArguments.ARG_LO开发者_Go百科CATION_DOCUMENT, document));
This works fine for an example document such as:
String document = "<lbs>" + "<location lon='-8030000' lat='4326000' label='Kitchener, ON' description='Kitchener, Ontario, Canada' />" + "</lbs>";
My question is: how can I construct such a document if I do not know the coordinates of the location I am trying to inspect? I only know the address...
According to this document, <location> supports an address, city, postal code, and region attributes. Would this work?
If that doesn't work, you'll need to use the Locator class to get the location information. It needs starting coordinates though. Code from page 25 of the documentation:
// Create an javax.microedition.location.AddressInfo object
AddressInfo ai = new AddressInfo();
// Set the fields of the AddressInfo Object
ai.setField(AddressInfo.STREET, “main street”);
ai.setField(AddressInfo.CITY, “Toronto”);
ai.setField(AddressInfo.STATE, “Ontario”);
ai.setField(AddressInfo.POSTAL_CODE, “XXX XXX”);
ai.setField(AddressInfo.COUNTRY, “Canada”);
// Create a Coordinates object that the location-based services locator server
// uses as a starting location to search for location
// information for an address.
Coordinates co = new Coordinates(45.423488, -75.697929, 0);
// Create a Locator object.
Locator lo = new Locator();
// Invoke Locator.geocode(AddressInfo address, Coordinates startCoords).
Enumeration en = lo.geocode(ai, co);
精彩评论