Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

MapBox in UIScrollView, scrolling behavior #7217

Closed
standers67 opened this issue Nov 29, 2016 · 9 comments
Closed

MapBox in UIScrollView, scrolling behavior #7217

standers67 opened this issue Nov 29, 2016 · 9 comments
Assignees
Labels
bug iOS Mapbox Maps SDK for iOS
Milestone

Comments

@standers67
Copy link

**Platform: iOS 10
**Mapbox SDK version: 3.3.7

We have an IOS project where we have migrated to the MapBox iOS SDK, currently on version 3.3.7

We have identified one behavior related to the scrolling that differs from the MKMapView. We want to present the map without letting the user pan (scroll) the map. For this we set the property self.mapView.allowsScrolling to NO. This works as intended, the user is not able to pan the map.

However, the problem we have is that the MGLMapView is presented in a UIScrollView. When we have disabled the scrolling as above, the map seems to ignore the swipe gesture that would normally be detected by the UIScrollView.

To scroll the view presented in the scrollview you need to touch the screen either above or below the MGLMapView. Swiping on the map do not cause the UIScrollView to move.

This works with the regular MKMapView, setting the scrolling to disabled there, still let it send the received gestures to the underlying UIScrollView.

@tobrun tobrun added the iOS Mapbox Maps SDK for iOS label Nov 29, 2016
@standers67
Copy link
Author

There has not been any activity for this issue. Do I need to provide more input? This problem is very annoying and we have not been able to find a workaround either. I have not tried any of the latest builds, but I assume that if this problem would have been corrected - it should somehow be noted here.

Thanks,
Stefan

@friedbunny
Copy link
Contributor

Hi @standers67, it would be useful if you could:

  • Provide a minimal test case that reproduces the issue.
  • Confirm that this issue still exists in the latest v3.4.0 pre-release.

If you haven’t already, you might also try different means of disabling the map view’s interactivity. Specifically:

@standers67
Copy link
Author

standers67 commented Jan 10, 2017 via email

@boundsj
Copy link
Contributor

boundsj commented Jan 11, 2017

@standers67 @friedbunny could a possible workaround be to iterate through the map view's gesture recognizers, find the one that is a kind of UIPanGestureRecognizer and set its isEnabled property to false? Something like this is suggested in #2278 (comment) but, I don't think using the requireGestureRecognizerToFail: API is required in this case since the goal is to simply let the containing UIScrollView take over, always.

I also wonder if it may be worth opening a ticket to change MGLMapView so that it disables all of its gesture recognizers when the map view's user interactivity is disabled? Relatedly, it might be natural to disable the relevant gesture recognizers when properties like allowsScrolling are set to false. Currently, APIs like allowsScrolling short circuit the gesture recognizer handlers but don't actually disable them.

cc @1ec5 @incanus

@boundsj
Copy link
Contributor

boundsj commented Jan 11, 2017

also wonder if it may be worth opening a ticket to change MGLMapView so that it disables all of its gesture recognizers when the map view's user interactivity is disabled

Actually, this should not be necessary since setting userInteractionEnabled would cancel out all touch events. So, this might be another workaround if no interaction with the map is desired.

Otherwise, I think that disabling just the relevant recognizers when APIs like scrollEnabled, rotateEnabled, etc. are set to false, for now in application code, and eventually in MGLMapView itself, may help here.

@incanus
Copy link
Contributor

incanus commented Jan 12, 2017

I think both using userInteractionEnabled = false (as in e.g. https://github.com/mapbox/MapboxTableViewDemo) as well as improving our ..Enabled APIs to actually disregard input are good ideas.

@standers67
Copy link
Author

standers67 commented Feb 18, 2017

Just as follow-up to this problem. If we use the userInteractionEnabled = NO, it actually works in one aspect, but then we have the issue that we cannot respond to map annotation events. Our mapView have annotations that the users can interact with. This does not work if we completely disable user interaction with the mapView.

@1ec5
Copy link
Contributor

1ec5 commented Feb 18, 2017

To clarify, would setting scrollEnabled to NO work for you? It should disable pan gestures but still ensure that the user can select annotations by tapping.

@standers67
Copy link
Author

That was what we tried initially, but the problem was then that the scrolling gesture was not sent to the underlying scrollView that the mapBox is contained in. Have any changes been made in the component to fix this problem? We are not running on the very latest release, but if nothing has been changed in the component, it would probably not matter.

davidchiles added a commit to davidchiles/mapbox-gl-native that referenced this issue Mar 7, 2017
…ng user interactivity. Fixes mapbox#7217

Added an example behavior of MGLMapView as a subview of UIScrollView in
iOS app.
@boundsj boundsj added this to the ios-v3.6.0 milestone Mar 22, 2017
@boundsj boundsj added the bug label Mar 28, 2017
@boundsj boundsj self-assigned this Mar 31, 2017
boundsj pushed a commit that referenced this issue Apr 7, 2017
…ng user interactivity. Fixes #7217

Added an example behavior of MGLMapView as a subview of UIScrollView in
iOS app.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug iOS Mapbox Maps SDK for iOS
Projects
None yet
Development

No branches or pull requests

6 participants