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, 08: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

(1) MSA Altair Pro Single Gas Detector - For Parts -
$19.95
(1) MSA Altair Pro Single Gas Detector - For Parts - pictureMSA ALTAIR H2S PORTABLE GAS DETECTOR IN BOX ( 84201-1 H )*
$79.99
MSA ALTAIR H2S PORTABLE GAS DETECTOR IN BOX ( 84201-1 H )* picture(8) MSA 10083913 INTERNAL Li-Poly BATTERY ALTAIR 4/ 4X MULTI-GAS DETECTOR -*K12*
$34.79
(8) MSA 10083913 INTERNAL Li-Poly BATTERY ALTAIR 4/ 4X MULTI-GAS DETECTOR -*K12* pictureMSA 10106727 Sulfur Dioxide XCell Replacement Sensor Kit for Use with ALTAIR ...
$350.0
MSA 10106727 Sulfur Dioxide XCell Replacement Sensor Kit for Use with ALTAIR ... picture( 2 ) X MSA Altair 4 X Multi gas Monitor Detector Meter
$150.0
( 2 ) X MSA Altair 4 X Multi gas Monitor Detector Meter picture






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