科尔多瓦Google Maps Native Plugin自动旋转标记旋转错误的一面

时间:2018-07-31 06:52:33

标签: google-maps cordova

我正在使用Android 6.0。

我正在使用设备方向事件event.alpha来使设备旋转,当我使设备旋转后,将其设置为标记旋转,但是当我将设备旋转到右侧时标记旋转到一个问题向左旋转,当我向左旋转设备时,标记向右旋转,因此基本上向相反方向旋转。

window.addEventListener("deviceorientation",processEvent, true);
function processEvent(event) {
        if(parseInt(event.alpha) + 180 > 360){
            userPosition.setRotation(parseInt(event.alpha) - 180);
        }else{
            userPosition.setRotation((parseInt(event.alpha) + 180) % 360);
        }

    }

0 个答案:

没有答案