mapbox-gl-native icon indicating copy to clipboard operation
mapbox-gl-native copied to clipboard

[Android] Disable rotate map feature - not working

Open mpuchala opened this issue 10 years ago • 8 comments

Platform: Android Mapbox SDK version: 4.1.0 SNAPSHOT

Steps to trigger behavior

  1. Disable rotate gesture in map style <item name="rotate_enabled">false</item>
  2. Default dismissTrackingOnGesture = true
  3. Rotate map

Expected behavior

Rotate is disabled

Actual behavior

When map is being rotated for the first time it's disabled (like expected), but after first gesture it's enabled.

Comment

@tobrun I can see your last changes (https://github.com/mapbox/mapbox-gl-native/commit/63780d07f3af392338ae88f53fea726195c9c7ff).


    private void validateGesturesForTrackingModes() {
        if (!dismissTrackingOnGesture) {
            int myLocationTrackingMode = getMyLocationTrackingMode();
            int myBearingTrackingMode = getMyBearingTrackingMode();

            // Enable/disable gestures based on tracking mode
            if (myLocationTrackingMode == MyLocationTracking.TRACKING_NONE) {
                uiSettings.setScrollGesturesEnabled(true);
                uiSettings.setRotateGesturesEnabled(true);
            } else {
                uiSettings.setScrollGesturesEnabled(false);
                uiSettings.setRotateGesturesEnabled((myBearingTrackingMode == MyBearingTracking.NONE));
            }
        }else{
            uiSettings.setScrollGesturesEnabled(true);
            uiSettings.setRotateGesturesEnabled(true);
        }
    }

My goal is to disable rotation feature and don't follow user location. I think my case is common and should be possible to achieve that. I guess it's impossible after changes, because if dismissTrackingOnGesture == true Scroll and Rotate gestures are set to enabled (not like it's defined on init map) and it's called on every map move. In fact init values are overrode on map start.

mpuchala avatar Apr 07 '16 16:04 mpuchala

@mpuchala thank you for the detailed report!

tobrun avatar Apr 07 '16 18:04 tobrun

Looking into this issue, I'm currently thinking that this would require us to decouple initial state of a gesture and the current state.

tobrun avatar Apr 08 '16 08:04 tobrun

@mpuchala Here is my current solution to the problem:

  • https://www.dropbox.com/s/lde398tstgrn1rt/device-2016-04-08-105129.mp4?dl=0

Could check I this is covering the use-case?

tobrun avatar Apr 08 '16 09:04 tobrun

Adding a note here that current solution will based on initial configuration of the MapView and will not add extra public API (only package private methods).

To configure this disabling gestures one must either use the xml layout attribute app:rotate_enabled="false" or use of MapboxMapOptions.

tobrun avatar Apr 08 '16 09:04 tobrun

Are there any changes since yesterday?

  • I'm disabling rotate as you suggest (xml file)
  • Setting MyBearingTracking.NONE and MyLocationTracking.TRACKING_NONE
  • I guess it's use case from video

The current problem is in code I posted before after last changes. It works in last stable 4.0.0 version (like on your video).

else{
            uiSettings.setScrollGesturesEnabled(true);
            uiSettings.setRotateGesturesEnabled(true);
        }

I was debugging app and this fragment of code is called on every map move/gesture - my initial values are overrode and set to true.

If there are any changes which I missed please let me know, for now disabling rotate and tracking user (location, bearing) works like I describe in my first post - rotation is enabled after first interaction with map.

mpuchala avatar Apr 08 '16 09:04 mpuchala

@mpuchala I just committed the fix and PR it in #4650. If that PR is merged before the end of the day, it should be available our SNAPSHOT in ~22 hours. Sorry for not communicating that beforehand.

Thanks again for the valuable feedback!

tobrun avatar Apr 08 '16 09:04 tobrun

@tobrun I'll let you know if there are any problems after updating my snapshot.

Thanks!

mpuchala avatar Apr 08 '16 09:04 mpuchala

@tobrun

Now it works like a charm, thanks!

mpuchala avatar Apr 13 '16 09:04 mpuchala