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

100pcs 6.3V47uF 6.3V 5x11mm Rubycon YXA Aluminum Electrolytic Capacitor
$5.79
100pcs 6.3V47uF 6.3V 5x11mm Rubycon YXA Aluminum Electrolytic Capacitor picture5E 40-PCS LOT Silver Mica MICA Cornell Dubilier CDE CD10FD 130PF 500V
$0.99
5E  40-PCS LOT Silver Mica MICA Cornell Dubilier  CDE  CD10FD  130PF  500V  picture5E 100-PCS LOT Silver Mica MICA Cornell Dubilier CDE CD10FD121J0 120PF 500V
$0.99
5E 100-PCS LOT Silver Mica MICA Cornell Dubilier  CDE  CD10FD121J0  120PF  500V  picture5E 40-PCS LOT Silver Mica MICA Cornell Dubilier CDECD10FD 270PF 500V
$0.99
5E  40-PCS LOT Silver Mica MICA Cornell Dubilier  CDECD10FD  270PF  500V  picture2000 PCS THOMSON BF014D0473J .047MF 5% 63V CAPACITORS
$3.99
2000 PCS THOMSON BF014D0473J .047MF 5% 63V CAPACITORS picture






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