When I rotate the map, the compass appears. However one of my button overlaps with the compass... I'm wondering if there's a way to detect it so I can hide my button when the compass show. Thanks in advance!
Edit: My question was misleading earlier sorry, I actually want the button to disappear when user is actually rotating/tilting the map, and it should reappear once user's hand is off the screen.
@MaciejGórski 's suggestion of using CameraPosition.bearing != 0 || CameraPosition.tilt != 0
is a big step to me, I tried the following implementation but then I realize that OnCameraChangeListener
doesn't fire as soon as user start rotating/tilting the map, so it won't work as expected.
public OnCameraChangeListener getCameraChangeListener() {
return new OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition position) {
// when compass show hide option button
if (optionButton.getVisibility() == LinearLayout.VISIBLE
&& (position.bearing != 0 || position.tilt != 0)) {
optionButton.setVisibility(LinearLayout.GONE);
final Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
//wait 1 sec and show the button again
optionButton.setVisibility(LinearLayout.VISIBLE);
}
}, 1000);
}
}
};
}