Hello, I am developing an Android app with Mapsforge. Currently it starts by default in a "navigation" mode, where the map pans and zooms automatically according to the driver's position and some other things. When the user interacts with the map, it goes to a "manual" mode where no automatic zooming and panning happens, until the user clicks on a button to go back to navigation mode.
The problem I have is: I can't set up a listener for ZoomControls to know when the user changed zoom via zoom controls. I have a GestureDetector that already detects drag movements and double-tap movements to call a handler, but I found no way to set up a listener to the zoom controls, since I'd like to call the same handler whenever the user changed zoom via zoom controls as well.
I've tried setting onClick and OnTouch listeners like this with no results:
mapView.getMapZoomControls().setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Log.d(TAG, "onClick");
}
});
mapView.getMapZoomControls().setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent event) {
Log.d(TAG, "onTouch");
return true;
}
});
What would solve my problem:
- A way to set a listener to zoom controls; or
- A way to set a listener for ANY zoom changes, and then I check internally if the zoom was generated programatically by my navigation logic or not (I've tried that as well with no success).
I don't know if that's basic or not, but I'm stuck with this and decided to seek help.
Thank you in advance!