如何限制androidgoogle地图到一个城市?

How to restrict android google map to a city?

我如何限制 android google 地图到城市?
我目前正在关注显示 google 地图的代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);
}

我只想显示一个城市。有什么办法吗?

使用官方文档 restrict the user's panning to a given area

限制用户。

更新您的 Play 服务的依赖项:

dependencies {
    compile 'com.google.android.gms:play-services:9.6.1'
}

你可以disable scroll gesture like in this answer of madhu sudhan:

mGoogleMap.getUiSettings().setScrollGesturesEnabled(false);

其中 mGoogleMap - GoogleMap class 的对象。

private static final LatLngBounds DUBAI_BOUNDS = new LatLngBounds(new LatLng(24.5908366068, 54.84375),
            new LatLng(25.3303729706, 55.6835174561));


map.setLatLngBoundsForCameraTarget(DUBAI_BOUNDS);