Initially I am able to add the pin on the map.I delete the pin using
mapView.getOverlays().clear();
mapView.invalidate();
Now when I click on addPin button the same code of adding the pin on map runs, but it does not get added on it. Please Help.....
Code for adding pin is:-
addPin.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
ch=1;
}
});
After clicking the add button i touch on the place where I want to add PIN
view.setOnTouchListener(new OnTouchListener() {
public boolean onTouch(View v, MotionEvent motionEvent) {
Toast.makeText(getApplicationContext(), "done", Toast.LENGTH_SHORT).show();
itemizedoverlay.populateList();
if(ch==1){
GeoPoint point = view.getProjection().fromPixels(
(int) motionEvent.getX(),
(int) motionEvent.getY());
overlayitem = new OverlayItem(point, "Yeahh", "I've added");
itemizedoverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedoverlay);
Toast.makeText(getApplicationContext(), "Added", Toast.LENGTH_SHORT).show();
ch=0;
}
Toast.makeText(getApplicationContext(), "done", Toast.LENGTH_SHORT).show();
return false;
}
});
Here view=mapView I am using counter ch which will change to ch=0 when added and when deleted it will get turned to ch=1
code for deleting:-
delete.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
view.getOverlays().clear();
view.invalidate();
}
});