1

I am trying to restrict the user going beyond the specified city boundary. In leaflet I have achieved this with maxBounds property of map object or with setMaxBounds function by providing southwest & northeast points., this way it limits scrolling/zooming beyond that city boundary.

Is there any way like above to restrict scrolling/zooming of Google map in android?

Viththal Joshi
  • 113
  • 1
  • 3
  • 11

1 Answers1

5

The latest version of GoogleMaps has added these features, see the blogpost here. In gradle just set: compile 'com.google.android.gms:play-services:9.4.0' or compile 'com.google.android.gms:play-services-maps:9.4.0' depending on which library you're using.

The methods you'll be interested in are:

GoogleMap.setMinZoomPreference(float minZoomPreference)
GoogleMap.setMaxZoomPreference(float maxZoomPreference)
GoogleMap.setLatLngBoundsForCameraTarget(LatLngBounds bounds)
dr_sulli
  • 893
  • 10
  • 21