on touch event you must use the inverted matrix used on dispatch draw of the view. Follow both method implementation:
private Matrix invertedMatrix = new Matrix(); private float[] tempLocation = new float[2]; @Override protected void dispatchDraw(Canvas canvas) { canvas.save(Canvas.MATRIX_SAVE_FLAG); canvas.rotate(-mHeading, getWidth() * 0.5f, getHeight() * 0.5f); canvas.getMatrix().invert(invertedMatrix); mCanvas.delegate = canvas; super.dispatchDraw(mCanvas); canvas.restore(); } @Override public boolean dispatchTouchEvent(MotionEvent ev) { float[] location = tempLocation; location[0] = ev.getX(); location[1] = ev.getY(); invertedMatrix.mapPoints(location); ev.setLocation(location[0], location[1]); return super.dispatchTouchEvent(ev); } Em quinta-feira, 25 de fevereiro de 2010 00h30min22s UTC-3, lbendlin escreveu: > > I am using the MapsDemo example for a mapping application where I > rotate the map in direction of travel. This works well even without > the canvas smoothing in the example. > > However, I haven't yet managed to adjust the dispatchTouchEvent code > to counter the map rotation effect for the user touches (right now > when the map is rotated 90 degrees a user's horizontal sweep will move > the map vertically etc). The sample code only offers the teaser: > > public boolean dispatchTouchEvent(MotionEvent ev) { > // TODO: rotate events too > return super.dispatchTouchEvent(ev); > } > > Any guidance would be appreciated. > > And while I am at it - Is it still possible to position the zoom > controls separately, so that they do NOT rotate when the map rotates? > I read that the getZoomControls() is deprecated. (Why ?) > > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en