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

Remove paint class support #3643

Merged
merged 1 commit into from
Oct 5, 2017
Merged

Remove paint class support #3643

merged 1 commit into from
Oct 5, 2017

Conversation

anandthakker
Copy link
Contributor

@anandthakker anandthakker commented Nov 17, 2016

Prerequisites:

UPDATE: Removed #3662 (comment) from the prerequisites, in light of setSprite being (a) orthogonal to paint classes, and (b) a pretty complicated / significant lift.

@anandthakker
Copy link
Contributor Author

Hmm... what is the right thing to do in -style-spec alongside this change?

Issue: paint.* is referenced in the spec definition and the docs

Options:

  1. Remove from spec & docs, bump to v9
  2. Leave in spec--with deprecation notice--and update docs to point to declass for usage of paint.*.
  3. Something else?

@anandthakker
Copy link
Contributor Author

I guess now that I've written that, I'm leaning towards option 2

@anandthakker
Copy link
Contributor Author

Also TODO: remove classes tests from the test-suite. Updating top of ticket to reflect this and the -style-spec change.

anandthakker pushed a commit to mapbox/mapbox-gl-test-suite that referenced this pull request Nov 17, 2016
@anandthakker
Copy link
Contributor Author

anandthakker commented Nov 17, 2016

Rebased off of master instead of being branched off an open PR

jfirebaugh pushed a commit to mapbox/mapbox-gl-test-suite that referenced this pull request Nov 17, 2016
@anandthakker
Copy link
Contributor Author

Rebased onto master to fixup minor merge conflict

@anandthakker
Copy link
Contributor Author

@jfirebaugh @lucaswoj updated top of ticket w/ the prerequisites we discussed.

@averas
Copy link
Contributor

averas commented Jan 14, 2017

I use paint classes quite extensively and just stumbled across this. Do you think it's justified to mention in the documentation that paint class support will be deprecated so that we who use it start migrating away from it and new users stay away from it?

@lucaswoj
Copy link
Contributor

Absolutely @averas. I'll do that ASAP.

@anandthakker
Copy link
Contributor Author

Deprecation flagged here: #4038

@anandthakker
Copy link
Contributor Author

At this point, all of the technical blockers for merging this have been cleared -- that is, I believe it is now possible to losslessly replace 100% of the use cases of paint classes with map.setStyle().

So, question: should we look to merge this now (after a rebase/resolve), or should we consider adding setStyle examples to the docs (https://github.com/mapbox/mapbox-gl-js/issues/3660) to be a prerequisite for merging this PR?

cc @lucaswoj @jfirebaugh

@lucaswoj
Copy link
Contributor

I support considering adding Map#setStyle examples to the docs (#3660) to be a prerequisite for merging this PR.

Doing so will give us more confidence that our proposed alternative is sound, give our users more resources to make the transition, and give support more materials to reference.

@averas
Copy link
Contributor

averas commented Jan 27, 2017

I am currently migrating away from paint classes in my own applications so I thought I'd share the challenges that I've hit with the new smart setStyle() (which by the way has tons of other benefits):

Keeping GeoJSON sources in sync when the user switches style

I would say that it's fairly common that you have "base layers" that constitute the backdrop of your map, and on top of that you have some "custom layers" containing data that you visualise on your map. Sometimes different backdrops, such as with higher contrast, or with a satellite raster fits better, and a common use case is allowing the user to flip the backdrop while retaining the custom layers.

I used to fulfil this use case quite straightforwardly using paint classes. Any mutations to my "custom layers" would only require that I updated a single set of sources which allowed me to easily implement tons of filtering etc.

With smart setStyle() this is not as straight forward, as you need to manually keep your sources in sync, either by copying the sources from the style you're about to replace, to the style you're replacing it with, or by maintaining the "single-source-of-truth" outside of the style sources.

Except that copying sources is tedious I think it may become a performance issue as well. It isn't currently so for me, but if you copy a 70-80MB GeoJSON back and fourth between styles it may become one (even if you pass the GeoJSON by reference and really don't copy it per se, I would imagine Mapbox GL JS still would have to parse it every time).

It's not just sources, sometimes you want to keep custom layers in sync as well

Some of the layers I have in my applications have their paint properties set dynamically based on user interaction (for example the color stops of a fill). This requires me to copy such layers much like with the sources described above. When I had paint classes I simply let such multi-style-layers have paint properties defined without classes (so they were active regardless of class).

@anandthakker
Copy link
Contributor Author

Thanks for this helpful feedback, @averas !

Keeping GeoJSON sources in sync when the user switches style

Except that copying sources is tedious I think it may become a performance issue as well. It isn't currently so for me, but if you copy a 70-80MB GeoJSON back and fourth between styles it may become one.

Interesting point -- I agree that this is an issue that isn't well addressed by the current setStyle API. I'll file a separate ticket.

@anandthakker
Copy link
Contributor Author

Followed up on the GeoJSON source syncing issue here: #4006 (comment)

@jfirebaugh jfirebaugh merged commit e4201fc into master Oct 5, 2017
@jfirebaugh jfirebaugh deleted the remove-paint-classes branch October 5, 2017 23:32
@indus
Copy link
Contributor

indus commented Nov 6, 2017

The deprecation of paint classes hit me hard and for me the new setStyle is not a sufficient replacement when you deal with toggleable layers and realtime data at the same time.

@anandthakker
Copy link
Contributor Author

Sorry to hear that, @indus. Our intention was for "smart setStyle" to be sufficient (thus our waiting until it supported changes to sprite:, for example); if there are specific use cases where it's not, please do open a new issue!

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

Successfully merging this pull request may close these issues.

5 participants