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 6473391
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T06:27:39+00:00 2026-05-25T06:27:39+00:00

I am trying to implement my own map overlay for osmdroid (but I assume

  • 0

I am trying to implement my own map overlay for osmdroid (but I assume it is fairly similar to Google map overlays).

What I am trying to do is draw a plane, rotate it according to bearing and draw a speed vector (line ahead of the plane in the flight direction that shows where it will soon be).

The idea is that I draw the plane (et all) on a canvas “facing North”, then rotate it according to flight direction and “merge” it with the overlay canvas (I tried drawing directly to the overlay canvas, but on rotate, it was rotating the map as well).

I have created a subclass of Overlay and overiden the onDraw method as follows:

@Override
protected void draw(Canvas c, MapView mapView, boolean shadow) {
    if (location != null) {
        Point locPoint = new Point();
        GeoPoint locGeoPoint = new GeoPoint(location);
        final Projection pj = mapView.getProjection();
        pj.toMapPixels(locGeoPoint, locPoint);

        this.drawPlane(c, locPoint, location.getBearing());
    }
}

private void drawPlane(Canvas cs, Point ctr, float bearing) {

    Paint paint = new Paint();
    paint.setColor(Color.RED);
    paint.setAntiAlias(true);

    Bitmap planeBM = Bitmap.createBitmap(cs.getWidth(), cs.getHeight(), Bitmap.Config.ARGB_8888);
    planeBM.setDensity(cs.getDensity());        
    Canvas c = new Canvas(planeBM);

    Rect r = new Rect();

    //Point center = new Point(cs.getWidth() / 2, cs.getHeight() /2);
    Point center = new Point(0, 0);

    // Draw fuselage
    r.left = center.x - PLANE_WIDTH / 2;
    r.right = r.left + PLANE_WIDTH;
    r.top = center.y - PLANE_SIZE / 3;
    r.bottom = r.top + PLANE_SIZE;

    c.drawRect(r, paint);

    // Draw wing (REMOVED)

    // Draw stabilizer    (REMOVED)

    // TODO Draw Speed vector


    // "Merging" canvas

    Matrix merge = new Matrix(cs.getMatrix());
    //merge.setTranslate(0, 0);
    //merge.setRotate(bearing, center.x, center.y);
    cs.drawBitmap(planeBM, merge, paint);
    cs.save();

}

Basically my plane never shows.

I assume this has to do with the matrix in the initial canvas which has large values (I assume these are sort of geographical coordinates).

It all seems to be consistent though (the plane location has large values as well consistent with the matrix).

I have tried a number of things :

  • drawing from the actual plane location (large values) : did not help;
  • setting the matrix of my new canvas with the overlay canvas matrix : did not help;
  • merging with a new “empty” matrix : did not help;
    -…

I know that my image contains the plane (at least if I draw from 0,0 or the new canvas center as I saved it to the SD to check…

  • 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-25T06:27:39+00:00Added an answer on May 25, 2026 at 6:27 am

    In case this is usefull to someone, I finally found a solution.

    Basicaly I was trying to do too much at the same time.
    Using setPostRotate instead of setRotate on the merge matrix did solve the issue (that and goig bac to the drawing board for the correct translation parameters).

    Using the below as a merge matrix worked:

     // "Merging" canvas
     Matrix merge = new Matrix();
     merge.setTranslate(loc.x - pCenter.x, loc.y - pCenter.y);
     merge.postRotate(bearing, loc.x, loc.y);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to implement my own GenericIdentity implementation but keep receiving the following error
I am trying to implement my own provider for xml site map files. Because
I'm trying to implement my own tabs, but in certain cases the :visible selector
I'm trying to implement my own list class but am having trouble reversing just
I'm trying to implement my own List system in Java. the List class file
I am trying to implement my own authentication method for AuthKit and am trying
I'm trying to implement my own version of the 'cd' command that presents the
For all those ligthning fast shop users. I'm trying to implement my own first
Trying to implement a UITableView of names similar to the built-in Contacts iPhone app
Im trying to implement my own Huffman Coding algorithm and the priority queue for

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.