Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3855956
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T17:51:21+00:00 2026-05-19T17:51:21+00:00

I have a map application using an in-house map engine on Android. I’m working

  • 0

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’m assuming translating the canvas is one possible solution but I’m honestly not sure the correct way to do this.

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 that this will resolve my problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T17:51:22+00:00Added an answer on May 19, 2026 at 5:51 pm

    You can trivially get the delta x and delta y between two consecutive move events. To correct these values for your canvas rotation you can use some simple trignometry:

    void correctPointForRotate(PointF delta, float rotation) {
    
        // Get the angle of movement (0=up, 90=right, 180=down, 270=left)
        double a = Math.atan2(-delta.x,delta.y); 
        a = Math.toDegrees(a);  // a now ranges -180 to +180
        a += 180;
    
        // Adjust angle by amount the map is rotated around the center point
        a += rotation;
        a = Math.toRadians(a);
    
        // Calculate new corrected panning deltas
        double hyp = Math.sqrt(x*x + y*y);
        delta.x = (float)(hyp * Math.sin(a));
        delta.y = -(float)(hyp * Math.cos(a));
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an in-house enterprise application (EJB2) that works with a certain BPM vendor.
I have a silverlight bing map application. I am using the MVVM pattern with
In my spring application context file, I have something like: <util:map id="someMap" map-class="java.util.HashMap" key-type="java.lang.String"
I have a map for my game, I have a script that on a
I want to have a map that has a homogeneous key type but heterogeneous
I am developing a mapping application using ESRI Silverlight API (it's SL map control).
I have developed an application using google maps v3. Here, I need to show
I'm developing a map application in Silverlight. I have a type Polygon, containing the
I have unsorted map of key value pairs. input = { xa => xavalue,
I have a Map which is to be modified by several threads concurrently. There

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.