zakjan / mapbox-gl-draw-waypoint

Waypoint plugin for Mapbox GL Draw
https://zakjan.github.io/mapbox-gl-draw-waypoint/
MIT License
14 stars 6 forks source link

direct_select changes polyline vertices to selected state after one click, but not the associated line #1

Closed jaybo closed 4 years ago

jaybo commented 4 years ago

I'm drawing a polyline with a style which contains a user property to control the color, as in:

paint: {
    "line-color": ["get", "user_color"],
}

Similar styles exist for the vertices and midpoints. I change the value of the "color" property on a "draw.selectionchange" message.

As I click between polylines, the vertices change color on the first mouse click, but the associated line requires two mouse clicks to change color. So I'm guessing there's some missing logic which should be changing the line selected state along with it's vertices after only a single click.

draw

This problem exists whether I click on the line itself, or on the vertices individually.

jaybo commented 4 years ago

I'm guessing this is related to: https://github.com/mapbox/mapbox-gl-draw/pull/901

zakjan commented 4 years ago

Interesting, can you post a runnable example so that I can replicate it?

jaybo commented 4 years ago

I've discovered a hack around the issue. In Quasar, in the "draw.selectionchanged" callback I've added:

   Vue.nextTick(() => {
        this.draw.add(features[0]);            // total hack to force draw to change line selection state
        this.setActiveRoute(features[0]);   // change the line color
   });

Since I'm pretty certain the underlying problem is https://github.com/mapbox/mapbox-gl-draw/pull/901, I don't think this is really your issue, and since I have a workaround, you're welcome to close this.

zakjan commented 4 years ago

All right, closing for now. I'll take a look at the original issue if there is time. Why it wasn't merged yet? If you have any other information, let me know!

jaybo commented 4 years ago

I have no inside knowledge, but it looks like draw has been largely dormant for the past year or so. Minor updates, but nothing of consequence, which is partly why I'm delighted your two projects have solved two of the major issues I've had.

I don't know why 901 wasn't merged (and now no longer passes integration testing). I've been on the verge of giving up on Mapbox multiple times just because of the lack of progress in the draw control.