I didn't need to do it myself, but given that you know the angle and
you know the drag vector, you can use a rotation matrix for that.
This Wikipedia segment should help you out, it even comes with a
picture:
http://en.wikipedia.org/wiki/Rotation_matrix#Rotations_in_two_dimensions

On 27 янв, 03:00, Dave Bryson <debry...@gmail.com> wrote:
> Thanks for the response!  No, my code is not rotating the drag
> direction.  I'm primary rotating the canvas the map is drawn on.  I'm
> not sure *how* to rotate the axes used by the touch event.  Any
> pointers on how to do this would be greatly appreciated!
>
> Thanks again,
> Dave
>
> On Jan 26, 8:51 am, "JAlexoid (Aleksandr Panzin)" <jalex...@gmail.com>
> wrote:
>
> > You have to rotate the drag direction vector as well as canvas.
> > Even without looking at your code, the actual drawing code probably
> > doesn't translate the dragging direction in accordance with the
> > direction of the device.
>
> > On 26 янв, 08:13,DaveBryson<debry...@gmail.com> wrote:
>
> > > I have a map application using an in-house map engine on Android. I'm
> > > working on a rotating Map view that rotates the map based on the
> > > phone's orientation using the Sensor Service. All works fine with the
> > > exception of dragging the map when the phone is pointing other than
> > > North. For example, if the phone is facing West, dragging the Map up
> > > still moves the Map to the South versus East as would be expected.  I
> > > assume translating the canvas is one possible solution but I'm
> > > honestly not sure the correct way to do this to swap the axes without
> > > disrupting the coordinate system needed by the map tiles.
>
> > > Here is the code I'm using to rotate the Canvas:
>
> > > public void dispatchDraw(Canvas canvas)
> > > {
> > >     canvas.save(Canvas.MATRIX_SAVE_FLAG);
> > >     // mHeading is the orientation from the Sensor
> > >     canvas.rotate(-mHeading, origin[X],origin[Y]);
>
> > >     mCanvas.delegate = canvas;
> > >     super.dispatchDraw(mCanvas);
> > >     canvas.restore();
>
> > > }
>
> > > What is the best approach to make dragging the map consistent
> > > regardless of the phones orientation? The sensormanager has a
> > > "remapcoordinates()" method but it's not clear to me exactly how to
> > > use it.  I've searched the web and posted to StackOverflow to try and
> > > figure this out...no luck so far.  Any pointers would be greatly
> > > appreciated!  Thanks.

-- 
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

Reply via email to