I'm developing an app which needs to rotate the mapView with a compass. I know how to rotate the camera but I need to rotate the mapView with the compass. the center point should be the current location. I found codes for Maps V1 but I need to do it with Maps V2
相关问题
- 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
OK, i figured it out myself. first you need to calculate the bearing from the compass. then the Maps api-2 camera can be rotated.
set
SensorListener
in your code and call this method inonSensorChanged
event. i have added a tilt value so the map will rotate in 3D.in your GoogleMap object you can access getMyLocation method. This last returns a Location object which contains getBearing method. This one returns a float [0..360] computed from last known location and current location, 0° is the north axis, rotation is in the clock sens.
To resume, you can use a code like: