[问题] 如何删除google地图上,画的线条

楼主: m4u06 (meleo)   2014-11-30 18:37:04
第一次发文,如有那里说不清楚,请见谅了
最近开始学android,算是出于兴趣,java程度算会基础而已
我想要让我的功能表上
打勾前显示A线(并删掉B线),打勾后显示B地图(并删掉B线)
上网爬了一下文好像跟remove()有关,我试过把remove放各位置
目前的当点选两次后,两条线都会出现,不会把旧的删掉
这是我的程式码,如果知道我的问题请跟我说了,谢谢:)
public boolean onOptionsItemSelected(MenuItem item) {
switch(item.getItemId()){
case R.id.sss;
boolean sss = false;
sss = !sss;
item.setChecked(!sss);
PolylineOptions one = new PolylineOptions();
one.add(new LatLng(25.034026, 121.565435));
one.add(new LatLng(25.032981, 121.565419));
one.add(new LatLng(25.033010, 121.563590));
one.color(Color.RED);
Polyline polylinee = map.addPolyline(one);
PolylineOptions two = new PolylineOptions();
two.add(new LatLng(25.034296, 121.563585));
two.add(new LatLng(25.034981, 121.563601));
two.add(new LatLng(25.034966, 121.564985));
two.color(Color.BLUE);
Polyline polylineeeee = map.addPolyline(two);
polylineeeee.setWidth(10);
if(sss){
polylineeeee.remove(); }
else{
polylinee.remove(); }
break;
}
return super.onOptionsItemSelected(item);
}
作者: changyuheng (张昱珩)   2014-12-01 00:38:00
自己写无妨,但要交流的话应该注意一下 coding style

Links booklink

Contact Us: admin [ a t ] ucptt.com