0

我的MapActivity記錄多段線很好,但是當我翻轉屏幕並且方向改變時,折線消失了嗎?什麼可能導致這個?這裏是我的代碼是記錄多段線:方向變化時Polyline消失 - Android - GMaps V2

Location lastLocationloc; 
private GoogleMap myMap; 
@Override 
public void onLocationChanged(Location location) { 
    if (lastLocationloc == null) { 
     lastLocationloc = location; 
    } 
    LatLng lastLatLng = locationToLatLng(lastLocationloc); 
    LatLng thisLatLng = locationToLatLng(location); 
    //Log.e(TAG, "Last LatLng is :"+lastLatLng); 
    //Log.e(TAG, "Last LatLng is :"+thisLatLng); 
    myMap.addPolyline(new PolylineOptions().add(lastLatLng).add(thisLatLng).width(10).color(Color.RED)); 
    lastLocationloc = location; 
} 

我該如何防止這種情況發生?

回答