cant Remove overlay items?
i want to remove an added Overlay item from my mapview ,here we go with the code but it didnt remove the over lay item why this ?
enter code here
public void addOverLays(){
String [] coordinates = {"31.216487288475037","29.932637214660645" ,"30.084123015403748", "51.5002" , "-0.1262","31.337149143218994"};
double lat = 30.084686279296875,lat2 = 29.987107515335083,lat3=29.987091422080994;
double log = 31.33642494678493, log2 = 31.43912136554718,log3=31.43909454345703;
p = new GeoPoint((int) (lat * 1E6), (int) (log * 1E6));
p2 = new GeoPoint( (int) (lat2开发者_StackOverflow * 1e6), (int) (log2 * 1e6));
p3=new GeoPoint( (int) (lat3 * 1e6), (int) (log3 * 1e6));
mapOverlays = mapView.getOverlays();
drawable = this.getResources().getDrawable(R.drawable.pushpin);
drawable2 = this.getResources().getDrawable(R.drawable.dotred);
drawable3 = this.getResources().getDrawable(R.drawable.ballon);
itemizedOverlay = new HelloItemizedOverlay(drawable,this);
itemizedOverlay2 = new HelloItemizedOverlay(drawable2,this);
itemizedOverlay3 = new HelloItemizedOverlay(drawable3,this);
OverlayItem overlayitem = new OverlayItem(p, "Cairo", " over1");
OverlayItem over2 = new OverlayItem(p2, "ulm", "over2");
OverlayItem over3 = new OverlayItem(p3, "offff", "over3");
itemizedOverlay.addOverlay(overlayitem);
mapOverlays.add(itemizedOverlay);
itemizedOverlay2.addOverlay(over2);
mapOverlays.add(itemizedOverlay2);
itemizedOverlay3.addOverlay(over3);
mapOverlays.add(itemizedOverlay3);
mc.setZoom(17);
mc.animateTo(p1);
mapView.getOverlays().remove(p);
mapView.invalidate();
}
I think you should remove the overlay item, not the geopoint:
mapView.getOverlays().remove(itemizedOverlay);
精彩评论