I'm developing an Android app that is supposed to use Google Maps v2. Now i'm stuck at finding when zoom level of map has changed. Can anyone help me?Thanks in advance.
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Since previous answers are based on
OnCameraChangeListener
and that is deprecated, this answer is based on camerasetOnCameraMoveListener
.In this example, I am changing my Map Type when user changes the zoom (using controls or fingers and zooming). If zoom level changes above 18.0, map type changes to
MAP_TYPE_HYBRIB
and if it goes below 18.0, map type changes toMAP_TYPE_NORMAL
.Create an implementation of
OnCameraChangeListener
, and pass an instance of it tosetOnCameraChangeListener()
of yourGoogleMap
. Your listener should be called withonCameraChange()
whenever the user changes the zoom, center, or tilt. You find out the new zoom level from theCameraPosition
object that you are passed.If you're looking for how to determine if the zoom level has changed from the previous zoom level, here's what I'd suggest:
Define an instance variable to keep track of the previous zoom level:
Also, define an instance variable to let you know if the map is zooming:
When you setup your GoogleMap instance, give it an OnCameraChangeListener...
Now, define the OnCameraChangeListener that will determine if the zoom level has changed:
Now, you can check the value of isZooming to know if you are changing zoom levels.
Make sure to set
after you've completed whatever action relies on knowing if the map is zooming.