mapbox-gl-draw icon indicating copy to clipboard operation
mapbox-gl-draw copied to clipboard

MapboxDraw doesn't work with MapLibre 3.x

Open neodescis opened this issue 1 year ago • 8 comments

As of MapLibre 3.x, the MapboxDraw plugin is no longer working. The issue can be seen in this official MapLibre example.

This is because MapLibre no longer uses the Mapbox CSS classes that MapboxDraw is checking for, which has been discussed in this (closed) MapLibre issue. Obviously this is because of a change to MapLibre, but I think it would be great if MapboxDraw could be used in both Mapbox and MapLibre. A relatively easy option I see is to consolidate all of the CSS classes that MapboxDraw is using into its list of constants (many but not all of them are already there), and allow them to be updated either before or while instantiating a MapboxDraw instance. Thoughts on this?

neodescis avatar Jun 29 '23 22:06 neodescis

Sounds like a good approach from my point of view. @pessimistress what is your solution for react-map-gl for these kind of issues? @stepankuzmin what do you think should be the approach?

HarelM avatar Jun 30 '23 19:06 HarelM

Hey everyone! Overriding classes in GL JS Draw sounds like a good addition. We already have constants in src/constants.js, so implementing overriding should be straightforward. Does anyone want to take a first stab at it?

stepankuzmin avatar Jul 07 '23 10:07 stepankuzmin

I'll be happy to give it a go. I'm hoping to be able to work on it this week.

neodescis avatar Jul 12 '23 17:07 neodescis

I tried this and it's okay a

tianzaishuo avatar Aug 01 '23 02:08 tianzaishuo

Note to people finding this issue: it looks like only the "display controls" are broken. I was able to hack together a PoC for my Vaadin integration by using a separate UI to trigger the draw mode (and using defaultMode constructor parameter to start drawing immediately): https://github.com/parttio/maplibre/commit/edb0a498d5c384a3a35e2b8fdcc408075860db4c

mstahv avatar Aug 08 '23 13:08 mstahv

I tried this and it's okay a

Worked for me.

geronimoooo avatar Apr 01 '24 09:04 geronimoooo

This is not working for me. Any updates on this issue?

I tried this and it's okay a

I'm using:

"maplibre-gl": "^4.1.1",
"@mapbox/mapbox-gl-draw": "^1.4.3",

bernatfortet avatar May 03 '24 07:05 bernatfortet

Unfortunately I've had to prioritize other work. We are using the latest of both libraries, and the workaround I posted on the MapLibre side is still working.

neodescis avatar May 04 '24 16:05 neodescis