[問題] 如何刪除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