Tuesday, June 22, 2010

Problem of onTouchEvent(MotionEvent, MapView) on MapView

It's a follow-up of my old article "Move the marker on MapView". In the article, onTouchEvent(MotionEvent, MapView) was overrided to handle user touching on screen to update the marker. It work fine on Android emulator, BUT TOTALLY NO WORKING on true phone, such as Nexus One. It seem that the onTouchEvent(MotionEvent, MapView) cannot be triggered. I don't know why!

Instead of onTouchEvent(MotionEvent, MapView), I override onTap(GeoPoint, MapView) and test on Nexus One. It work as expect.

public boolean onTap(GeoPoint p, MapView mapView) {
String strLocation = String.valueOf((float)p.getLongitudeE6()/1000000)
+ " : "
+ String.valueOf((float)p.getLatitudeE6()/1000000);
Toast.makeText(AndroidMapView.this, strLocation, Toast.LENGTH_LONG).show();
// TODO Auto-generated method stub
//return super.onTap(p, mapView);

myMapView.getOverlays().remove(0);

CenterLocation(p);

return true;
}

No comments:

Post a Comment