开发者

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 i开发者_C百科t 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


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 )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜