Blackberry GPS and BlackBerry Maps Manual - Página 27

Navegue en línea o descargue pdf Manual para Software Blackberry GPS and BlackBerry Maps. Blackberry GPS and BlackBerry Maps 35 páginas. Version: 4.7.0

Development Guide
3.
To convert pixels to latitudinal and longitudinal coordinates, invoke
convertFieldToWorld(XYPoint fieldIn, Coordinates worldOut) or
convertFieldToWorld(XYPoint fieldIn, 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.
Invoke setPreferredSize(int preferredWidth, int preferredHeight).

Requesting location information for an address

You can use the Locator class in a BlackBerry® device application to request location information for an address. Requests
are sent to a locator server for location-based services. If the request is successful, the server returns an enumeration that contains
latitudinal and longitudinal data for the address. If the request is unsuccessful, the server throws aLocatorException
exception that contains the reason for the unsuccessful request. A BlackBerry device application can request location information
for only one address at a time.

Retrieve location information for an address stored in address fields

1.
Create an AddressInfo object.
AddressInfo ai = new AddressInfo();
2.
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");
3.
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);
4.
Create a Locator object.
Locator lo = new Locator();
5.
Invoke Locator.geocode(AddressInfo address, Coordinates startCoords).
Enumeration en = lo.geocode(ai, co);
Requesting location information for an address
25