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

RFC: Deprecate/Remove Style component and unify MapViews prop styleURL and styleJSON #512

Closed
KiwiKilian opened this issue Nov 23, 2024 · 8 comments

Comments

@KiwiKilian
Copy link
Collaborator

KiwiKilian commented Nov 23, 2024

Working through the examples, I noticed for the first time the Style component. The component basically allows to read a style.json and it will create Source and Layer components, to render the style partially.

This is confusing, because it's also possible to pass a JSON style via styleJSON on MapView, so this functionality is duplicated. It turns out, initially there was no support for local JSON styles at all. Then the Style component was introduced, before finally MapView got support for also styleJSON. The author of both did also recommend to keep only the functionality on MapView through styleJSON, but that component seemed to got forgotten.

I would like to do the following:

  • Deprecate/Remove Style component
    • Removes duplicate funcitonality and confusion about which to use
    • If someone wants to render a style, but not as the MapView styleJSON, this is a user space concern, nothing this library has to solve
    • It will help keep us this library clean in functionality
  • Unify styleURL and styleJSON to a new prop mapStyle, just like react-map-gl uses, mapStyle should then accept either a URL or a Style object

Smoothest migration would be first to deprecate Style and MapViews styleURL and styleJSON for one major version and then drop on the next major version. Immediate removal would be less work.

@KiwiKilian KiwiKilian changed the title RFC: Deprecate/Remove Style component RFC: Deprecate/Remove Style component, unify MapViews prop styleURL and styleJSON Nov 23, 2024
@KiwiKilian KiwiKilian changed the title RFC: Deprecate/Remove Style component, unify MapViews prop styleURL and styleJSON RFC: Deprecate/Remove Style component and unify MapViews prop styleURL and styleJSON Nov 23, 2024
@cashc
Copy link

cashc commented Nov 25, 2024

I'd vote for removing it now. Seems to me like a straightforward change that is a cleaner approach and breaking changes like these can be expected with a major version release.
I imagine that would mean you'd want to add some sort of 10.0 migration documentation to the readme that outlines the fact the if you're using the Style component currently, you'll have to switch to using MapView mapStyle=... approach.

Just my two cents (: Thank you for your work!

@KiwiKilian
Copy link
Collaborator Author

@cashc thanks for your comment! I'm with you on immediate removal of the Style component, my guess is, there are very few users of it.

The migration towards mapStyle from styleJSON and styleURL will affect everyone. So maybe deprecate those two props for one major version and remove them in the next major version?

A migration doc should be a must, you are right!

@KiwiKilian
Copy link
Collaborator Author

@tyrauber would love your feedback on this one 🙏.

@tyrauber
Copy link
Collaborator

I agree with htis. styleJSON and styleURL is more explicit. Having a prop that takes a url or json is not. I am fine with the breaking change as long as the docs are updated.

@KiwiKilian
Copy link
Collaborator Author

Are you also fine with removing the Style component?

@tyrauber
Copy link
Collaborator

If it is not needed. Reviewing the style component it looks like it is responsible for parsing the JSON and adding it to the map based on the style spec. Does styleJSON handle this differently?

@KiwiKilian
Copy link
Collaborator Author

Yeah it's not needed, see my initial comment:

Initially there was no support for local JSON styles at all. Then the Style component was rnmapbox/maps#846, before finally MapView got support for also styleJSON. The author of both did also recommend to keep only the rnmapbox/maps#1102 (comment), but that component seemed to got forgotten.

Right now a use case could only be to render layers separate from the map style injected from a style json – but that should be the users concern and not be covered by this library. maplibre-gl-js also only supports this through the maps style.

Copy link

🎉 This issue has been resolved in version 10.0.0-beta.11 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

3 participants