0

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?

1

1 Answer 1

0

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

Put this line in onCreate:

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

Then add this:

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

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

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.