2016-04-20 51 views
0

我一直在努力使MapView不可點擊。我希望有人也遇到這個問題。谷歌地圖打開後點擊MapView v2

這裏是我的代碼:

<com.google.android.gms.maps.MapView 
    android:id="@+id/map_header" 
    android:layout_width="fill_parent" 
    android:layout_height="90dp" 
    android:clickable="false" 
    android:longClickable="false" 
    map:liteMode="true" 
    map:mapType="normal" 
/> 

另外:

mMap.getUiSettings().setAllGesturesEnabled(false); 
mMap.getUiSettings().setMapToolbarEnabled(false); 
CameraPosition cameraPosition = new CameraPosition.Builder() 
      .target(userLocation) 
      .zoom(16) 
      .build(); 
mMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); 
mProgressBar.setVisibility(View.GONE); 

這隻有當我使用精簡版模式發生。在正常模式下,它不可點擊。

感謝提前:)

回答

0

考慮到您在活動中使用它。你可以做以下

public class MapActivity extends AppCompatActivity implements OnMapReadyCallback { 

    MapView mapView; 

    @Override 
    protected void onCreate(Bundle savedInstanceState) { 
     super.onCreate(savedInstanceState); 
     setContentView(R.layout.activity_map); 

     // Gets the MapView from the XML layout and creates it 
     mapView = (MapView) v.findViewById(R.id.map_header); 
     mapView.setClickable(false); 
     mapView.getMapAsync(this); 
    } 

    @Override 
    public void onMapReady(GoogleMap map) { 
     // Perform action on your map. E.g. Display marker 
    } 
} 
+0

GoogleMap的沒有一個setClickable方法:(編輯:固定它,你需要setClickable(假)上的onCreate的MapView,而不是在GoogleMap的在onMapReady – Ruben2112

+0

@ Ruben2112感謝我建議在飛行中糾正這種錯誤,無論如何,糾正以備將來使用。 –

-1

mapView.setClickable(false)getMapAsync回調(onMapReady法)之內。