音量键+谷歌地图V2 [英] Volume Keys + Google maps V2

查看:202
本文介绍了音量键+谷歌地图V2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何使android上的谷歌地图V2通过点击音量键来放大/缩小?

Does anyone knows how to make a google maps V2 on android to zoom in/out by clicking on the Volume keys?

我用这个code,但它不工作:

I use this code but it does not work :

     @Override
    public boolean dispatchKeyEvent(KeyEvent event)
    {
        if (mUseVolumeKeys)
        {
            int action = event.getAction();
            int keyCode = event.getKeyCode();
            switch (keyCode)
            {
                case KeyEvent.KEYCODE_VOLUME_UP:
                    if (action == KeyEvent.ACTION_UP)
                    {
                        if (mMap != null)
                        {
                            mMap.zoomIn();
                        }
                    }
                    return true;
                case KeyEvent.KEYCODE_VOLUME_DOWN:
                    if (action == KeyEvent.ACTION_DOWN)
                    {
                        if (mMap != null)
                        {
                            mMap.zoomOut();
                        }
                    }
                    return true;
            }
        }

我对Mmap.zoomIn /出一个错误,指出
     该方法zoomIn()是未定义的类型的GoogleMap

I have an error on the Mmap.zoomIn / out that says The method zoomIn() is undefined for the type GoogleMap

谢谢!

推荐答案

有没有 zoomIn()在地图上V2方法。

There is no zoomIn() method on Maps V2.

如果你想放大,获得通过当前的相机位置 getCameraPosition(),更新其缩放,和然后用 moveCamera() animateCamera()更改为修改后的 CameraPosition

If you want to zoom, get the current camera position via getCameraPosition(), update its zoom, and then use moveCamera() or animateCamera() to change to your revised CameraPosition.

这篇关于音量键+谷歌地图V2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆