KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
On GoogleMap android API v2, how do I get the current map zoom level? On API v1, there used to be float MapView.getZoomLevel() , but there appears to be nothing similar on the API version I am using, and that Google recommends. I've thought of using a class variable to save the zoom level manually via a zoom button click listener, but this doesn't solve the problem for pinch-type zooming. Why do I need the current zoom level? I am restricting the map range to a certain rectangle and want any moves that would otherwise leave this rectangle, bounce back. This animation requires me to use a zoom level, for without it, the default maximum zoom level is used. What I really want is to maintain the zoom level used before the move attempt. protected void recenterMap() { map.getMinZoomLevel(); if(MAP_BOUNDS.contains(map.getCameraPosition().target) == false) { CameraPosition cameraPosition = new CameraPosition.Builder() .target(MAP_CENTER) .zoom(current_zoom) .build(); map.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition)); } else { MAP_CENTER = map.getCameraPosition().target; } } Notice that the variable current_zoom is what I need to define.
Tags (comma-separated)
Save Edits
Cancel