You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
👍 on unifying panTo, flyTo, jumpTo, and easeTo for sure: it’d be nice if AnimationOptions were the one-stop shop for specifying how you get to the destination camera, and the default were to have no animation at all.
On the other hand, panBy is quite handy. It isn’t always obvious how to pan by a relative pixel distance, especially when bearing and pitch are involved. Could it be generalized to accept a options object that could vary the zoom level or bearing instead?
Everything 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 moveTo that includes an additional option animationType, which specifies how to animate the motion.
Example usage:
map.moveTo({animationType: 'ease',// 'fly', 'none', 'something-new'center: [0,0],// more options});
This would allow us to set the moveTo animation default (possibly no animation whatsoever, replacing jumpTo). Internally we can update all motion to moveTo and extend their options to include animationType, which would reduce the number of methods used internally.
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 map.fitBounds(bounds, options) as a shortcut for map.setCamera(map.cameraForBounds(bounds, 0), options) (small things like this matter for beginners), but not a strong opinion.
@mourner running into some .bind errors with the navigation controls.
Example: currently when creating the "zoom in" button we pass map.zoomIn.bind(map) as the function to execute. This worked previously since zoomIn was a wrapper around the easeTo function, so we had space to set defaults for the zooming functionality. Now we can pass in our cameraOptions and animationOptions with the .bind function like this:
The problem: the values in .bind (i.e. map.getZoom()) are only calculated once, so the function doesn't recalculate every time you click the button. This means you can only zoom in/out once.
Can we get rid of the duration: 0 workaround now that we are specifying animation types? With no animation specified, setCamera defaults to no animation. We could also build in a check like:
if(duration===0)animationOptions.type='none';
This would allow us to remove the duration !== 0 and animationOptions.animate checks within the ease and fly animation code.
Realizing there are quite a few tests that rely on duration: 0 to get themselves within the ease/fly transforms, which handle more camera options than the "no animation" transform. Example:
map.setCamera({offset: [100, 0]});
This will run through the non-animation code, which doesn't even check for the offset parameter.
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 0 in the scroll zoom if a wheel isn't used.
Two options:
Keep all instances of duration: 0 within the ease function
Set duration: 1 for quick ease animations, which leads to a similarly smooth experience
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 getCamera and cameraForBounds for a map I'm working on, and they could be implemented without breaking backward-compatibility, but is that ok?
Reacted by Aleksey Smolenchuk, Jan Baykara, Clay, Nicholas Brown and Felix Böhm
Activity
1ec5 commentedon Jun 29, 2016
👍 on unifying
panTo,flyTo,jumpTo, andeaseTofor sure: it’d be nice ifAnimationOptionswere the one-stop shop for specifying how you get to the destination camera, and the default were to have no animation at all.On the other hand,
panByis quite handy. It isn’t always obvious how to pan by a relative pixel distance, especially when bearing and pitch are involved. Could it be generalized to accept a options object that could vary the zoom level or bearing instead?lucaswoj commentedon Jul 8, 2016
Combining this ticket with #2820, "Support overlapping and/or queued Camera animations." See also mapbox/mapbox-gl-native#3625
1ec5 commentedon Jul 8, 2016
The equivalent gl-native ticket is mapbox/mapbox-gl-native#3625.
[-]Consider redesigning the camera API[/-][+]Redesign the camera API[/+][-]Redesign the camera API[/-][+]Unify camera API into a single method[/+]mapsam commentedon Nov 1, 2016
Brainstorming:
moveTo
Everything 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
moveTothat includes an additional optionanimationType, which specifies how to animate the motion.Example usage:
This would allow us to set the
moveToanimation default (possibly no animation whatsoever, replacingjumpTo). Internally we can update all motion tomoveToand extend their options to includeanimationType, which would reduce the number of methods used internally.22 remaining items
mourner commentedon Nov 3, 2016
@jfirebaugh it's not obvious, but I'd prefer making the docs clearer rather than removing it altogether. Makes transition from Leaflet/etc. easier.
1ec5 commentedon Nov 3, 2016
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)?
mourner commentedon Nov 3, 2016
@1ec5 I would keep
map.fitBounds(bounds, options)as a shortcut formap.setCamera(map.cameraForBounds(bounds, 0), options)(small things like this matter for beginners), but not a strong opinion.mapsam commentedon Nov 3, 2016
@mourner running into some
.binderrors with the navigation controls.Example: currently when creating the "zoom in" button we pass
map.zoomIn.bind(map)as the function to execute. This worked previously sincezoomInwas a wrapper around theeaseTofunction, so we had space to set defaults for the zooming functionality. Now we can pass in our cameraOptions and animationOptions with the.bindfunction like this:The problem: the values in
.bind(i.e.map.getZoom()) are only calculated once, so the function doesn't recalculate every time you click the button. This means you can only zoom in/out once.Any suggestions?
mapsam commentedon Nov 3, 2016
I'm able to get around the above ^ by building in a private functions for
NavigationControlthat are called like:And are just implementations of
setCameramapsam commentedon Nov 4, 2016
Can we get rid of the
duration: 0workaround now that we are specifying animation types? With no animation specified,setCameradefaults to no animation. We could also build in a check like:This would allow us to remove the
duration !== 0andanimationOptions.animatechecks within the ease and fly animation code.1ec5 commentedon Nov 4, 2016
Yes, I think so. Also, per #1473, we should make sure unanimated camera changes are synchronous, in addition to taking no time to complete.
mapsam commentedon Nov 7, 2016
Realizing there are quite a few tests that rely on
duration: 0to get themselves within the ease/fly transforms, which handle more camera options than the "no animation" transform. Example:map.setCamera({offset: [100, 0]});This will run through the non-animation code, which doesn't even check for the
offsetparameter.mapsam commentedon Nov 8, 2016
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
0in the scroll zoom if a wheel isn't used.Two options:
duration: 1for quick ease animations, which leads to a similarly smooth experiencejwangler commentedon Apr 26, 2017
+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..
tuukka commentedon Feb 20, 2018
What's the status of this work? I would need
getCameraandcameraForBoundsfor a map I'm working on, and they could be implemented without breaking backward-compatibility, but is that ok?asheemmamoowala commentedon Jul 7, 2021
With v2 we added a free camera with options to get and set the camera directly, and
Map#cameraForBounds.The existing
jumpToandeaseTowill be kept for API compatibility.