-
-
Notifications
You must be signed in to change notification settings - Fork 784
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
Mapbox-gl-draw no longer works in maplibre v3.0.0 #2601
Comments
I believe this is because MapLibre no longer has the Mapbox CSS classes applied. Mapbox Draw is creating a control group with the Mapbox classes, not the MapLibre classes. Also, Mapbox Draw depends on the Mapbox classes on the map itself being there, and not just for CSS. There are checks in the Mapbox Draw code for them. Do we need to fork Mapbox Draw at this point? I will be unable to update our project to MapLibre 3.x without draw support. |
I've been able to work around the issue by adding the Mapbox classes back. Here's what I did. First, add the Mapbox CSS classes to the MapLibre map:
Also, when the draw controls are created, the MapLibre classes need to be added to what MapboxDraw creates:
|
I'll close this issue as this is not a msplibre-gl bug. |
So... by closing this, are you saying that MapLibre no longer wants to support MapboxDraw at all? That seems strange to me, as does leaving a broken demo/example. |
You have it backwards 😀 |
Yeah sorry, I guess I didn't mean to imply that MapLibre should support MapboxDraw the project, but it does seem like the functionality would be important to the MapLibre community. That's why I was asking if we should fork MapboxDraw. It seems unlikely that the current project would want to support MapLibre, but I suppose it doesn't hurt to ask. |
I think that historically mapbox draw did make an effort to support maplibre. |
This problem was actually triggered by a change that So ultimately it was really #1575 that "broke" this, I believe. I can totally understand this project not wanting to include the
I will try to get a PR up for In the meantime another option that may work for some folks is adding this code somewhere: import MapboxDraw from "@mapbox/mapbox-gl-draw";
// @ts-ignore
MapboxDraw.constants.classes.CONTROL_BASE = "maplibregl-ctrl";
// @ts-ignore
MapboxDraw.constants.classes.CONTROL_PREFIX = "maplibregl-ctrl-";
// @ts-ignore
MapboxDraw.constants.classes.CONTROL_GROUP = "maplibregl-ctrl-group"; This worked for me for most functionality, but there's still some CSS rules that rely on the |
I agree with @HarelM that it would be great for plugins to be updated to work with both, but I'm not sure how feasible that is. MapboxDraw still hasn't published my pull request for a compatibility fix with MapLibre 2.x that got merged three months ago... |
@joekrill @neodescis Thanks for your feedback! Since drawing is quite an essential feature for a map library IMHO,, would it make sense to you to merge the MapboxDraw functionality into MapLibre, so this kind of functionality remains under control? Preferably allowing for tree shaking, so it would only be included in the final bundle when required. |
Tree shaking is a painful point. |
Drawing is essential to many map use cases, but I agree with keeping it separate. I think it would make a lot of sense to fork it though; the plugin would be much improved by moving to TypeScript and a class-based structure, among other things. |
@stepankuzmin is there a chance to release a new version of mapbox-gl-draw? I see that the linked PR was merged and should help here, wouldn't it? |
Hey everyone! Yes, I planned to cut a GL Draw release, but I was caught up with some stuff. I'll find some time to make a release. |
@HarelM Published |
THANKS!! I'll update the docs within a few weeks. |
Yes, thanks a bunch @stepankuzmin! @HarelM, keep in mind my fix was to get MapboxDraw working with MapLibre 2.x. Much of what I posted above is still needed for 3.x. I'm more than willing to work on MapboxDraw to get it working with 3.x, but probably we'll need to discuss an approach. I can file an issue in that repo and mention this one to get the ball rolling. |
I have made the following modifications and can run normally. @HarelM |
@bk201lucifer can you open a PR to update the example here in this repo with these changes? |
I can confirm that changing the constants fixes the issue.
|
Well, it fixes most of the problems, but not all. Specifically, keyboard bindings still won't work. @HarelM , I've been holding off on updating the example until we hear back from @stepankuzmin on my PR, but that was a few weeks ago. |
We can update the example, and later on update it again. |
Regarding the resolution, is the fix for us to add these three lines in our project before the MapboxDraw instance? MapboxDraw.constants.classes.CONTROL_BASE = 'maplibregl-ctrl';
MapboxDraw.constants.classes.CONTROL_PREFIX = 'maplibregl-ctrl-';
MapboxDraw.constants.classes.CONTROL_GROUP = 'maplibregl-ctrl-group'; The changes in #3394 seem to only update the example HTML, and doesn’t add anything to the actual |
Also, it seems like when drawing, the cursor is off. It should be using the Screen.Recording.2023-12-05.at.15.24.18.mov |
There shouldn't be any code changes in maplibre-gl-js as mapbox-gl-draw is a plugin and should facilitate for these issues. |
@kevinjmo |
maplibre-gl-js version: 3.0.0
browser: Edge
Steps to Trigger Behavior
Link to Demonstration
You can use your own jsfiddle to have a demo.
Expected Behavior
I can draw on the map.
Actual Behavior
Nothing happens.
The text was updated successfully, but these errors were encountered: