0

How can i restrict android google map to a city?
I am currently following code for show google map:

@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);
}

I want to show just a city. Any way?

emen
  • 170
  • 2
  • 19

3 Answers3

2

Use official document restrict the user's panning to a given area

To restrict user.

update the dependencies for your Play Services:

dependencies {
    compile 'com.google.android.gms:play-services:9.6.1'
}
vishal jangid
  • 2,967
  • 16
  • 22
  • Hey man thx for answer but i want to user won't to another positions just see for example Adelaide on map and can not move to another places just zoom in and zoom out on Adelaide. – emen Aug 17 '17 at 08:00
1

You can disable scroll gesture like in this answer of madhu sudhan:

mGoogleMap.getUiSettings().setScrollGesturesEnabled(false);

where mGoogleMap - object of GoogleMap class.

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79
1
private static final LatLngBounds DUBAI_BOUNDS = new LatLngBounds(new LatLng(24.5908366068, 54.84375),
            new LatLng(25.3303729706, 55.6835174561));


map.setLatLngBoundsForCameraTarget(DUBAI_BOUNDS);
Igor Drozdov
  • 14,690
  • 5
  • 37
  • 53
prakash
  • 162
  • 3