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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:06:23+00:00 2026-06-16T06:06:23+00:00

I have a problem with GoogleMap API for Android component MyLocationOverlay. I want to

  • 0

I have a problem with GoogleMap API for Android component MyLocationOverlay. I want to turn off MyLocationOverlay auto-recenter feature (to current user location) every time device location changes (and user location goes out of the visible part or the map).

It seems there is no flag to turn off the undesired maps auto-center feature when user location goes out of the screen

e.g.

public class LocationTest extends MapActivity{

  private MapView map;
  private MapController controller;

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    map = (MapView) findViewById(R.id.map);
    final MyLocationOverlayUpdate overlay = new MyLocationOverlayUpdate(this, map);
    overlay.enableMyLocation();
    map.getOverlays().add(overlay);
  }

  @Override
  protected boolean isRouteDisplayed() {
    return false;
  }
}

public class MyLocationOverlayUpdate extends MyLocationOverlay {

  public MyLocationOverlayUpdate(Context context, MapView mapView) {
    super(context, mapView);
  }

  public void drawMyLocation(Canvas canvas, MapView mapView, 
              Location location, GeoPoint geoPoint, long when) {}
}

I looked through the net for this problem but didn’t found the solution provided.

Additional info found:

  • I guess that documentation is faulty, buggy, or just outdated saying:

    Optionally, the constructor can also take a MapController and use it to keep
    the “my location” dot visible by panning the map when it would go offscreen

because there is no constructor accepting MapController as an argument, and it seems that I have no choice over keeping the "my location" dot visible or not.

  • I accidentaly found a workaround by overriding method drawMyLocation() with no call to super.drawMyLocation() solves the problem of recentering the map (undesired “feature” turns off). However i have to reimplement drawMyLocation() method, therefore changing default appearence (and spending time…)

Maybe there is a more clear solution?

  • 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-06-16T06:06:24+00:00Added an answer on June 16, 2026 at 6:06 am

    extend MyLocationOverlay class and reimplement the overlay animation by overriding drawMyLocation method.

    public class CustomMyLocationOverlay extends MyLocationOverlay {
    
        private static final String TAG = "Bankomatai";
    
    
        private Drawable[] slips;
        private final MapView mapView;
        private int currSlip = 0;
        private Location savedFix = null;
        Point point = new Point();
        Rect rect = new Rect();
        private Handler handler = new Handler();
        private Runnable overlayAnimationTask;
    
    
        public CustomMyLocationOverlay(Context context, MapView mapView) {
            super(context, mapView);
            this.mapView = mapView;
            slips = new Drawable[4];
            slips[0] = context.getResources().getDrawable(R.drawable.ic_maps_indicator_current_position_1);
            slips[1] = context.getResources().getDrawable(R.drawable.ic_maps_indicator_current_position_2);
            slips[2] = context.getResources().getDrawable(R.drawable.ic_maps_indicator_current_position_3);
            slips[3] = context.getResources().getDrawable(R.drawable.ic_maps_indicator_current_position_4);
            overlayAnimationTask = new Runnable() {
    
            @Override
            public void run() {
                currSlip = (currSlip + 1) % slips.length;
                CustomMyLocationOverlay.this.mapView.invalidate();
                handler.removeCallbacks(overlayAnimationTask);
                handler.postDelayed(overlayAnimationTask, 200);
    
            }
    
            };
            handler.removeCallbacks(overlayAnimationTask);
            handler.postAtTime(overlayAnimationTask, 100);
        }
    
    
    
        protected void drawMyLocation(Canvas canvas, MapView mapView, Location lastFix, GeoPoint myLocation, long when) {   
            Log.v(TAG, "draw: " + System.currentTimeMillis());      
            mapView.getProjection().toPixels(myLocation, point);
            rect.left = point.x - slips[currSlip].getIntrinsicWidth() / 2;
            rect.top = point.y - slips[currSlip].getIntrinsicHeight() / 2;
            rect.right = point.x + slips[currSlip].getIntrinsicWidth() / 2;
            rect.bottom = point.y + slips[currSlip].getIntrinsicHeight() / 2;
            slips[currSlip].setBounds(rect);
            slips[currSlip].draw(canvas);
        }
    }
    

    plus you need to create 4 icons and put them in res/drawable folder under names ic_maps_indicator_current_position_1, ic_maps_indicator_current_position_2, ic_maps_indicator_current_position_3, ic_maps_indicator_current_position_4. You need to draw them by yourself.

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

Sidebar

Related Questions

I am using the javascript googlemap API. I want the user to define a
I have a problem that Google Map API is inheriting the style from my
I have a problem with a Javascript request to the Google Map Api Web
I am having a problem with the Google map API v3, I have created
Hi I have this weird problem with Google Maps V3 API. Showing multiple markers
I am using custom InfoWindowsAdapter for GoogleMap on Android. My problem is, that I
I'm new to Android development and have some question regarding overlays in googlemaps API.
I'm new to Android development and have some question regarding overlays in googlemaps API.
i have that problem, I actualice the positions of the items of mi googlemap
I have a program that I want to use google maps for. The problem

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.