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

(5PCS) BR24L02FVT-WE2 IC EEPROM 2KBIT 400KHZ 8TSSOP 24L02 BR24L02
$7.0
(5PCS) BR24L02FVT-WE2 IC EEPROM 2KBIT 400KHZ 8TSSOP 24L02 BR24L02 picture(5PCS) BR24C02-10TU-1.8 IC EEPROM 2KBIT 400KHZ 8TSSOP 24C02 BR24C02
$5.51
(5PCS) BR24C02-10TU-1.8 IC EEPROM 2KBIT 400KHZ 8TSSOP 24C02 BR24C02 picture(5PCS) BR24G64FJ-3GTE2 IC EEPROM 64KBIT 400KHZ 8SOP 24G64 BR24G64
$5.24
(5PCS) BR24G64FJ-3GTE2 IC EEPROM 64KBIT 400KHZ 8SOP 24G64 BR24G64 picture(5PCS) BR24T08FVM-WTR IC EEPROM 8KBIT 400KHZ 8MSOP 24T08 BR24T08
$3.48
(5PCS) BR24T08FVM-WTR IC EEPROM 8KBIT 400KHZ 8MSOP 24T08 BR24T08 picture(5PCS) BR24G16FJ-3GTE2 IC EEPROM 16KBIT 400KHZ 8SOP 24G16 BR24G16
$3.26
(5PCS) BR24G16FJ-3GTE2 IC EEPROM 16KBIT 400KHZ 8SOP 24G16 BR24G16 picture






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