go-spatial / fresco

An open source vector tile style editor
https://fresco.go-spatial.org
Apache License 2.0
228 stars 26 forks source link

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

Open dwoznicki opened 2 years ago

dwoznicki commented 2 years ago

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.

Any thoughts?

ARolek commented 2 years ago

@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 commented 2 years ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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 commented 1 year ago

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