Your code isn't working because the onTap()
is fired when a MotionEvent.ACTION_POINTER_UP
or MotionEvent.ACTION_UP
occurs, and not MotionEvent.ACTION_POINTER_DOWN
or MotionEvent.ACTION_DOWN
.
To test it correctly you need to check during UP
action if the movement was used to zoom the map, and then save it to the boolean.
Example code:
Geopoint center = new Geopoint(0,0);
Boolean ignoreTap = false;
@Override
public boolean onTouchEvent(MotionEvent event, MapView mapView) {
int action = event.getAction() & MotionEvent.ACTION_MASK;
switch (action) {
case MotionEvent.ACTION_POINTER_DOWN: {
case MotionEvent.ACTION_DOWN: {
center = mapView.getMapCenter();
ignoreTap = false;
break;
}
case MotionEvent.ACTION_UP: {
case MotionEvent.ACTION_POINTER_UP: {
if(center != mapView.getMapCenter())
ignoreTap = true;
break;
}
}
return super.onTouchEvent(event, mapView);
}
and in onTap()
:
@Override
protected boolean onTap(int index)
{
if(!ignoreTap){ //...dialog here
Note:
I´m using the map center to test the zoom, as the multitouch zoom works arround the map point located between fingers center, resulting on a center change when you zoom. You couls also use the map longitude span.