Google 单击 MapView v2 后打开地图
Google Maps opens after click on MapView v2
我一直在努力让 MapView 不可点击。我希望有人也遇到过这个问题。
这是我的代码:
<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);
只有在我使用精简模式时才会出现这种情况。在普通模式下,它不可点击。
提前致谢:)
在 getMapAsync
回调(onMapReady
方法)中设置 mapView.setClickable(false)
。
考虑到您在 activity 中使用它。您可以执行以下操作
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
}
}
我也有这个问题。解决这个问题的方法是像这样覆盖 onMapClick 侦听器:
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
//do nothing, we want to suppress launching Google Maps
}
});
我一直在努力让 MapView 不可点击。我希望有人也遇到过这个问题。
这是我的代码:
<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);
只有在我使用精简模式时才会出现这种情况。在普通模式下,它不可点击。
提前致谢:)
在 getMapAsync
回调(onMapReady
方法)中设置 mapView.setClickable(false)
。
考虑到您在 activity 中使用它。您可以执行以下操作
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
}
}
我也有这个问题。解决这个问题的方法是像这样覆盖 onMapClick 侦听器:
mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
@Override
public void onMapClick(LatLng latLng) {
//do nothing, we want to suppress launching Google Maps
}
});