blue screen in map with plotting

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

blue screen in map with plotting

Postby saisri2k2 » Thu Nov 13, 2008 4:30 am

Hello ,
I'm getting a blue screen for the following code.. could i get some help on this.see my attachments for the screen shot...... thanks.. thanks

public class Mapping extends MapActivity
{

//private MapView map1;
private Button btnSearch;
private EditText adress;
private MapView map;
Drawable defaultMarker;
GeoPoint p,q;
private double lat=29.5582*1000000;
private double lon=-95.0963*1000000;
private Geocoder gc;

@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
map = (MapView) findViewById(R.id.maps); // Get map from XML
btnSearch = (Button) findViewById(R.id.simpleGM_btn_search); // Get button from xml


adress = (EditText) findViewById(R.id.simpleGM_adress); // Get address from XML
gc = new Geocoder(this); // create new geocoder instance

btnSearch.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String addressInput = adress.getText().toString(); // Get input text
//onclick goes here...

try {

List<Address> foundAdresses = gc.getFromLocationName(addressInput, 5); // Search addresses
if (foundAdresses.size() == 0) { // if no address found,
// display an error
/*Dialog locationError = new AlertDialog.Builder(
Mapping.this).setIcon(0).setTitle(
"Error").setPositiveButton(R.string.ok, null)
.setMessage(
"Sorry, your address doesn't exist.")
.create();
locationError.show();*/
} else { // else display address on map
for (int i = 0; i < foundAdresses.size(); ++i) {
// Save results as Longitude and Latitude
// @todo: if more than one result, then show a
// select-list
Address x = foundAdresses.get(i);
lat = x.getLatitude();
lon = x.getLongitude();
//
p = new GeoPoint((int)lat*1000000,(int)lon*1000000);
// q = new GeoPoint((int)(-33.881511 * 1000000),(int)(151.171253 * 1000000));


ZoomControls zoomControls = (ZoomControls) map.getZoomControls();
zoomControls.setLayoutParams(new ViewGroup.LayoutParams(LayoutParams.WRAP_CONTENT,LayoutParams.WRAP_CONTENT));

map.addView(zoomControls);
map.displayZoomControls(true);



defaultMarker = getResources().getDrawable(R.drawable.bubble);

defaultMarker.setBounds(0, 0, defaultMarker.getIntrinsicWidth(), defaultMarker.getIntrinsicHeight());

map.getOverlays().add(new MapOverlay(defaultMarker));


MapController mc = map.getController();

mc.animateTo(p);

mc.setZoom(15);

}
//navigateToLocation((lat * 1000000), (lon * 1000000),
// map); // display the found address
}

}catch (Exception e) {

}//end try and ctch
}
});




}


private class MapOverlay extends ItemizedOverlay<OverlayItem>
{
private ArrayList<OverlayItem> mItemList = new ArrayList<OverlayItem>();


@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow)
{

super.draw(canvas, mapView, shadow);
MapOverlay.boundCenterBottom(defaultMarker);


}

public MapOverlay(Drawable pMarker)
{
super(pMarker);


mItemList.add(new OverlayItem(p, "Title", "Snippet"));

// mItemList.add(new OverlayItem(q, "Title", "Snippet"));

populate();
}

@Override
protected OverlayItem createItem(int pIndex)
{
return mItemList.get(pIndex);
}


@Override
protected boolean onTap(int pIndex)
{
EditText adress;
adress = (EditText) findViewById(R.id.simpleGM_adress); // Get address from XML
String addressInput = adress.getText().toString(); // Get input text
switch (pIndex)
{

case 0:

Toast.makeText(Mapping.this,"77058",Toast.LENGTH_SHORT).show();

return true;



}

return false;

}


@Override
public int size()
{
return mItemList.size();
}
}




@Override
protected boolean isRouteDisplayed()
{
return false;
}
}
Attachments
bluescreen.jpg
bluescreen.jpg (19.49 KiB) Viewed 317 times
Sai
saisri2k2
Junior Developer
Junior Developer
 
Posts: 12
Joined: Wed Oct 29, 2008 7:57 pm
Location: Houston

Top

Postby GasBot » Thu Nov 13, 2008 10:36 pm

Are you sure it's not just plotting you in the middle of a lake or ocean all the way zoomed in? Can you zoom out and see the area around it?
GasBot
Experienced Developer
Experienced Developer
 
Posts: 50
Joined: Fri Oct 17, 2008 7:19 am

Postby saisri2k2 » Fri Nov 14, 2008 7:01 am

I'm not able to access the zoom controls of it after i click on the go button... i'd uploaded the whole zip of my project...could you please run it and chek...thanks for your reply.
Attachments
MapOverlays.rar
(35.48 KiB) Downloaded 58 times
Sai
saisri2k2
Junior Developer
Junior Developer
 
Posts: 12
Joined: Wed Oct 29, 2008 7:57 pm
Location: Houston

Postby saisri2k2 » Fri Nov 14, 2008 7:26 am

Yes you were right, it is plotting into sea....could i get suggestions to remove that?
Sai
saisri2k2
Junior Developer
Junior Developer
 
Posts: 12
Joined: Wed Oct 29, 2008 7:57 pm
Location: Houston

Postby saisri2k2 » Fri Nov 14, 2008 7:44 am

lat=lat*1000000; lon=lon*1000000;


I've placed the following code after lat = x.getLatitude();
lon = x.getLongitude();

this code...i'm able to acheive the plotting .... thank you very much for you reply...i came to know wher i have done hte mistake. keep helping the community like you are doing.. thanks..
Sai
saisri2k2
Junior Developer
Junior Developer
 
Posts: 12
Joined: Wed Oct 29, 2008 7:57 pm
Location: Houston

Postby GasBot » Fri Nov 14, 2008 7:57 am

Haha I wish I could've helped more.

Also, you can achieve zooming and moving the map by using the MapController.

MapController mc = theMap.getController();
GasBot
Experienced Developer
Experienced Developer
 
Posts: 50
Joined: Fri Oct 17, 2008 7:19 am

Top

Postby andrex_17 » Thu Dec 18, 2008 6:41 pm

Hi men, I got a question, may yo explain me this part, I got error when i do this

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. @Override
  2.  
  3. protected boolean onTap(int pIndex)
  4.  
  5. {
  6.  
  7. Toast.makeText(Mapping.this,"77058",Toast.LENGTH_SHORT).show();
  8.  
  9. return false;
  10.  
  11. {
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


First do you must create an instance of the Mapping class in the MapOverlay class??
Cause if I put
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. Toast.makeText(Mapping.this,"77058",Toast.LENGTH_SHORT).show();
Parsed in 0.031 seconds, using GeSHi 1.0.8.4

I got a mistake
andrex_17
Freshman
Freshman
 
Posts: 6
Joined: Wed Nov 26, 2008 8:24 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 2 guests