hwrdprkns
hwrdprkns

Reputation: 7585

How to pass Itemized Overlay from a class to a Listener Class

I tried searching the forums on this one, but I wasn't able to find anything on my problem.

To describe my problem, everytime my location changes, it redraws the center maker on the map.... Only catch is that it doesn't delete the previous one. I can get it to delete the previous one when the location is changed, but I have no idea how to pass the original overlay in-between classes.

Also, pastebin here

Thanks in advance, hwrd

Upvotes: 0

Views: 561

Answers (1)

Soumya Simanta
Soumya Simanta

Reputation: 11751

You need to clear "existing" items in the Overlay list before adding new ones.

public void createOverlay(GeoPoint point, MapView mv) { //Make overlay reference declaration List mapOverlays = mv.getOverlays(); Drawable drawable = this.getResources().getDrawable(R.drawable.center_marker); FindScreenOverlays itemizedoverlay = new FindScreenOverlays(drawable);

               OverlayItem overlayitem = new OverlayItem(point,null,null);

               //clear your list before adding new overlays unless you want to see all the previous locations as well. 
               itemizedoverlay.addOverlay(overlayitem);
               mapOverlays.add(itemizedoverlay);
    }

Adding an OverlayItem is similar to adding an overlay. Just extend ItemizedOverlay. ( public class YourItemizedOverlay extends ItemizedOverlay )

Upvotes: 1

Related Questions