-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
API: fitBounds without an animation #1473
Comments
|
@1ec5 Ah, makes sense. Just one thing, fitBounds does a check for a linear option. This isn't documented nor used in any other public methods, just internally. Makes it slightly tricky to follow. Anyway, feel free to close this issue unless you want to keep it open as an doc-improvement issue. fitBounds: function(options) {
(...)
return options.linear ?
this.easeTo(options) :
this.flyTo(options); |
I think we should add sync API methods and clear ways to use them: setting a duration of 0 is not a very good way to express this. |
@1ec5 Request for clarification: the docs on jumpTo indicate there's no transition, but easeTo with duration:0 (or linear: true) still shows a (very fast) animation. Is this the expected behavior? If so, we still do need a way to fitBounds() with no transition. |
In my opinion, this is wrong - we should special case Thoughts, @1ec5 ? |
I agree. gl-native runs zero-second transitions atomically and synchronously. Should the change take place in |
It is in fact special-cased already. So the 0-duration @peckjon describes is definitely a bug. |
Can someone else verify the bug please? Want to be sure it's not just my codebase.
|
|
@mourner @1ec5 thank you for your help! I've been able to confirm it was a bug in my local code, and 0.12.4 works properly with no-animation. Presumably, then, the best way to create a Map with specific bounds (and no other side effects) is to call fitBounds with {duration: 0} immediately after creation? cross-ref: #1970 |
@peckjon Yes, that's correct. In terms of API here, I think we should add |
gl-native publicly exposes a |
I'm 👍 on this, and also adding |
Before
|
Merged into #2801 |
I might be stupid, but hey
jumpTo with duration 0, or stuff like panTo and panBy are all about a combination of center and zoom, while a bound is like a rectangle. I know best zoom / center combination can be calculated from a bounds, but the purpose of I'm aware of #2801, and |
@cyrilchapon Did you find one? |
@cyrilchapon @Erutan409 you can use map.fitBounds([[
32.958984,
-5.353521
], [
43.50585,
5.615985
]], {duration: 0});
|
@mollymerp Thank you for this! I didn't connect that
|
This doesn't work for me
Also how I can listed to fitBounds end event? |
@vedmant could you create working fiddle which is reproducing the issue? For the fitBounds end event, you can try to use |
@cs09g It works actually, it was my mistake. |
It's easy. You must add map.fitBounds(bounds, {
padding: {
top: 150, bottom: 150, left: 30, right: 30,
},
maxZoom: 13,
animate: false,
}); |
Hei!
fitBounds fires off either easeTo or FlyTo. Both are animated. Would be great if we could pass along a param to trigger jumpTo.
The text was updated successfully, but these errors were encountered: