mapbox/mapbox-gl-leaflet

Supporting MapLibre

loleg opened this issue · 6 comments

loleg commented

Leaflet's author commented recently on the MapLibre project discussion, and this project lets us combine the best of both worlds. Since this wrapper is an independent and independently licensed project, there doesn't seem to me to be a need for a libre fork. But it would be good to rebase to the maplibre-gl-js libraries, or at least offer it as an option.

this plugin just works with maplibre-gl

https://codepen.io/jgravois/pen/gOLrOqb?editors=1000

Apparently not any more with v1.14.0 https://github.com/maplibre/maplibre-gl-js/releases/tag/v1.14.0 :(

I’m getting TypeError: undefined is not an object (evaluating 'new mapboxgl.Map') in the console.

Maybe reopen?

yup, looks like v1.14.0 introduced (at least) two breaking changes.

  1. the bundled library has been renamed

https://unpkg.com/maplibre-gl@1.13.0-rc.4/dist/mapbox-gl.js
https://unpkg.com/maplibre-gl@1.14.0/dist/maplibre-gl.js

  1. the namespace for the API has changed
// before: global.mapboxgl
(global = global || self, global.maplibregl = factory());

see maplibre/maplibre-gl-js#123 for more info

so much for being a drop-in replacement that aims to avoid fragmentation...

Thanks! Is it possible to have an alias or something for the namespace, to make it work for both? (I’m no proper JS-programmer, sorry)

if you don't to muck around with it yourself, your best bet is to just use @codespree's fork:

maplibre/maplibre-gl-js#123 (comment)
https://github.com/codespree/maplibre-gl-leaflet

Thanks. I follow your frustration regarding the fragmentation, so here’s another one :(.