You need to create Overlay and override onSingleTapConfirmed .
Try the following:
Overlay touchOverlay = new Overlay(this){ ItemizedIconOverlay<OverlayItem> anotherItemizedIconOverlay = null; @Override protected void draw(Canvas arg0, MapView arg1, boolean arg2) { } @Override public boolean onSingleTapConfirmed(final MotionEvent e, final MapView mapView) { final Drawable marker = getApplicationContext().getResources().getDrawable(R.drawable.markericon); Projection proj = mapView.getProjection(); GeoPoint loc = (GeoPoint) proj.fromPixels((int)e.getX(), (int)e.getY()); String longitude = Double.toString(((double)loc.getLongitudeE6())/1000000); String latitude = Double.toString(((double)loc.getLatitudeE6())/1000000); System.out.println("- Latitude = " + latitude + ", Longitude = " + longitude ); ArrayList<OverlayItem> overlayArray = new ArrayList<OverlayItem>(); OverlayItem mapItem = new OverlayItem("", "", new GeoPoint((((double)loc.getLatitudeE6())/1000000), (((double)loc.getLongitudeE6())/1000000))); mapItem.setMarker(marker); overlayArray.add(mapItem); if(anotherItemizedIconOverlay==null){ anotherItemizedIconOverlay = new ItemizedIconOverlay<OverlayItem>(getApplicationContext(), overlayArray,null); mapView.getOverlays().add(anotherItemizedIconOverlay); mapView.invalidate(); }else{ mapView.getOverlays().remove(anotherItemizedIconOverlay); mapView.invalidate(); anotherItemizedIconOverlay = new ItemizedIconOverlay<OverlayItem>(getApplicationContext(), overlayArray,null); mapView.getOverlays().add(anotherItemizedIconOverlay); }
source share