I am working in google maps…
i did the bellow application and it was working fine then suddenly it stoped working and I trace it from the begining and I found that when I add
mapOverlays = mapView.getOverlays();
the application stops working…
I need a help please
public class MapGtugActivity extends MapActivity implements OnClickListener {
MapView mapView ;
MyLocationOverlay compass ;
MapController controller ;
Drawable drawable ;
Drawable drawable2 ;
List<Overlay> mapOverlays ;
GeoPoint point1 ;
GeoPoint point2 ;
GeoPoint point3 ;
MapItemizedOverlay custom ;
MapItemizedOverlay custom2 ;
//List <GeoPoint> LGP ;
GeoPoint LGP[] = new GeoPoint[6] ;
Button AddLayers ;
int x , y ;
GeoPoint touchedpoint ;
long start ;
long stop ;
CharSequence[] items = {"Layer1", "Layer2"};
boolean[] itemsChecked = new boolean[items.length];
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MapView mapview = (MapView) findViewById(R.id.mapview) ;
mapview.setBuiltInZoomControls(true) ;
mapOverlays = mapView.getOverlays();
}
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
public void onClick(View v) {
// TODO Auto-generated method stub
}
}
You can only make calls to getOverlays after you have added overlays. I think its returning nullpointerException at that point (because ur calling it in onCreate). Because when getOverlays() is called there is no overlay defined on ur map for it to get.