-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unify camera API into a single method #2801
Comments
👍 on unifying On the other hand, |
Combining this ticket with #2820, "Support overlapping and/or queued Camera animations." See also mapbox/mapbox-gl-native#3625 |
The equivalent gl-native ticket is mapbox/mapbox-gl-native#3625. |
Brainstorming: moveToEverything within the current available animation methods involve moving the map based on a set of options (i.e. bearing, speed, zoom, etc.). What if we were to integrate all of them into a single method, called Example usage: map.moveTo({
animationType: 'ease', // 'fly', 'none', 'something-new'
center: [0, 0],
// more options
}); This would allow us to set the |
An alternative to the above ^ moveTo w/ animation objectThe example above lumps movement and animation all into the same map.moveTo({
center: [0, 0],
bearing: 0,
pitch: 0,
zoom: 10,
animation: {
type: 'ease', // 'fly', 'none', 'etc'
duration: 1000,
easing: function(f) { return f; }
}
}); I think we can remove the |
I think it would be more intuitive to keep I also wonder if we should unify |
Since #2820 has been folded into this issue, it bears noting that any options left undefined in map.setCamera({ bearing: 180 }, { type: 'ease', duration: 5000 });
setTimeout(() => map.setCamera({ pitch: 60 }, { type: 'ease', duration: 5000 }), 3000); |
Good points @1ec5 - I'm happy to keep them separate. The reaction to combine them is due to the direct connection of options in some camera methods interacting with animations, like flyTo where
With two separate objects, map.setCamera({center: [0,0]}, {type: 'ease'}); I'm not sure if that's confusing or not, honestly. |
The extra options on If the two objects really do need to be combined, it would make more sense to invert the options structure: In any case, if need be, |
@jfirebaugh it's not obvious, but I'd prefer making the docs clearer rather than removing it altogether. Makes transition from Leaflet/etc. easier. |
With the addition of cameraForBounds (or boundsToCamera), is a setBounds or fitBounds really needed? #2801 (comment) Could we complement it with a more flexible boundsForCamera (or cameraToBounds)? |
@1ec5 I would keep |
@mourner running into some Example: currently when creating the "zoom in" button we pass map.setCamera.bind(map, {zoom: map.getZoom() + 1}, {type: 'ease'}) The problem: the values in Any suggestions? |
I'm able to get around the above ^ by building in a private functions for this._zoomIn.bind(map) And are just implementations of _zoomIn() { map.setCamera({zoom: map.getZoom() + 1}, {type: 'ease'}); } |
Can we get rid of the if (duration === 0) animationOptions.type = 'none'; This would allow us to remove the |
Yes, I think so. Also, per #1473, we should make sure unanimated camera changes are synchronous, in addition to taking no time to complete. |
Realizing there are quite a few tests that rely on
This will run through the non-animation code, which doesn't even check for the |
More-so, there is a good amount of duration: 0 in scroll animations, where smooth ease is desired over a ton of non-animated transitions. Removing duration zero means a lot of these interactions aren't as smooth as before. See how duration is set to Two options:
|
+1 Definitely would like to see merging the concepts of bounds and camera options together into something like a BoundCameraOptions where bounding box takes the place of center and zoom, and center and zoom are then derived when flyTo/jumpTo/easeTo are called with those BoundCameraOptions.. |
What's the status of this work? I would need |
With v2 we added a free camera with options to get and set the camera directly, and The existing |
As part of the v1 effort, we should consider refactoring the camera API
panBy
,panTo
,flyTo
,jumpTo
,easeTo
don't make their behaviour obvious (I need to reference the docs regularly)The text was updated successfully, but these errors were encountered: