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

  • Home
  • SEARCH
  • 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 4624286
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T03:06:30+00:00 2026-05-22T03:06:30+00:00

I am creating an application which trakcs down users path on a mapview. What

  • 0

I am creating an application which trakcs down users path on a mapview. What I want to achieve when user takes a left turn for instance map should rotate it self in such a way that the head of the mapview should always point to upward direction. I hope that makes sense.

I came across Mr. Romain Guy’s post an he says

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() :

Does anyone came accross some solution similiar to my question ? A working example would be excellent 🙂

  • 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-22T03:06:30+00:00Added an answer on May 22, 2026 at 3:06 am

    Keep in mind that it’s not an ideal approach, because the text on the map is a static image and will rotate along with the map tiles (at some point it will be upside down).

    Here’s an example of how to put the MapView into your own Layout widget and rotate it. I’ve done it with the OpenStreetMaps, but it should be quite the same for Google Maps.

    First create the “rotating” Layout widget

    package com.eli.util;
    
    import android.content.Context;
    import android.graphics.Canvas;
    import android.util.AttributeSet;
    import android.util.DisplayMetrics;
    import android.widget.LinearLayout;
    
    public class RotatingLinearLayout extends LinearLayout {
    
        private final int mDiagonal;
        private float mBearing;
    
        public RotatingLinearLayout(final Context pContext, final AttributeSet pAttrs) {
            super(pContext, pAttrs);
            final DisplayMetrics dm = pContext.getResources().getDisplayMetrics();
            mDiagonal = (int) Math.hypot(dm.widthPixels, dm.heightPixels);
        }
    
        public void setBearing(final float pBearing) {
            mBearing = pBearing;
        }
    
        @Override
        protected void dispatchDraw(final Canvas pCanvas) {
            pCanvas.rotate(-mBearing, getWidth() >> 1, getHeight() >> 1);
            super.dispatchDraw(pCanvas);
        }
    
        @Override
        protected void onMeasure(final int pWidthMeasureSpec,
                final int pHeightMeasureSpec) {
            final int widthMode = MeasureSpec.getMode(pWidthMeasureSpec);
            final int heightMode = MeasureSpec.getMode(pHeightMeasureSpec);
            super.onMeasure(MeasureSpec.makeMeasureSpec(mDiagonal, widthMode), MeasureSpec.makeMeasureSpec(mDiagonal, heightMode));
        }
    }
    

    Surround by it your MapView in the layout.xml

    <com.eli.util.RotatingLinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:id="@+id/rotating_layout">
        <org.osmdroid.views.MapView
            android:id="@+id/map_view"
            android:layout_width="fill_parent" 
            android:layout_height="fill_parent"
            android:enabled="true"
            android:clickable="true"/>
    </com.eli.util.RotatingLinearLayout>
    

    Now, every time you receive a geo fix, update the bearing of the rotating layout and it should turn.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am creating an application which will store a (semi) real-time feed of a
I am creating an application which retrieve from an external party application an arraylist
I'm creating a Windows application which use FileSystemWatcher. FileSystemWatcher watches some catalog for changes.
I'm creating a Windows application which reads XML file from given server. This application
I am creating an Android application which will have some embedded music inside of
I am working on creating an iphone application which logins to we website and
I am creating a music application in which I am adding a scrollview to
I am creating NSButton dynamically in the cocoa application which is fine. However once
Im creating a web application in asp.net visual studio 2008.. in my application, i
I'm writing C# application which saves picture box screen to JPEG files. One thread

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.