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.