问题描述
|
删除特定叠加项目的命令是什么?
如果这是我添加项目的代码
public void addOverLays(){
String [] coordinates = {\"30.084262490272522\",\"31.33625864982605\",\"30.084123015403748\",\"51.5002\",\"-0.1262\",\"31.337149143218994\"};
double lat = 30.084262490272522,lat2 = 51.5002,lat3=29.987091422080994;
double log = 31.33625864982605,log2 = -0.1262,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.ballon);
drawable2 = this.getResources().getDrawable(R.drawable.ballon);
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);
解决方法
用remove()替换add():
mapView.getOverlays().remove(<putYourOverlayHere>);
mapView.invalidate();