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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T11:41:44+00:00 2026-06-04T11:41:44+00:00

I have a MapActivity where i get the current location and i pin a

  • 0

I have a MapActivity where i get the current location and i pin a drawable on it. The thing is that when my location is changed ( onchangedlocation method ) there appears another pinpoint on the map but the first one does not disappear. Another problem is that onchangedlocation does not pin another drawable until i touch the screen. What should I do to appear instantly. I want to show with this drawable the current location of the car so it should move properly, like a GPS or something.

Here is my activity with which I add the pinpoint.

public class CustomPinpoint extends ItemizedOverlay<OverlayItem>{


private ArrayList<OverlayItem> pinpoints = new ArrayList<OverlayItem>();
private Context c;


public CustomPinpoint(Drawable defaultMarker) {
    super(boundCenter(defaultMarker));
    // TODO Auto-generated constructor stub
}
public CustomPinpoint(Drawable m, Context context) {
    // TODO Auto-generated constructor stub
    this(m);
    c = context;
}

@Override
protected OverlayItem createItem(int i) {
    // TODO Auto-generated method stub
    return pinpoints.get(i);
}



@Override
public int size() {
    // TODO Auto-generated method stub
    return pinpoints.size();
}

public void insertPinpoint(OverlayItem item){
    pinpoints.add(item);
    this.populate();
}
  }

and I use this in my oncreate method :

    lm= (LocationManager) getSystemService(Context.LOCATION_SERVICE);
        Criteria crit = new Criteria();

        towers = lm.getBestProvider(crit, false);
        final Location location = lm.getLastKnownLocation(towers);

        if(location != null){
            latit = (int) (location.getLatitude() *1E6);
            longi = (int) (location.getLongitude() *1E6);
            ourLocation = new GeoPoint(latit, longi);
            controller.animateTo(ourLocation);
            controller.setZoom(14);

            if//myItemizedOverlay.addItem(ourLocation, "myPoint1", "myPoint1");
            OverlayItem overlayItem = new OverlayItem(ourLocation, "What's up", "2nd String");
            CustomPinpoint custom = new CustomPinpoint(d, Map.this);
            custom.insertPinpoint(overlayItem);
            overlayList.add(custom);}
            map.setSatellite(false);
            map.setStreetView(true);

and this is my onlocationchanged

   public void onLocationChanged(Location l) {
    // TODO Auto-generated method stub
    latit = (int) (l.getLatitude() *1E6);
    longi = (int) (l.getLongitude() *1E6);
    GeoPoint ourLocation = new GeoPoint(latit, longi);
    OverlayItem overlayItem = new OverlayItem(ourLocation, "What's up", "2nd String");
    CustomPinpoint custom = new CustomPinpoint(d, Map.this);
    custom.insertPinpoint(overlayItem);
    overlayList.add(custom);
}

I thought that for the multiple drawables on my current location a solution would be to display only the last pinpoint(geopoint) added but I don’t really know how to do this.

I would be very grateful if you could help me with both problems. Thank you !

PS: I would need the drawable looks like it is moving continuesly when the device is in a car or something which goes with some speed.

  • 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-04T11:41:46+00:00Added an answer on June 4, 2026 at 11:41 am

    I don’t see the definition of overlayList in your code but I guess it must be of type ArrayList<OverlayItem>

    So before you overlayList.add(custom) you need to call overlayList.clear(). That will leave you with just the latest position’s marker. As far as updating the display, I would have thought it should do that when you .add. I suppose you could always call .invalidate() on the mapview to see if that helps

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

Sidebar

Related Questions

I have this method that get's the street names for Ambassy's out of a
Here I create one project that will track our current location. But I have
Have a matrix report now that has Position, Hours and Wages for a location
I have written following code to get location name package demo.gps.locname; import java.io.IOException; import
I have an activity that implements LocationListener in my application and my onLocationChanged method
I have a public class FriendMaps extends MapActivity that gets called from a menu
I have an android app that extends a MapActivity, so I can't extend TabActivity.
I have a an app that starts with a MapActivity showing some POI's on
I have a function that shows a map page so I can get the
I have an activity MyActivity that extends from MapActivity. In the .xml file containing

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.