Issue
I have a MapView with an ImageView with an arrow that points towards a specific location. I´m doing the pointing by rotating the ImageView, by calculating the bearing (orientation) of the compass by means of getOrientation() - the heading with geoField.getDeclination() and bearing with myLocation.bearingTo(finalDestiny).
The algorithm works perfectly, I get the arrow pointing exactly where I want to. The only problem is that to be able to getOrientation() it is needed to enableCompass(), otherwise it returns NaN. At the same time, enableCompass() draws the default google compass on the MapView, which I don't want to display.
How can I do so? it is possible to calculate this bearing "manually" using the sensors so I don't need to use enableCompass()?
Solution
You should implement a class extends MyLocationOverlay and override drawCompass() without any code, I just try it and work perfectly. In your activity, enableCompass() will not draw compass.
public class CustomMyLocation extends MyLocationOverlay {
//...
@Override
protected void drawCompass(Canvas canvas, float bearing) {
}
}
Answered By - VAdaihiep
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.