Update NativeOpenStreetMapController.java
Move compass to the right side as shown in the designer.
@@ -76,6 +76,7 @@ import android.graphics.drawable.Drawable;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
+import android.view.ViewTreeObserver;
import android.view.animation.Animation;
class NativeOpenStreetMapController implements MapController, MapListener {
@@ -359,6 +360,14 @@ class NativeOpenStreetMapController implements MapController, MapListener {
public void setCompassEnabled(boolean enabled) {
if (enabled && compass == null) {
compass = new CompassOverlay(view.getContext(), view);
+ view.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
+ @Override
+ public boolean onPreDraw() {
+ float density = view.getContext().getResources().getDisplayMetrics().density;
+ compass.setCompassCenter(view.getMeasuredWidth() / density - 35, 35);
+ return true;
+ }
+ });
view.getOverlayManager().add(compass);
}
if (compass != null) {
