Skip to content
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

Events: so when the style loaded and ready to draw? #8765

Open
korywka opened this issue Sep 17, 2019 · 3 comments
Open

Events: so when the style loaded and ready to draw? #8765

korywka opened this issue Sep 17, 2019 · 3 comments
Labels

Comments

@korywka
Copy link
Contributor

korywka commented Sep 17, 2019

For now we have style.load event which is not public.

We are supposed to use styledata.

Lets take this example: https://bravecow.github.io/mapbox-gl-controls/

  1. We want to add our own layers. If we use style.load, our layers are rendered faster, because load event is fired at the end:
styledata
style.load <-- we CAN render our layers here (at least it works and looks faster than "load" event)
styledata
styledata
load

Okay, we can use load event here and render them with some delay. At least it works.

  1. But it worse if we want to render same layers after style is changed. Please, use Ruler Control and switch style by Style Control. We want to preserve the same Ruler state. Events log:
styledata
style.load
styledata
styledata

Only style.load event is fired once. How we can use public styledata event here without some setTimeout hacks to draw layers again?

Thanks ❤️

@korywka
Copy link
Contributor Author

korywka commented Sep 17, 2019

  1. Also, if you use Language Control to modify style, styledata event is called. But this action doesn't clear our own layers (like after Style Control) and we don't want here to redraw them. So by using styledata event in this case, we will have redundant redraw.

@korywka korywka changed the title Events: so when the style changed and ready to draw? Events: so when the style loaded and ready to draw? Sep 17, 2019
@mourner
Copy link
Member

mourner commented Sep 18, 2019

Related: #8691

@sukalas-zz
Copy link

sukalas-zz commented Nov 26, 2019

Try using the event "idle" and if it isn't triggered use panTo to recenter.
That way you are triggering 'idle' event to listen
This is the most reliable workaround so far for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants