2013-03-01 19 views
10

Googleの開発者のウェブサイトと同じようにポリラインオプションを追加しています。ポリラインを削除する際の問題Googleマップv2 android

PolylineOptions rectOptions = new PolylineOptions() 
     .add(new LatLng(37.35, -122.0)) 
     .add(new LatLng(37.45, -122.0)) // North of the previous point, but at the same longitude 
     .add(new LatLng(37.45, -122.2)) // Same latitude, and 30km to the west 
     .add(new LatLng(37.35, -122.2)) // Same longitude, and 16km to the south 
     .add(new LatLng(37.35, -122.0)); // Closes the polyline. 

// Get back the mutable Polyline 
Polyline polyline = myMap.addPolyline(rectOptions); 

削除します。しかし、ないrectOptions.remove() 私は私のSDKからGoogle Maps Android API v2, how to remove Polylines from the map? で述べたようにGoogleの再生サービスを更新しましたが、まだ私はそれを持っていません。ちょうどSDKマネージャからそれを更新した後に何かをする必要がありますか?私は本当にそれを削除する必要があり、私は多くのポイントと多くの時間のパスを表示する原因をメモリを節約するために見えないようにしないでください。

答えて

11

あなたはそれを削除するPolylineOptionsを使用してはならないpolyline.remove();

+0

よう

使用PolyLine。 remove()を使用することはできません。削除はPolylineオブジェクトに対してのみ定義されているので、この1つを使用しました。 –

+0

PolylineOptionsは、ポリラインの初期化を簡単にするのに役立ちます(他の* Optionsクラスでも同じです)。ポリラインそのもののポリラインの操作はすべて行う必要があります。 – Mokus

+0

@Mokus私はポリゴンを持っていますが、私はあなたが答えを投稿するのと同じことをやっていますが、それはマップからマップを削除しません。どのように私はそれをリフレッシュできますか? [docを見る](https://developers.google.com/maps/documentation/android/reference/com/google/android/gms/maps/model/Polygon#remove%28%29) –

2

を使用し、Polylineを削除します。ですから、PolylineOptions xに宣言するとき、私は推測する。この

polyline.remove(); 

Documentation

public void remove() 

Removes this polyline from the map. After a polyline has been removed, the behavior of all its methods is undefined.

+0

はい私はそれを得た。私はポリラインに変更しました。ありがとうMitesh –

関連する問題