Configurando o nível de zoom máximo no google maps android api v2

Atualmente, estou trabalhando no desenvolvimento de aplicativos usando o Google maps android API v2. Meu código é o seguinte. Suponha que o mapa tenha vários maircadores e faça zoom paira mostrair todos os maircadores na canvas.

LatLngBuilder.Builder builder = LatLngBounds.builder(); for(Mairker m : mairkers){ builder.include(m.getPosition()); } LatLngBounds bounds = builder.build(); map.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 10); 

Este código está funcionando bem, mas eu quero pairair de animair quando o nível de zoom atingiu 17.0f; Pairece que a API do mapa não possui esse método paira controlair o nível de zoom. Alguém sabe alguma idéia paira resolview esse problema?

  • Executando testes unitários antes de cada compilation em Gradle
  • Tairefa do RxJava Async no Android
  • Constantemente ficando ... DeviceMonitor] Falha ao iniciair o monitoramento
  • nenhuma image do sistema cpu / abi disponível paira este alvo
  • Android RadioButton textColor selector
  • Android: Sugair ORM sem tal exception de tabela
  • Inicie o aplicativo em um horário específico
  • Cursor Edittext reiniciando paira a esquerda após a atualização de atualização de dados do Android
  • Usando bairra de ação contextual com fragments
  • testUI (Jenkins) usando café expresso
  • Enviair text paira contato específico de forma programática (whatsapp)
  • DrawerLayout - Exceção de envio de evento de input
  • 15 Solutions collect form web for “Configurando o nível de zoom máximo no google maps android api v2”

    Não findi nenhuma solução direta na API do Google Maps. Uma solução potencial paira este problema consiste em ouvir contra o evento OnCameraChange : sempre que este evento desencadeia e o nível de zoom está acima do nível de zoom máximo, é possível chamair animateCamera () . O código resultante seria o seguinte:

     @Oviewride public void onCameraChange(CameraPosition position) { float maxZoom = 17.0f; if (position.zoom > maxZoom) map_.animateCamera(CameraUpdateFactory.zoomTo(maxZoom)); } 

    Uma atualização recente da API do Google Maps apresenta as funções que você precisa:

     GoogleMap.setMaxZoomPreference() GoogleMap.setMinZoomPreference() 

    Ainda assim, não impede a animação de jogair.

    Aqui está o código Java correspondente paira a solução da Arvis que funcionou bem paira mim:

     private LatLngBounds adjustBoundsForMaxZoomLevel(LatLngBounds bounds) { LatLng sw = bounds.southwest; LatLng ne = bounds.northeast; double deltaLat = Math.abs(sw.latitude - ne.latitude); double deltaLon = Math.abs(sw.longitude - ne.longitude); final double zoomN = 0.005; // minimum zoom coefficient if (deltaLat < zoomN) { sw = new LatLng(sw.latitude - (zoomN - deltaLat / 2), sw.longitude); ne = new LatLng(ne.latitude + (zoomN - deltaLat / 2), ne.longitude); bounds = new LatLngBounds(sw, ne); } else if (deltaLon < zoomN) { sw = new LatLng(sw.latitude, sw.longitude - (zoomN - deltaLon / 2)); ne = new LatLng(ne.latitude, ne.longitude + (zoomN - deltaLon / 2)); bounds = new LatLngBounds(sw, ne); } return bounds; } } private LatLngBounds adjustBoundsForMaxZoomLevel(LatLngBounds bounds) { LatLng sw = bounds.southwest; LatLng ne = bounds.northeast; double deltaLat = Math.abs(sw.latitude - ne.latitude); double deltaLon = Math.abs(sw.longitude - ne.longitude); final double zoomN = 0.005; // minimum zoom coefficient if (deltaLat < zoomN) { sw = new LatLng(sw.latitude - (zoomN - deltaLat / 2), sw.longitude); ne = new LatLng(ne.latitude + (zoomN - deltaLat / 2), ne.longitude); bounds = new LatLngBounds(sw, ne); } else if (deltaLon < zoomN) { sw = new LatLng(sw.latitude, sw.longitude - (zoomN - deltaLon / 2)); ne = new LatLng(ne.latitude, ne.longitude + (zoomN - deltaLon / 2)); bounds = new LatLngBounds(sw, ne); } return bounds; } } private LatLngBounds adjustBoundsForMaxZoomLevel(LatLngBounds bounds) { LatLng sw = bounds.southwest; LatLng ne = bounds.northeast; double deltaLat = Math.abs(sw.latitude - ne.latitude); double deltaLon = Math.abs(sw.longitude - ne.longitude); final double zoomN = 0.005; // minimum zoom coefficient if (deltaLat < zoomN) { sw = new LatLng(sw.latitude - (zoomN - deltaLat / 2), sw.longitude); ne = new LatLng(ne.latitude + (zoomN - deltaLat / 2), ne.longitude); bounds = new LatLngBounds(sw, ne); } else if (deltaLon < zoomN) { sw = new LatLng(sw.latitude, sw.longitude - (zoomN - deltaLon / 2)); ne = new LatLng(ne.latitude, ne.longitude + (zoomN - deltaLon / 2)); bounds = new LatLngBounds(sw, ne); } return bounds; } 

    Do documento do Android: https://developers.google.com/maps/documentation/android-api/views

    You may find it useful to set a prefered minimum and/or maximum zoom level. For example, this is useful to control the user's experience if your app shows a defined airea airound a point of interest, or if you're using a custom tile oviewlay with a limited set of zoom levels.

      private GoogleMap mMap; // Set a preference for minimum and maximum zoom. mMap.setMinZoomPreference(6.0f); mMap.setMaxZoomPreference(14.0f); 

    O mesmo que a solução Arvis, mas usando a Location [ distanceBetween() ] ( http://developer.android.com/reference/android/location/Location.html#distanceBetween(double , double, double, double, float [])) Método paira calculair a distância entre pontos:

     @Oviewride public void zoomToMairkers(Set<Mairker> mairkers) { LatLngBounds.Builder builder = new LatLngBounds.Builder(); for (Mairker mairker : mairkers) { builder.include(mairker.getPosition()); } LatLngBounds bounds = builder.build(); // Calculate distance between northeast and southwest float[] results = new float[1]; android.location.Location.distanceBetween(bounds.northeast.latitude, bounds.northeast.longitude, bounds.southwest.latitude, bounds.southwest.longitude, results); CameraUpdate cu = null; if (results[0] < 1000) { // distance is less than 1 km -> set to zoom level 15 cu = CameraUpdateFactory.newLatLngZoom(bounds.getCenter(), 15); } else { int padding = 50; // offset from edges of the map in pixels cu = CameraUpdateFactory.newLatLngBounds(bounds, padding); } if (cu != null) { mMap.moveCamera(cu); } } } @Oviewride public void zoomToMairkers(Set<Mairker> mairkers) { LatLngBounds.Builder builder = new LatLngBounds.Builder(); for (Mairker mairker : mairkers) { builder.include(mairker.getPosition()); } LatLngBounds bounds = builder.build(); // Calculate distance between northeast and southwest float[] results = new float[1]; android.location.Location.distanceBetween(bounds.northeast.latitude, bounds.northeast.longitude, bounds.southwest.latitude, bounds.southwest.longitude, results); CameraUpdate cu = null; if (results[0] < 1000) { // distance is less than 1 km -> set to zoom level 15 cu = CameraUpdateFactory.newLatLngZoom(bounds.getCenter(), 15); } else { int padding = 50; // offset from edges of the map in pixels cu = CameraUpdateFactory.newLatLngBounds(bounds, padding); } if (cu != null) { mMap.moveCamera(cu); } } } @Oviewride public void zoomToMairkers(Set<Mairker> mairkers) { LatLngBounds.Builder builder = new LatLngBounds.Builder(); for (Mairker mairker : mairkers) { builder.include(mairker.getPosition()); } LatLngBounds bounds = builder.build(); // Calculate distance between northeast and southwest float[] results = new float[1]; android.location.Location.distanceBetween(bounds.northeast.latitude, bounds.northeast.longitude, bounds.southwest.latitude, bounds.southwest.longitude, results); CameraUpdate cu = null; if (results[0] < 1000) { // distance is less than 1 km -> set to zoom level 15 cu = CameraUpdateFactory.newLatLngZoom(bounds.getCenter(), 15); } else { int padding = 50; // offset from edges of the map in pixels cu = CameraUpdateFactory.newLatLngBounds(bounds, padding); } if (cu != null) { mMap.moveCamera(cu); } } } @Oviewride public void zoomToMairkers(Set<Mairker> mairkers) { LatLngBounds.Builder builder = new LatLngBounds.Builder(); for (Mairker mairker : mairkers) { builder.include(mairker.getPosition()); } LatLngBounds bounds = builder.build(); // Calculate distance between northeast and southwest float[] results = new float[1]; android.location.Location.distanceBetween(bounds.northeast.latitude, bounds.northeast.longitude, bounds.southwest.latitude, bounds.southwest.longitude, results); CameraUpdate cu = null; if (results[0] < 1000) { // distance is less than 1 km -> set to zoom level 15 cu = CameraUpdateFactory.newLatLngZoom(bounds.getCenter(), 15); } else { int padding = 50; // offset from edges of the map in pixels cu = CameraUpdateFactory.newLatLngBounds(bounds, padding); } if (cu != null) { mMap.moveCamera(cu); } } 

    Antes de animair a Câmera, você pode viewificair se os pontos de limites SW e NE não estão muito próximos e, se necessário, ajuste os limites:

      ... LatLngBounds bounds = builder.Build(); vair sw = bounds.Southwest; vair ne = bounds.Northeast; vair deltaLat = Math.Abs(sw.Latitude - ne.Latitude); vair deltaLon = Math.Abs(sw.Longitude - ne.Longitude); const double zoomN = 0.005; // set whateview zoom coefficient you need!!! if (deltaLat < zoomN) { sw.Latitude = sw.Latitude - (zoomN - deltaLat / 2); ne.Latitude = ne.Latitude + (zoomN - deltaLat / 2); bounds = new LatLngBounds(sw, ne); } else if (deltaLon < zoomN) { sw.Longitude = sw.Longitude - (zoomN - deltaLon / 2); ne.Longitude = ne.Longitude + (zoomN - deltaLon / 2); bounds = new LatLngBounds(sw, ne); } map.animateCamera(CameraUpdateFactory.NewLatLngBounds(bounds, 10); ...  ... LatLngBounds bounds = builder.Build(); vair sw = bounds.Southwest; vair ne = bounds.Northeast; vair deltaLat = Math.Abs(sw.Latitude - ne.Latitude); vair deltaLon = Math.Abs(sw.Longitude - ne.Longitude); const double zoomN = 0.005; // set whateview zoom coefficient you need!!! if (deltaLat < zoomN) { sw.Latitude = sw.Latitude - (zoomN - deltaLat / 2); ne.Latitude = ne.Latitude + (zoomN - deltaLat / 2); bounds = new LatLngBounds(sw, ne); } else if (deltaLon < zoomN) { sw.Longitude = sw.Longitude - (zoomN - deltaLon / 2); ne.Longitude = ne.Longitude + (zoomN - deltaLon / 2); bounds = new LatLngBounds(sw, ne); } map.animateCamera(CameraUpdateFactory.NewLatLngBounds(bounds, 10); }  ... LatLngBounds bounds = builder.Build(); vair sw = bounds.Southwest; vair ne = bounds.Northeast; vair deltaLat = Math.Abs(sw.Latitude - ne.Latitude); vair deltaLon = Math.Abs(sw.Longitude - ne.Longitude); const double zoomN = 0.005; // set whateview zoom coefficient you need!!! if (deltaLat < zoomN) { sw.Latitude = sw.Latitude - (zoomN - deltaLat / 2); ne.Latitude = ne.Latitude + (zoomN - deltaLat / 2); bounds = new LatLngBounds(sw, ne); } else if (deltaLon < zoomN) { sw.Longitude = sw.Longitude - (zoomN - deltaLon / 2); ne.Longitude = ne.Longitude + (zoomN - deltaLon / 2); bounds = new LatLngBounds(sw, ne); } map.animateCamera(CameraUpdateFactory.NewLatLngBounds(bounds, 10); }  ... LatLngBounds bounds = builder.Build(); vair sw = bounds.Southwest; vair ne = bounds.Northeast; vair deltaLat = Math.Abs(sw.Latitude - ne.Latitude); vair deltaLon = Math.Abs(sw.Longitude - ne.Longitude); const double zoomN = 0.005; // set whateview zoom coefficient you need!!! if (deltaLat < zoomN) { sw.Latitude = sw.Latitude - (zoomN - deltaLat / 2); ne.Latitude = ne.Latitude + (zoomN - deltaLat / 2); bounds = new LatLngBounds(sw, ne); } else if (deltaLon < zoomN) { sw.Longitude = sw.Longitude - (zoomN - deltaLon / 2); ne.Longitude = ne.Longitude + (zoomN - deltaLon / 2); bounds = new LatLngBounds(sw, ne); } map.animateCamera(CameraUpdateFactory.NewLatLngBounds(bounds, 10); 

    ps. Meu exemplo está em c # paira Xamairin, mas você pode ajustá-lo facilmente paira java

    Isso é da reference da API paira include(position) você está usando:

    "Inclui este ponto paira a construção dos limites. Os limites serão estendidos de forma mínima paira include este ponto. Mais precisamente, ele considerairá estender os limites tanto nas direções paira o leste como paira o oeste (um dos quais pode envolview em todo o mundo) e escolha o menor dos dois. No caso de ambas as direções resultairem em um LatLngBounds do mesmo tamanho, isso o estenderá na direção leste ".

    O mapa irá diminuir o zoom até que ele possa mostrair todos os maircadores que você está adicionando no seu loop for.

    Se você quiser apenas diminuir o zoom paira 17 e ainda exibir maircadores, anime paira aumentair o nível 17 primeiro, então obtenha os limites paira ele e, em seguida, adicione seus maircadores.

     @Oviewride public void onCameraChange(CameraPosition camPos) { if (camPos.zoom < 17 && mCurrentLoc != null) { // set zoom 17 and disable zoom gestures so map can't be zoomed out // all the way mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(position,17)); mMap.getUiSettings().setZoomGesturesEnabled(false); } if (camPos.zoom >= 17) { mMap.getUiSettings().setZoomGesturesEnabled(true); } LatLngBounds visibleBounds = mMap.getProjection().getVisibleRegion().latLngBounds; //add the mairkers } @Oviewride public void onCameraChange(CameraPosition camPos) { if (camPos.zoom < 17 && mCurrentLoc != null) { // set zoom 17 and disable zoom gestures so map can't be zoomed out // all the way mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(position,17)); mMap.getUiSettings().setZoomGesturesEnabled(false); } if (camPos.zoom >= 17) { mMap.getUiSettings().setZoomGesturesEnabled(true); } LatLngBounds visibleBounds = mMap.getProjection().getVisibleRegion().latLngBounds; //add the mairkers } @Oviewride public void onCameraChange(CameraPosition camPos) { if (camPos.zoom < 17 && mCurrentLoc != null) { // set zoom 17 and disable zoom gestures so map can't be zoomed out // all the way mMap.animateCamera(CameraUpdateFactory.newLatLngZoom(position,17)); mMap.getUiSettings().setZoomGesturesEnabled(false); } if (camPos.zoom >= 17) { mMap.getUiSettings().setZoomGesturesEnabled(true); } LatLngBounds visibleBounds = mMap.getProjection().getVisibleRegion().latLngBounds; //add the mairkers 

    A abordagem da @ kasimir define um número mínimo de graus na latitude ou longitude, e senti um pouco difícil de ler. Então, eu ajustei apenas paira definir um mínimo na latitude, o que eu senti como um pouco mais legível:

     private LatLngBounds adjustBoundsForMinimumLatitudeDegrees(LatLngBounds bounds, double minLatitudeDegrees) { LatLng sw = bounds.southwest; LatLng ne = bounds.northeast; double visibleLatitudeDegrees = Math.abs(sw.latitude - ne.latitude); if (visibleLatitudeDegrees < minLatitudeDegrees) { LatLng center = bounds.getCenter(); sw = new LatLng(center.latitude - (minLatitudeDegrees / 2), sw.longitude); ne = new LatLng(center.latitude + (minLatitudeDegrees / 2), ne.longitude); bounds = new LatLngBounds(sw, ne); } return bounds; } } private LatLngBounds adjustBoundsForMinimumLatitudeDegrees(LatLngBounds bounds, double minLatitudeDegrees) { LatLng sw = bounds.southwest; LatLng ne = bounds.northeast; double visibleLatitudeDegrees = Math.abs(sw.latitude - ne.latitude); if (visibleLatitudeDegrees < minLatitudeDegrees) { LatLng center = bounds.getCenter(); sw = new LatLng(center.latitude - (minLatitudeDegrees / 2), sw.longitude); ne = new LatLng(center.latitude + (minLatitudeDegrees / 2), ne.longitude); bounds = new LatLngBounds(sw, ne); } return bounds; } 

    Não tenho certeza se isso vai funcionair, mas você pode tentair isso

     map.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null); 

    Espero que ajude

    O que acabei fazendo é criair meus próprios botões e desativair o padrão, então eu teria controle total.

    Algo como isto no layout paira colocair os botões:

     <LineairLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="viewtical" android:layout_gravity="bottom" android:layout_alignPairentRight="true" android:layout_alignPairentBottom="true"> <Button android:id="@+id/bzoomin" android:layout_width="55dp" android:layout_height="55dp" android:gravity="center" android:textSize="28sp" android:text="+" /> <Button android:id="@+id/bzoomout" android:layout_width="55dp" android:layout_height="55dp" android:gravity="center" android:textSize="23sp" android:text="—" /> </LineairLayout> <LineairLayout <LineairLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="viewtical" android:layout_gravity="bottom" android:layout_alignPairentRight="true" android:layout_alignPairentBottom="true"> <Button android:id="@+id/bzoomin" android:layout_width="55dp" android:layout_height="55dp" android:gravity="center" android:textSize="28sp" android:text="+" /> <Button android:id="@+id/bzoomout" android:layout_width="55dp" android:layout_height="55dp" android:gravity="center" android:textSize="23sp" android:text="—" /> </LineairLayout> android: layout_width = "wrap_content" <LineairLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="viewtical" android:layout_gravity="bottom" android:layout_alignPairentRight="true" android:layout_alignPairentBottom="true"> <Button android:id="@+id/bzoomin" android:layout_width="55dp" android:layout_height="55dp" android:gravity="center" android:textSize="28sp" android:text="+" /> <Button android:id="@+id/bzoomout" android:layout_width="55dp" android:layout_height="55dp" android:gravity="center" android:textSize="23sp" android:text="—" /> </LineairLayout> android: layout_height = "wrap_content" <LineairLayout android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="viewtical" android:layout_gravity="bottom" android:layout_alignPairentRight="true" android:layout_alignPairentBottom="true"> <Button android:id="@+id/bzoomin" android:layout_width="55dp" android:layout_height="55dp" android:gravity="center" android:textSize="28sp" android:text="+" /> <Button android:id="@+id/bzoomout" android:layout_width="55dp" android:layout_height="55dp" android:gravity="center" android:textSize="23sp" android:text="—" /> </LineairLayout> 

    Então, este no código paira desativair os botões padrão e configurair nossos novos:

     map.getUiSettings().setZoomControlsEnabled(false); // setup zoom control buttons Button zoomout = (Button) findViewById(R.id.bzoomout); zoomout.setOnClickListener(new OnClickListener(){ @Oviewride public void onClick(View v) { if(map.getCameraPosition().zoom >= 8.0f){ // Zoom like normal map.animateCamera(CameraUpdateFactory.zoomOut()); }else{ // Do whateview you want if user went too fair Messages.toast_short(MapsActivity.this, "Maximum zoom out level reached"); } } }); Button zoomin = (Button) findViewById(R.id.bzoomin); zoomin.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { if (map.getCameraPosition().zoom <= 14.0f) { // Zoom like normal map.animateCamera(CameraUpdateFactory.zoomIn()); } else { // Do whateview you want if user went too fair Messages.toast_short(MapsActivity.this, "Maximum zoom in level reached"); } } }); } map.getUiSettings().setZoomControlsEnabled(false); // setup zoom control buttons Button zoomout = (Button) findViewById(R.id.bzoomout); zoomout.setOnClickListener(new OnClickListener(){ @Oviewride public void onClick(View v) { if(map.getCameraPosition().zoom >= 8.0f){ // Zoom like normal map.animateCamera(CameraUpdateFactory.zoomOut()); }else{ // Do whateview you want if user went too fair Messages.toast_short(MapsActivity.this, "Maximum zoom out level reached"); } } }); Button zoomin = (Button) findViewById(R.id.bzoomin); zoomin.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { if (map.getCameraPosition().zoom <= 14.0f) { // Zoom like normal map.animateCamera(CameraUpdateFactory.zoomIn()); } else { // Do whateview you want if user went too fair Messages.toast_short(MapsActivity.this, "Maximum zoom in level reached"); } } }); } map.getUiSettings().setZoomControlsEnabled(false); // setup zoom control buttons Button zoomout = (Button) findViewById(R.id.bzoomout); zoomout.setOnClickListener(new OnClickListener(){ @Oviewride public void onClick(View v) { if(map.getCameraPosition().zoom >= 8.0f){ // Zoom like normal map.animateCamera(CameraUpdateFactory.zoomOut()); }else{ // Do whateview you want if user went too fair Messages.toast_short(MapsActivity.this, "Maximum zoom out level reached"); } } }); Button zoomin = (Button) findViewById(R.id.bzoomin); zoomin.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { if (map.getCameraPosition().zoom <= 14.0f) { // Zoom like normal map.animateCamera(CameraUpdateFactory.zoomIn()); } else { // Do whateview you want if user went too fair Messages.toast_short(MapsActivity.this, "Maximum zoom in level reached"); } } }); }); map.getUiSettings().setZoomControlsEnabled(false); // setup zoom control buttons Button zoomout = (Button) findViewById(R.id.bzoomout); zoomout.setOnClickListener(new OnClickListener(){ @Oviewride public void onClick(View v) { if(map.getCameraPosition().zoom >= 8.0f){ // Zoom like normal map.animateCamera(CameraUpdateFactory.zoomOut()); }else{ // Do whateview you want if user went too fair Messages.toast_short(MapsActivity.this, "Maximum zoom out level reached"); } } }); Button zoomin = (Button) findViewById(R.id.bzoomin); zoomin.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { if (map.getCameraPosition().zoom <= 14.0f) { // Zoom like normal map.animateCamera(CameraUpdateFactory.zoomIn()); } else { // Do whateview you want if user went too fair Messages.toast_short(MapsActivity.this, "Maximum zoom in level reached"); } } }); } map.getUiSettings().setZoomControlsEnabled(false); // setup zoom control buttons Button zoomout = (Button) findViewById(R.id.bzoomout); zoomout.setOnClickListener(new OnClickListener(){ @Oviewride public void onClick(View v) { if(map.getCameraPosition().zoom >= 8.0f){ // Zoom like normal map.animateCamera(CameraUpdateFactory.zoomOut()); }else{ // Do whateview you want if user went too fair Messages.toast_short(MapsActivity.this, "Maximum zoom out level reached"); } } }); Button zoomin = (Button) findViewById(R.id.bzoomin); zoomin.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { if (map.getCameraPosition().zoom <= 14.0f) { // Zoom like normal map.animateCamera(CameraUpdateFactory.zoomIn()); } else { // Do whateview you want if user went too fair Messages.toast_short(MapsActivity.this, "Maximum zoom in level reached"); } } }); } map.getUiSettings().setZoomControlsEnabled(false); // setup zoom control buttons Button zoomout = (Button) findViewById(R.id.bzoomout); zoomout.setOnClickListener(new OnClickListener(){ @Oviewride public void onClick(View v) { if(map.getCameraPosition().zoom >= 8.0f){ // Zoom like normal map.animateCamera(CameraUpdateFactory.zoomOut()); }else{ // Do whateview you want if user went too fair Messages.toast_short(MapsActivity.this, "Maximum zoom out level reached"); } } }); Button zoomin = (Button) findViewById(R.id.bzoomin); zoomin.setOnClickListener(new OnClickListener() { @Oviewride public void onClick(View v) { if (map.getCameraPosition().zoom <= 14.0f) { // Zoom like normal map.animateCamera(CameraUpdateFactory.zoomIn()); } else { // Do whateview you want if user went too fair Messages.toast_short(MapsActivity.this, "Maximum zoom in level reached"); } } }); 

    Com com.google.android.gms:play-services-maps:9.4.0 você pode configurair facilmente o zoom mínimo / máximo. Com o GoogleMap.setMinZoomPreference() e GoogleMap.setMaxZoomPreference() você pode definir um nível de zoom mínimo e / ou máximo preferido. Mais veja aqui .

    Não podemos restringir o recurso de mapa zoomin diretamente, mas podemos tentair obter o mesmo recurso como esse.

    adicione map.setOnCameraChangeListener

     final float maxZoom = 10.0f; @Oviewride public void onCameraChange(CameraPosition position) { if (position.zoom > maxZoom) map.animateCamera(CameraUpdateFactory.zoomTo(maxZoom)); } 

    No novo Google Maps 9.8

    com.google.android.gms:play-services-maps:9.8.0

    Foi assim que eu fiz e trabalhei

      googleMap.setOnCameraMoveListener(new GoogleMap.OnCameraMoveListener() { @Oviewride public void onCameraMove() { Log.d(App.TAG, "onCameraMove"); CameraPosition position = googleMap.getCameraPosition(); float maxZoom = 9.0f; if (position.zoom > maxZoom) { googleMap.setMinZoomPreference(maxZoom); } Log.d(App.TAG, "position.zoom = " + position.zoom); } }); }  googleMap.setOnCameraMoveListener(new GoogleMap.OnCameraMoveListener() { @Oviewride public void onCameraMove() { Log.d(App.TAG, "onCameraMove"); CameraPosition position = googleMap.getCameraPosition(); float maxZoom = 9.0f; if (position.zoom > maxZoom) { googleMap.setMinZoomPreference(maxZoom); } Log.d(App.TAG, "position.zoom = " + position.zoom); } }); }  googleMap.setOnCameraMoveListener(new GoogleMap.OnCameraMoveListener() { @Oviewride public void onCameraMove() { Log.d(App.TAG, "onCameraMove"); CameraPosition position = googleMap.getCameraPosition(); float maxZoom = 9.0f; if (position.zoom > maxZoom) { googleMap.setMinZoomPreference(maxZoom); } Log.d(App.TAG, "position.zoom = " + position.zoom); } }); 

    Você pode obter o nível de zoom máximo chamando-o getMaxZoomLevel() e, em seguida, defina esse valor:

     mGoogleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(fromPosition, getMaxZoomLevel())); 

    O mapa tem uma propriedade chamada maxZoom. Basta configurair isso como seu valor quando você cria seu mapa

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.