fresco icon indicating copy to clipboard operation
fresco copied to clipboard

Support MapLibre GL JS as an alternative to Mapbox GL JS

Open dwoznicki opened this issue 3 years ago • 6 comments

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?

dwoznicki avatar Aug 03 '22 00:08 dwoznicki

@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.

ARolek avatar Aug 07 '22 19:08 ARolek

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.

dwoznicki avatar Aug 16 '22 18:08 dwoznicki

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.

maxammann avatar Nov 14 '22 22:11 maxammann

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.

dwoznicki avatar Nov 14 '22 23:11 dwoznicki

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 avatar Nov 19 '22 15:11 maxammann

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

maxammann avatar Nov 19 '22 15:11 maxammann