limit scrolling and zooming Google Maps Android API v2

Constraining the camera has (finally!) been added as a feature as part of the release of Google Play Services 9.4 — you can call setLatLngBoundsForCameraTarget(LatLngBounds bounds) to set the allowed panning area.

// Create a LatLngBounds that includes the city of Adelaide in Australia.
final LatLngBounds ADELAIDE = new LatLngBounds(
    new LatLng(-35.0, 138.58), new LatLng(-34.9, 138.61));

// Constrain the camera target to the Adelaide bounds.
mMap.setLatLngBoundsForCameraTarget(ADELAIDE);

You can find a thorough explanation in the documentation: Restricting the user’s panning to a given area and a sample activity in GitHub.

Leave a Comment