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 Answer
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.