Hi there. Is there any way to retrieve a transition duration before or after it begins? I'd like to avoid too long transitions on camera actions (flyTo, fitBounds, etc.) when the target point is too far away, like Google Maps does. I'd rather avoid to redo the entire calculations done internally... For example:
{animate: false}Can't find any proper or hacky way to do it :) For sure the best scenario would be an option like maxDurationForAnimation!
Thanks.
Maybe just an option, "maxTime" to those functions, since that's your actual goal? What do you want to happen if the transition would take longer than that, though? Jump to?
Yes that would be perfect!
I like the maxDuration option suggestion. We would then either set the duration to 0 if calculated flyTo duration exceeds maxDuration, or we could do duration = Math.min(duration, maxDuration) to limit the duration but still animate every time.
Yes but the 2nd option could mean super fast transition from Pekin to New York at zoom 15 for example, doesn't it? (Should I edit the title ?)
@nicooprat yeah, it looks like the first option would be more practical, and in line with what some other mapping APIs do.
I've created PR for this issue https://github.com/mapbox/mapbox-gl-js/pull/5349
Thanks guys :)
Most helpful comment
I like the
maxDurationoption suggestion. We would then either set the duration to 0 if calculatedflyTodurationexceedsmaxDuration, or we could doduration = Math.min(duration, maxDuration)to limit the duration but still animate every time.