Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 26
Registered: ‎07-15-2008
My Device: Not Specified

AddressInfo, Landmark, geocode Question

This should be a simple question, in terms of either it can be done or no it cant.


In the normal api usage, you can create an AddressInfo instance, set the various fields, use this to create a landmark be using Locator.geocode(AddressInfoInstance) and finally getting the fully qualified coordinates for the landmark.  What I want to do however is, using the GPS coordinates that I already know (from a gps listener etc), is it possible to get back an address i.e. postcode, street etc.


The code snippet below explains what I'm trying to achieve, but regardless of the coordinates I always get WhereAmI = null.


Theoretically the LBS api should be able to give me details about a location if the only thing I know about that location is the GPS coords.... well I hope anyway



AddressInfo WhereAmI = new AddressInfo();QualifiedCoordinates Qf =

new QualifiedCoordinates(gpsListener.getLatitude(), gpsListener.getLongitude(), 0, Float.NaN, Float.NaN);

Landmark landmark;

Landmark[] landmarkArray;

try {

landmark = new Landmark("test", "My Description", Qf, null);

WhereAmI = landmark.getAddressInfo();

catch (Exception e) {Dialog.inform("Ex1 = " + e.getMessage());



if (WhereAmI==null){

sSB.append("AddressInfo Object is null\n\n").append(

"Other Stats:\n")







"Got AddressInfo Object from Landmark");


try {

landmarkArray = Locator.geocode(WhereAmI, null);

if (landmarkArray.length == 1) {

landmark = landmarkArray[0];

WhereAmI = landmark.getAddressInfo();


catch (Exception e) {Dialog.inform("Ex2 = " + e.getMessage());



"Street = ").append(

"" + WhereAmI.getField(AddressInfo.STREET)).append(

"\nPost Code = ").append(

"" + WhereAmI.getField(AddressInfo.POSTAL_CODE)).append(

"\nCity = ").append(

"" + WhereAmI.getField(AddressInfo.CITY)).append(

"\nState = ").append(

"" + WhereAmI.getField(AddressInfo.STATE)).append(

"\nCountry = ").append( "" + WhereAmI.getField(AddressInfo.COUNTRY));




catch (Exception e) {

Dialog.inform("Ex3 = " + e.getMessage());


Posts: 16,519
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: AddressInfo, Landmark, geocode Question

as far as the LBS is concerned i think it works the other way round.

from the 4.6 api:
Class Locator
public static Landmark[] geocode(String freeformString,
Coordinates startCoords)
throws LocatorException
Starts a request for geocode information using a non-formatted String as input.
For example: 'Paris', '10 Downing St London UK', '90210 USA' are valid search requests.

array of Landmarks: the first array element contains the most relevant Landmark to the locator request. May be null if the geocode request is cancelled.

you need a service to translate the coordinates to an address. google offers an API like this, as does microsoft (and maybe others). i think if you want to use them commercially you will have to pay, never really digged deeper into this though.

i am pretty sure that RIM uses something similar, you can see the requests in the debug console of the simulator if you use blackberry maps.
to use it without any "hacking" you could use MapField and its method moveto that takes coordinates as an input.

the following link may be also of interest:

feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Posts: 1,415
Registered: ‎07-30-2008
My Device: Not Specified

Re: AddressInfo, Landmark, geocode Question

Does anyone have a list of commercial landmark providers? I'm setting up a zipcode and census

DB from the US govt source files, as well as user contributed stuff (I've got a text-based play version skeleton

running on 7130 ). If you can't find something free or suitable, it is easy to create your own DB at

least in the US. The Census Tiger files appear to give most fixed landmarks you'd care about

but they are quite large ( as you can imagine).