-
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
Smart setStyle (part 1) #3621
Smart setStyle (part 1) #3621
Conversation
@jfirebaugh @lucaswoj Here's an initial working "mvp," with a few lingering tasks listed in the top of the ticket. What are you thoughts on the questions re: unit tests? |
Looks like those properties are one of the cases where it'll generate an exception trying to call I also notice that for sources, any differences in properties currently results in a removeSource/addSource pair. This will not produce the expected result if there are layers actively using that source. Removing an actively-used source is not supported.
Use deref on the style input before doing anything else.
Yeah, let's try adding setters for these independently of this PR.
Eventually, yes. But for now let's make parallel setStyle tests. My inclination is to do all testing for this via test-suite. |
Agreed: mapbox/mapbox-gl-style-spec#570
Oh, interesting. I suppose the most straightforward thing to do here would be to modify the style diff so that
👍 in the interim, I propose to have
If/when we move the diffing logic to be resolved only once per 'batch', it will probably make sense for there to be some unit tests around that. |
Two cases: - Fix #570 - remove/re-add layer when `source`, `source-layer`, or `type` properties are changed. - Remove all dependent layers before removing a source; if the source is being removed and re-added, then the corresponding layers are also added again afterward. (See mapbox/mapbox-gl-js#3621 (comment))
* Remove/re-add layers when source-related properties change Two cases: - Fix #570 - remove/re-add layer when `source`, `source-layer`, or `type` properties are changed. - Remove all dependent layers before removing a source; if the source is being removed and re-added, then the corresponding layers are also added again afterward. (See mapbox/mapbox-gl-js#3621 (comment)) * Add explainer comment * Fix lint * Slightly better readability * One more comment
|
@jfirebaugh @lucaswoj k, I think this should be ready for 👀, pending also the merge of upstream PR mapbox/mapbox-gl-test-suite#170 (and subsequent update of package.json here) |
@anandthakker above you mention that all sources are going to need to reload tiles when the sprite changes -- does that mean that raster tile sources are going to redraw? It'd be super nice for my company's use case if we could avoid that because we add lots of new sprites at runtime and right now the full-map flickers are pretty awful. |
@AndyMoreland Yes, as of now (both before and after this particular PR), the fully reloading the style is still going to happen, but there are plans to remove this necessity -- check out the tickets referenced here: #3625 (comment). I'm not up to speed on how all of those interrelate, but the one that most directly bears on this problem is probably #2058 |
Thanks for the response. Will check the referenced issues out. |
This should now only be pending mapbox/mapbox-gl-test-suite#170 and a review, of course. It passes all of those tests, so if that one's good, then this should be ready as well. |
@jfirebaugh @lucaswoj updated checklist at the top to include #3655 as a prerequisite. |
Updated
|
2f5f492
to
92956de
Compare
39e5870
to
8f0475e
Compare
Goal: make
map.setStyle({ layers: [ ..., { one layout property different from map's current style } ] })
as good asmap.setLayoutProperty()
(modulo a pretty cheap diff)Style#setState
.Map#setStyle
to delegate toStyle#setState
(instead of constructing a newStyle
instance).layer.source
,layer.source-layer
, orlayer.type
: Handle changes to a layer's 'source', 'source-layer', or 'type' in diffStyles mapbox-gl-style-spec#570diff
operations that rely on currently-missing setters:this.glyphSource
andthis.sprite
, but need to make sure that tiles are then reloaded for all sources ticketed separately: Add Style#setGlyphs method #3625this.stylesheet
to the up-to-date style (i.e., no diff magic required){min,max}zoom
,layout
,paint
,filter
,metadata
, -- I think this just leaves:paint.*
,type
,ref
,source
, andsource-layer
. If I didn't miss any, and we drop paint classes, then this should be a nonissue.Map#setStyle
Style#setState
Style
's individual mutators are going to be basically become private helper functions, would it make sense to just change each of their unit tests into a corresponding test forsetState
?setStyle
. Done in Add runtime-styling tests for 'smart setStyle' mapbox-gl-test-suite#170, pending review/mergeLaunch Checklist