2016-04-20 56 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法)之内。