添加罗盘旋转的MapView [英] Adding Compass to Rotate MapView

查看:176
本文介绍了添加罗盘旋转的MapView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MapsDemo样品的code绘制,根据罗盘旋转的地图,但enableCompass工作不显示在MapView的指南针。我尝试添加该罗盘<一个href=\"http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/Compass.html\" rel=\"nofollow\">http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/Compass.html.但是,当我将它添加到我的应用程序,箭头出现冻结。任何想法?

I'm using the code of MapsDemo Sample to draw a Map that rotates according to the compass, but enableCompass is not working to show the compass on MapView. I tried to add this compass http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/Compass.html. But when I add it to my application, the arrow appears frozen. Any ideas?

推荐答案

请记住,它只会在实际硬件上运行。

Bear in mind that it will only work on actual hardware.

将这个行的onCreate

    MyLocationOverlay me = new MyLocationOverlay(this, mapView);
    mapView.getOverlays().add(me);

再补充一点:

@Override
protected void onResume() {
    super.onResume();
    me.enableCompass();
}

@Override
public void onPause() {
    super.onPause();
    me.disableCompass();
}

下面是一个示例项目,使罗盘 MyLocationOverlay 那肯定的作品,但你需要在自己的 Android的替代:apiKey

Here is a sample project that enables the compass on MyLocationOverlay that definitely works, though you will need to substitute in your own android:apiKey value.

这篇关于添加罗盘旋转的MapView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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