BlackBerry Forums Support Community
              

Closed Thread
 
LinkBack Thread Tools
Old 05-16-2011, 09:32 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Mar 2011
Model: 8900
PIN: N/A
Carrier: Torch
Posts: 59
Post Thanks: 3
Thanked 1 Time in 1 Post
Default Select Location & draw map

Please Login to Remove!

Hello,

I am j2me api to draw map in such a way that user enter country & map is drawn . my code is

public MyClass(){
selecLocation();
}

public void selectLocation(){
Application.getApplication().invokeAndWait( new Runnable() {

public void run() {
/*try {
final Criteria c = new Criteria();
c.setHorizontalAccuracy(500);
c.setVerticalAccuracy(500);
c.setCostAllowed(false);
c.setPreferredPowerConsumption(Criteria.POWER_USAG E_LOW);
c.setPreferredResponseTime(5000);
lp = LocationProvider.getInstance(c);
} catch (LocationException e) {
Dialog.alert("error");
}*/
if (lp == null) {

lp = LocationProvider.getInstance(null);

}

}
});
if (lp == null) {
Dialog.alert("location not found");
}
else{
lp.setLocationListener(new MyListener(), 5, 1, 1);
}


}

protected void makeMenu(Menu menu, int instance) {

super.makeMenu(menu, instance);
menu.add(new MenuItem("Select Location",1,1) {

public void run() {
try{
MapView _mapv = new MapView();
_mapv.setLatitude((int) (1e5 * lat));
_mapv.setLongitude((int) (1e5 * lng));
;
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments(_mapv));
}catch (Exception e) {
Dialog.alert("Error");
}

}
});

}
private class MyListener implements LocationListener
{
public void locationUpdated(LocationProvider provider, Location loc)
{
try{

if(loc.isValid())
{

lat = loc.getQualifiedCoordinates().getLatitude();
lng = loc.getQualifiedCoordinates().getLongitude();
alt = loc.getQualifiedCoordinates().getAltitude();
System.out.println(lat+"\n"+lng+"\n"+alt);


}
}
catch (Exception e) {
Dialog.alert("Cannot find location");
}
}

public void providerStateChanged(LocationProvider provider, int newState) {
// TODO Auto-generated method stub

}
}

Above code was creating map for America & Canada only for other countries it is throwing null pointer exception..

Any body knows why it throws exception for other countries
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

Similar Threads for: Select Location & draw map
Thread Thread Starter Forum Replies Last Post
Maps opens and finds location but no actual map displayed phudson86 General BlackBerry Discussion 4 05-03-2010 02:26 PM
Send GPS position directly to a public Google Map website wesko GPS & Mapping 0 07-22-2008 05:06 PM
Pearl Issues (emails and call logs getting deleted automatically) bacardinole General 8100 Series Discussion - Pearl 35 11-16-2007 12:16 AM
new 8820 report / Yahoo! Go question btaylor1 General Legacy Device Discussion 5 09-23-2007 03:25 PM
7100I Big HELP whoknowswhat General Legacy Device Discussion 1 10-23-2005 03:45 PM

Vintage 1967 Dan Mac Loud Ringing Extension Bell Telephone Repair Supply Co.
$29.99
Vintage 1967 Dan Mac Loud Ringing Extension Bell Telephone Repair Supply Co. pictureVintage 1/2" Drive MAC VUI 166T 6 Point Impact Swivel Socket
$11.95
Vintage 1/2LARGE STEEL GREASE CUP OLD ANTIQUE VINTAGE GAS STEAM TRACTOR HIT MISS ENGINE MAC
$7.99
LARGE STEEL GREASE CUP OLD ANTIQUE VINTAGE GAS STEAM TRACTOR HIT MISS ENGINE MAC pictureVINTAGE MAC D7 And D8 Wrenches
$3.0
VINTAGE MAC D7 And D8 Wrenches pictureNILSSON VINTAGE BORE GAGE #5 MACHINIST TOOL & MAC & MILLER FALLS GAGES AUTO TOOL
$80.0
NILSSON VINTAGE BORE GAGE #5 MACHINIST TOOL & MAC & MILLER FALLS GAGES AUTO TOOL picture






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