BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-07-2009, 08:48 AM   #1 (permalink)
New Member
 
Join Date: Feb 2008
Model: 7730
PIN: N/A
Carrier: tmobile
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Has anyone a sample of Locator.geocode?

Please Login to Remove!

Hi there,

i wanted to use the geocode method to get the latitude/longitude for a address string. But i cant get it to work.
Has anyone a sample code of that?

Thanks!
Matthias
Offline  
Old 08-18-2009, 09:37 AM   #2 (permalink)
New Member
 
Join Date: Dec 2005
Model: 9000
Carrier: Vodafone
Posts: 2
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

import net.rim.device.api.lbs.Locator;
import javax.microedition.location.*;
.
.
.
String strLatitude = "";
String strLongitude = "";
try {
AddressInfo addressInfo = new AddressInfo();
addressInfo.setField( AddressInfo.CITY, "your city" );
addressInfo.setField( AddressInfo.POSTAL_CODE, "your postal code" );
addressInfo.setField( AddressInfo.STREET, "your street" );
addressInfo.setField( AddressInfo.COUNTRY, "your country" );
Landmark[] landmarkArray = Locator.geocode( addressInfo, null );
if( landmarkArray != null ) {
//access the first landmark from the array, otherwise iterate the array
QualifiedCoordinates qc = landmarkArray[0].getQualifiedCoordinates();
if( qc != null ) {
strLatitude = qc.getLatitude();
strLongitude = qc.getLongitude();
}
}
} catch( LocatorException locex ) {
//handle the locator exception
} catch( Exception ex ) {
//handle other exception
}

Remember:
Locator.geocode(...) throws an IllegalStateException if a request is made on the event dispatch thread (see API help for details).
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.