Reputation: 9
I have a mapview in my app, I want to detect when the user moves the map and hide a imageview that I have, and then detect when the user stop move the map for show up the imageView once again.
Upvotes: 0
Views: 3713
Reputation: 12222
you can use OnCameraMoveStartedListener or OnCameraIdleListener
mMap.setOnCameraMoveStartedListener(new GoogleMap.OnCameraMoveStartedListener() {
@Override
public void onCameraMoveStarted(int reason) {
// code
// REASON_API_ANIMATION
// REASON_DEVELOPER_ANIMATION
// REASON_GESTURE
}
});
mMap.setOnCameraIdleListener(new GoogleMap.OnCameraIdleListener() {
@Override
public void onCameraIdle() {
// code
}
});
see this link
Upvotes: 3
Reputation: 51
Use either the GoogleMap.OnCameraChangeListener but this doesn't get called immediatly when you move the map. Or like in this thread intercept touch events from a transparent framelayout which you have to put over the map.
Upvotes: 0
Reputation: 46
try this:-
mapView.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_UP) {
imageView.setVisibility(View.VISIBLE);
}else{
imageView.setVisibility(View.GONE);
}
return false;
}
});
Upvotes: 0