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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:39:00+00:00 2026-05-31T04:39:00+00:00

I am trying to put the marker on the map and i have done

  • 0

I am trying to put the marker on the map and i have done it but the problem is that it is showing all the markers.previous & recent also.I dont want to show the previous markers instead i just want to show the marker on the place which is clicked recently.All other markers should not be seen

I have written the code with the help of follwing tutorial

http://mobiforge.com/developing/story/using-google-maps-android

And my Code is

public class SelectLocation extends MapActivity {
MapView mapView; 
MapController mc;
GeoPoint p;
String coordinates[];


class MapOverlay extends com.google.android.maps.Overlay
{

    private GeoPoint p; 
    public MapOverlay(GeoPoint p){
        this.p = p;
    }

    @Override
    public boolean draw(Canvas canvas, MapView mapView, 
            boolean shadow, long when) 
    {
        super.draw(canvas, mapView, shadow);                   

        //---translate the GeoPoint to screen pixels---
        Point screenPts = new Point();
        mapView.getProjection().toPixels(p, screenPts);

        //---add the marker---
        Bitmap bmp = BitmapFactory.decodeResource(
                getResources(), R.drawable.pushpin);            
        canvas.drawBitmap(bmp, screenPts.x, screenPts.y-50, null);         
        return true;
    }   

    public boolean onTouchEvent(MotionEvent event, MapView mapView) 
    {   
        //---when user lifts his finger---
        if (event.getAction() == 1) {                
            GeoPoint p = mapView.getProjection().fromPixels(
                    (int) event.getX(),
                    (int) event.getY());

            Toast.makeText(getBaseContext(), 
                    p.getLatitudeE6() / 1E6 + "," + 
                            p.getLongitudeE6() /1E6 , 
                            Toast.LENGTH_SHORT).show();
            mapView.getOverlays().add(new MapOverlay(p));
            Intent i=new Intent(SelectLocation.this,SetLocat.class);
            startActivity(i);

        }                            
        return false;
    }        

}
public void onCreate(Bundle savedInstanceState)
{
    super.onCreate(savedInstanceState);
    setContentView(R.layout.selectlocation);

    mapView = (MapView) findViewById(R.id.mapView);

    mapView.setBuiltInZoomControls(true);

    mc = mapView.getController();
    String coordinates[] = {"1.352566007", "103.78921587"};
    double lat = Double.parseDouble(coordinates[0]);
    double lng = Double.parseDouble(coordinates[1]);

    p = new GeoPoint(
            (int) (lat * 1E6), 
            (int) (lng * 1E6));

    mc.animateTo(p);
    mc.setZoom(17);
    MapOverlay mapOverlay = new MapOverlay(p);


    List<Overlay> listOfOverlays = mapView.getOverlays();
    listOfOverlays.clear();
    listOfOverlays.add(mapOverlay);        




}
/*protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}*/
@Override
protected boolean isRouteDisplayed() {
    // TODO Auto-generated method stub
    return false;
}
  • 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-31T04:39:02+00:00Added an answer on May 31, 2026 at 4:39 am

    before this code

    mapView.getOverlays().add(new MapOverlay(p)); 
    

    try,

    mapView.getOverlays().clear();
    mapView.invalidate();
    mapView.getOverlays().add(new MapOverlay(p)); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a linq query and I am trying to put that in to
I'm trying to tackle a problem that seemingly many Android developers have, which is
I'm trying to show/hide( or simply put - filter ) my markers( of houses
Trying to put a regex expression together that returns the string between _ and
I trying to put together an Android app that will take a picture and
GOOGLE MAPS API V3 is what i'm trying to use. I have all the
What's up y'all, I am trying to write some code in Java that will
I am trying to build a website and I want to have a map
I am trying to change the marker icon and put my own icon with
I'm trying to put some geolocation data from Google Maps into a database. But

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.