2011-05-02 124 views
-1

我想從我的mapview中刪除一個添加的Overlay項目,在這裏我們與代碼一起去,但它沒有刪除over lay項目爲什麼這麼做?cant刪除覆蓋項目?

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 * 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(); 
     } 
+0

重複http://stackoverflow.com/questions/5851437/how-to-make-a-loop-的過myoverlay項。在過去的幾天裏,你已經在身份的'fofo',jojo'和現在'koko'下一次又一次地提出了同樣的問題。你沒有接受任何根據這些身份給予你的完美答案。這不是在Stackoverflow上尋求幫助的方法。 – NickT 2011-05-02 19:34:21

回答

2

我想你應該去掉覆蓋項目,不是的GeoPoint:

mapView.getOverlays().remove(itemizedOverlay);