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

Support MapLibre GL JS as an alternative to Mapbox GL JS #133

Open
dwoznicki opened this issue Aug 3, 2022 · 6 comments
Open

Support MapLibre GL JS as an alternative to Mapbox GL JS #133

dwoznicki opened this issue Aug 3, 2022 · 6 comments

Comments

@dwoznicki
Copy link

I'd like to use MapLibre GL JS as my map renderer instead of Mapbox GL JS. MapLibre is an open source fork of Mapbox after they changed to a proprietary model, and includes features and bug fixes that are not available to earlier versions of Mapbox GL JS.

The MapLibre NPM package is set up to be a drop-in replacement for Mapbox, so swapping over is pretty painless. I managed to load it up simply by changing the imports in src/component/Map/MapMapbox.jsx.

import MapboxGl from 'mapbox-gl'
// import MapboxGl from 'maplibre-gl'

I'd be happy to contribute this feature, but I'm not sure how best to proceed.

  • We could simply replace the mapbox-gl dependency with maplibre-gl, if you don't anticipate people really caring which library is used.
  • We could add an environment variable or command line argument to choose renderers at initialization time.
  • We could add a UI element to change renderers at runtime.

Any thoughts?

@ARolek
Copy link
Member

ARolek commented Aug 7, 2022

@dwoznicki thanks for opening this issue! I think it would be great to use MapLibre with fresco. Of the options you suggested, my vote is:

We could add a UI element to change renderers at runtime.

To me this makes the most sense as there are a lot of renderers out there and it would be nice to eventually support them. Do you know if MapLibre's API is tracking mapbox-gl-js v2? Being able to swap between v1 and v2 of both libraries would be amazing.

I'd be happy to contribute this feature

Please send in a PR and we can get @justenPalmer looped in for a review.

@dwoznicki
Copy link
Author

Do you know if MapLibre's API is tracking mapbox-gl-js v2?

I don't believe MapLibre is following the Mapbox v2 API directly, though I could be wrong. I suspect it's not because the MapLibre team is making a conscious effort to differentiate maplibre-gl-js from mapbox-gl-js for legal reasons. I do know that maplibre-gl-js v1 is backwards compatible with mapbox-gl-js v1, though.

@maxammann
Copy link

I do know that maplibre-gl-js v1 is backwards compatible with mapbox-gl-js v1, though.

I think you meant v2 in the first part, right?


I think this would definitely be valuable! Though as soon as users load a v2 style and use maplibre a warning should be presented, or the loading should be aborted and an error should be shown probably.

@dwoznicki
Copy link
Author

I think you meant v2 in the first part, right?

Mmm, no I meant v1. I'm fairly certain maplibre-gl-js v1 was made to be backwards compatible with mapbox-gl-js v1. I suspect you know more about this @maxammann, so let me know if that's not correct.

It looks like maplibre-gl-js v2 has some breaking changes (https://github.com/maplibre/maplibre-gl-js/releases/tag/v2.0.0) which make it incompatible with mapbox-gl-js v1. That said, I believe my style.json works with both maplibre-gl-js v2 and mapbox-gl-js v1 without any issue.

@maxammann
Copy link

Mmm, no I meant v1. I'm fairly certain maplibre-gl-js v1 was made to be backwards compatible with mapbox-gl-js v1. I suspect you know more about this @maxammann, so let me know if that's not correct.

Oh sorry I mis-read what you have written. Yes both specs which work in mapbox v1 still work in maplibre.
There have been some breaking changes but not a whole lot: https://github.com/mapbox/mapbox-gl-js/blob/main/src/style-spec/CHANGELOG.md

@maxammann
Copy link

We probably should track which exact version of the style spec maplibre supports.

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

No branches or pull requests

3 participants