Commit 7ec248ca authored by User's avatar User Committed by Jeffrey Schiller

Update NativeOpenStreetMapController.java (#1265)

Move compass to the right side as shown in the designer.
parent c0cd37b2
...@@ -76,6 +76,7 @@ import android.graphics.drawable.Drawable; ...@@ -76,6 +76,7 @@ import android.graphics.drawable.Drawable;
import android.util.Log; import android.util.Log;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
import android.view.ViewTreeObserver;
import android.view.animation.Animation; import android.view.animation.Animation;
class NativeOpenStreetMapController implements MapController, MapListener { class NativeOpenStreetMapController implements MapController, MapListener {
...@@ -359,6 +360,14 @@ class NativeOpenStreetMapController implements MapController, MapListener { ...@@ -359,6 +360,14 @@ class NativeOpenStreetMapController implements MapController, MapListener {
public void setCompassEnabled(boolean enabled) { public void setCompassEnabled(boolean enabled) {
if (enabled && compass == null) { if (enabled && compass == null) {
compass = new CompassOverlay(view.getContext(), view); 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); view.getOverlayManager().add(compass);
} }
if (compass != null) { if (compass != null) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment