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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:36:04+00:00 2026-05-30T20:36:04+00:00

the overlay’s did not appear and position is not specified changed overlay’s and map

  • 0

the overlay’s did not appear and position is not specified
changed overlay’s and map code from onCreat() method to updateOverlays(), i just want to get right location and set overlay’s correctly on map

    public class tabsActivity extends MapActivity
    {
    private static final String LIST_TAB_TAG = "Notification";
    private static final String MAP_TAB_TAG = "Map";

    private TabHost tabHost;
    private ListView listView;
    private MapView mapView;
    MyLocationOverlay Compass;
    double longitude , latitude;
    MapController mc;
    GeoPoint point;

    protected LocationManager locationManager;

    @Override
    public void onCreate(Bundle savedInstanceState) 
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.maps_notification_tabs);

        LocationListener listener = new LocationListener() 
        {

            @Override
            public void onStatusChanged(String provider, int status, Bundle extras) 
            {
                // TODO Auto-generated method stub

            }

            @Override
            public void onProviderEnabled(String provider) 
            {
                // TODO Auto-generated method stub

            }

            @Override
            public void onProviderDisabled(String provider) 
            {
                // TODO Auto-generated method stub

            }

            @Override
            public void onLocationChanged(Location location) 
            {
                updateOverlays(location);
            }
        };

        LocationManager locMgr = (LocationManager) getBaseContext().getSystemService(Context.LOCATION_SERVICE);
        locMgr.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, listener);

        // setup map view
        mapView = (MapView) findViewById(R.id.mapview);


        //Compass Setup
        Compass = new MyLocationOverlay(this, mapView);
        mapView.getOverlays().add(Compass);
        final MapController control = mapView.getController();



    }

    public void updateOverlays(Location location)
    {
        mapView.setBuiltInZoomControls(true);
        mapView.postInvalidate();
        mapView.setSatellite(true);
        mc = mapView.getController();

        point = new GeoPoint((int) location.getLatitude() , (int) location.getLongitude());
        mc.animateTo(point);
        mc.setZoom(10); 
        mapView.invalidate();

        OverlayItem overlayitem = new OverlayItem(point, "Hint", "Your Are Here");

        List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable drawable =   this.getResources().getDrawable(R.drawable.black);
        MapOverlays itemizedoverlay = new MapOverlays(drawable, this);
        itemizedoverlay.addOverlay(overlayitem);
        mapOverlays.add(itemizedoverlay);
    }
  • 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-30T20:36:05+00:00Added an answer on May 30, 2026 at 8:36 pm

    Your issue is easy to explain: You only use the location that you got while your program is still in the onCreate() method.

    You need to update your overlay from the listener. So make a separate method that can be called from the LocationListener that updates the overlay.

    Edit:

    basically do that (not complete but should give you the idea!)

    public class MyMapActivity extends MapActivity {
        MapView mapView;
        LocationListener locListener;
    
        public onCreate() {
            // setup your map
            mapView = findViewById(R.id.my_map);
            // setup listener
            locListener = new LocationListener() {
                // override methods
                public void onLocationChanged(Location location) {
                    updateOverlays(location);
                }
            }
        }
    
        public void updateOverlays(Location location) {
            // this is basically your code just a bit modified (removed unnecessary code and added new code)
            mc = mapView.getController();
            p = new GeoPoint(location.getLatitudeE6(), location.getLongitudeE6());
    
            mc.animateTo(p);
            mc.setZoom(10); 
            mapView.invalidate();
    
            // remove all existing overlays!
            List<Overlay> mapOverlays = mapView.getOverlays();
            mapOverlays.clear();
    
            //Compass Setup
            Compass = new MyLocationOverlay(this, mapView);
            mapOverlays.add(Compass);
    
            Drawable drawable = getResources().getDrawable(R.drawable.black);
            MapOverlays itemizedoverlay = new MapOverlays(drawable, this);
    
            OverlayItem overlayitem = new OverlayItem(p, "Hint", "Your Are Here");
            itemizedoverlay.addOverlay(overlayitem);
            mapOverlays.add(itemizedoverlay);
        }
    }
    

    Edit2:

    You have an error in your GeoPoint calculation. You don’t give 1E6 integers, you just give some small doubles. Change

    point = new GeoPoint((int) location.getLatitude() , (int) location.getLongitude());
    

    to

    point = new GeoPoint((int) (location.getLatitude() * 1E6), (int) (location.getLongitude() * 1E6));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone know how to do picture overlay or appear on top of each other
Is it possible to add an image overlay to a google map that scales
I'm using the GGeoXml object to overlay KML on an embedded Google Map. I
I'm using the Overlay plugin from jQuery Tools: http://flowplayer.org/tools/overlay/index.html to display a full size
I'm trying to overlay text over a text form field. The text should appear
I using class Overlay to marker place on map.. I want show infomation of
I have overlay View managed by WindowManager , just like in this question .
I have added an overlay item to my mapview but it does not show
I'm using the overlay jquery from here: http://flowplayer.org/tools/overlay/index.html Within my overlay I have a
I'd like to overlay a custom map using MapKit. I've currently implemented the TileMap

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.