How to rotate MapView?

*爱你&永不变心* 提交于 2019-12-03 07:28:14

I have done this in the past and it requires to create a custom ViewGroup that rotates the Canvas in the dispatchDraw() method. You also need to increase the size of the MapView (so that it draws enough pixels when rotated.) You will also need to rotate the touch events in dispatchTouchEvent(). Or if you use Android 3.0 you can simply call theMapView.rotate() :)

As a general case, you can always created an Affine Transform with the angled rotation you need. In the general case, you do a matrix multiplication of this form:

|x'|   |cosθ  -sinθ   0| |x|
|y'| = |sinθ  cosθ    0|*|y|
|1 |   |0      0      1| |1|

Where (x,y) are your initial coordinates, θ is your angle of rotation, and (x',y') are the resultant transformation.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!