-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Limit Viewport #3602
Comments
With the map tilted, does it matter that the user will be able to see beyond the scrollable area limit? |
In other words, should these properties constrain the center point or the viewable bounds? If the latter, there could potentially be a complex interaction between the scrollable area limit, zoom, and tilt constraints. |
#2341 is one suggested approach, on iOS. |
+1 on setScrollableAreaLimit |
+1 on limiting scrollview |
+1 limiting scrollview |
@tobrun Let's get this into |
I'm not sure there's an overlap. Offline tiles would be handled by app users, while a limited viewport would be set by the app developer, isn't it? |
That is true, but how are you restricting bounds there? eg, user downloads region of NYC and than tries to pan to New Jersey? |
How about this solution? #2341 |
+1 on setScrollableAreaLimit Noticed some functionality is implemented and some still needs to work on Do we know if there is a plan to add this feature request to Milestone ? |
@guruduttstay As discussed in #5238 (comment) we probably won't add any new features to |
+1 on setScrollableAreaLimit |
@tobrun would enabling developers to change the native map's current |
@tobrun bump... sorry :\ If the |
@sddamico sorry for getting back to you just now. I'm actually surprised about that class. I'm looking into adding it to the Android binding to see what it actually does and solves the use-case mentioned above. |
Yes, |
@1ec5 thank you for adding that. I have been looking at how gl-js has implemented this. Would it be feasible to port over this logic to gl-native? |
The GL JS implementation allows the developer to constrain the viewable area to a rectangular bounding box, without accounting for rotation or pitch. (If I’m reading the code correctly, the user can still peek beyond the viewable area by rotating or tilting the map.) This approach implements a hard limit, so it won’t accommodate any “rubber band” effect we might want to introduce later (along the lines of #2191). If the GL JS approach is sufficient for the Android SDK despite these caveats, it might be easier to write the logic from scratch than to port the GL JS logic. You’ll want to plumb the options down into For the iOS and macOS SDKs, I’m still committed to a different approach outlined in #5584, which allows for a non-rectangular viewable area and would allow for a “rubber band” effect in the future. So those SDKs wouldn’t be using a bbox-style constraint option. |
I did a quick method by utilising the mapboxMap OnScrollListener and OnFlingListener together with the camera method demonstrated here: https://www.mapbox.com/android-sdk/examples/fit-bound-camera Not perfect but kind of did the job, waiting for a more stable and official method from the SDK
Below is the method i place in my OnScrollListener and OnFlingListener:
|
Thanks @jlormee for sharing! |
#5584 landed for iOS SDK v3.5.0 and macOS SDK v0.4.0. Removing the iOS label. |
Implementing core functionality in #8583. |
#8583 is the most straightforward approach to allowing the developer to limit the viewport, but I don’t expect that the iOS and macOS SDKs will need to adopt it. Instead, those SDKs persued a very different solution for the use case of limiting the viewport, as proposed in #2457: instead of fixed bounds and zoom levels, there’s a delegate method (callback) that allows the developer to decide on demand, in advance, whether to allow a change to the viewport. The delegate approach is more consistent with standard scroll view APIs on the iOS and macOS platforms. It allows the developer to constrain the map to a non-polygonal region of the world and a non-rectangular-prism camera space, and it’ll eventually allow the iOS and macOS SDKs to implement rubber banding (#2191), varying the maximum pitch by zoom level (#6908), and snapping the rotation without special cases all over the gesture handling code. At a high level, this approach is consistent with a general push to complement declarative APIs with imperative APIs (other examples being runtime styling, computed GeoJSON sources, etc.). With the delegate method already in place in #5584 and further conveniences coming in #8499, I don’t think it’ll be necessary to introduce another public API for limiting the viewport on iOS or macOS. However, if the Android SDK or other frontends need the more straightforward approach in #8583, it seems perfectly reasonable to provide this support at the core level. |
I have been hearing about the feature that developers want to limit the viewport for the end-user.
Sample use-case:
Create a tourist application for NYC, users are restricted to:
API:
This will result in exposing a similar API as the old raster API:
iOS is currently thinking about implementing #2457, which will work similar to the rotation snap-back animation we currently have at very low zoom levels.
The text was updated successfully, but these errors were encountered: