how to remove overlay on map

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

how to remove overlay on map

Postby xiaodar » Fri Jul 16, 2010 9:28 am

i'm developing this map application that each time i select a point on the map and press the mark button, it will mark the location of where i select. However when i select another location and press the mark button again. Yes it does mark the new location.BUT the first marked point is still shown on the map. i want it to remove the first marked point and mark the new marked point.
can any1 help me? thanks glady appreaciated
this is my on click listener button below


Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.   btnMark.setOnClickListener(new View.OnClickListener() {
  2.  
  3.                         public void onClick(View v) {
  4.                                  GeoPoint point8 = new GeoPoint(Latzx,Lonzx);
  5.                                  
  6.                                 OverlayItem overlayitem8 = new OverlayItem(point8, "test15", "test16");
  7.                                 itemizedOverlay2.addOverlay(overlayitem8);
  8.                                 mapView.getOverlays().add(itemizedOverlay2);
  9.                         }
  10.                 });    
  11.        
  12.     }
Parsed in 0.031 seconds, using GeSHi 1.0.8.4
xiaodar
Junior Developer
Junior Developer
 
Posts: 16
Joined: Wed Mar 24, 2010 9:51 am

Top

Re: how to remove overlay on map

Postby nicholas.hauschild » Sat Jul 17, 2010 9:41 pm

I believe that you can do this by clearing your itemizedOverlay2 before you add the new OverlayItem to it. BUT!, in the process of removing it, I think you will also need to call something like setLastIndex(-1) or something (I forget what it is, but it should be easy to find with a Google search)
nicholas.hauschild
Master Developer
Master Developer
 
Posts: 310
Joined: Fri Dec 04, 2009 4:50 am

Re: how to remove overlay on map

Postby xiaodar » Mon Jul 19, 2010 1:46 am

nicholas.hauschild wrote:I believe that you can do this by clearing your itemizedOverlay2 before you add the new OverlayItem to it. BUT!, in the process of removing it, I think you will also need to call something like setLastIndex(-1) or something (I forget what it is, but it should be easy to find with a Google search)



ok thank you i'll check it out on google
thanks mate
xiaodar
Junior Developer
Junior Developer
 
Posts: 16
Joined: Wed Mar 24, 2010 9:51 am

Re: how to remove overlay on map

Postby endhck » Thu Jul 22, 2010 3:15 pm

At the top of your click method, you can add this line:
mapView.getOverlays().clear();
So, firstly all overlay items are removed and then you can add new one.
endhck
Junior Developer
Junior Developer
 
Posts: 13
Joined: Tue Jul 06, 2010 3:20 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: Google Feedfetcher and 2 guests