-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Moving the map does not allow to override newCameraΒ #14686
Description
I would like to highlight a point, which could be improved in the current MapBox implementation. As the user of MapBox library, I am not able to edit the position to which the camera is going to.
Probably the best place to edit it would be method shouldChangeFromCamera:toCamera:reason:.
You could be passing newCamera as a reference - so it'd be editable for those who want it, or not, for those who don't want it. Or make another delegate method to eventually edit it - if you want to keep in sync with the old version.
2 examples why it's so useful to edit newCamera:
Scenario 1:
When someone wants to handle restricting map panning to an area in a better way, than just prohibiting any movement when you're close to the map border. In reality, when bounds are eg set to US, one would rather prefer not to stop the movement from New York to Pekin, but allow to move it behind California, to the border of US. Returning NO in this method, as you do in the sample (https://docs.mapbox.com/ios/maps/examples/constraining-gestures/), works far from perfect. There's a possibility to do the whole movement or no movement at all. It's impossible to swipe in such way, that you set the camera exactly next to the bounds. In reality, you'd rather prefer to be able to move to the point behind which you can't move. I'm attaching 2 drawings to demonstrate this scenario.
Scenario 2:
If you open Google Maps at zoom 6, centre to UK and scroll right/left you will see the map gets rotated as well. In this scenario, they're doing the rotation to mimic north pole. A simple change of heading in newCamera would be sufficient to do it.
Steps to reproduce
Repro steps for scenario 1:
- Implement the example from https://docs.mapbox.com/ios/maps/examples/constraining-gestures/
- Set the bounds to eg USA
- Launch the app, set camera position to New York and make a very quick gesture right. The camera shouldn't move at all. You'd expect it to swipe a bit, to let you see area next to the bounds.
Another scenario is to set your centre position in New York. Then try to zoom out to see the whole USA. Impossible without changing the centre point. I don't think any user will think it's so complicated and he needs to change the centre point.
Expected behaviour
The camera should allow you to pan to be exactly next to the border without constraining touches previously.
Actual behaviour
The camera with a quick swipe will not move at all.
Configuration
Mapbox SDK versions: 4.10.0 (previous as well)
iOS/macOS versions: all
Device/simulator models: all
Xcode version: 10.1

