1

In my app, the requirement is when I touch on any location in map, I have to create a new overlay and show it with a marker and if I tap on any location that is marked, I have to show its details in a balloon.

The onTap() and onTouchEvent() written inside my ItemizedOverlay class is as follows:

@Override
protected boolean onTap(int index) {
    if(!super.onTap(index)) {
        MyOverlayItem<OverlayItem> overlayItem = new MyOverlayItem<OverlayItem>(
            createItem(index).getPoint(), createItem(index).getTitle(), 
            createItem(index).getSnippet(), mapView, activity);
        overlayItem.onTap(createItem(index).getPoint(), mapView);       
    }
    return true;
}

@Override
public boolean onTouchEvent(MotionEvent event, MapView mapView) {
    GeoPoint point = mapView.getProjection().fromPixels(
            (int) event.getX(),
            (int) event.getY());
    addPoint(point);
    return true;
}

The onTap() inside MyOverlayItem is as follows:

public boolean onTap(GeoPoint point, MapView mapView) {
    createBalloon(); //creates the balloon view.
    return true;
}

My problem is:

If I am adding this onTouchEvent(), onTap() is not getting called. Always a new point is getting added.

How I can I achieve my requirement? I am getting confused with both of these methods. Can anyone please help me out. Thanks in advance.

Anju
  • 9,379
  • 14
  • 55
  • 94
  • Use this url for getting you answer. http://stackoverflow.com/questions/4486864/how-to-display-popup-on-tapping-overlay-in-android/4793288#4793288 I hope this is help. – DynamicMind Jun 02 '11 at 05:16

0 Answers0