Skip to content
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

bugfix: properties.mode is not available on vertex and midpoint, fixes #1077 #1221

Merged
merged 2 commits into from
Jun 28, 2024

Conversation

varna
Copy link
Contributor

@varna varna commented Jun 3, 2024

properties.mode is not available on vertex and midpoint.

Styles filter for mode on vertex and midpoint doesn't work, because lib/create_vertex and lib/create_midpoint does not extend feature_types/feature like other styles.

mapbox-gl-js version: 3.4.0
mapbox-gl-draw version: 1.4.3

Steps to Trigger Behavior

  1. Read https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/API.md#styling-draw
  2. Copy https://github.com/mapbox/mapbox-gl-draw/blob/main/src/lib/theme.js into your project
  3. Edit vertex or midpoint style in accordance to mode, i.e.
// before

export default [
 // ...
 {
   id: "gl-draw-polygon-and-line-vertex-stroke-inactive",
   type: "circle",
   filter: [
     "all",
     ["==", "meta", "vertex"],
     ["==", "$type", "Point"],
     ["!=", "mode", "static"]
   ],
   paint: {
     "circle-radius": 5,
     "circle-color": "#fff"
   }
 },
 {
   id: "gl-draw-polygon-and-line-vertex-inactive",
   type: "circle",
   filter: [
     "all",
     ["==", "meta", "vertex"],
     ["==", "$type", "Point"],
     ["!=", "mode", "static"]
   ],
   paint: {
     "circle-radius": 3,
     "circle-color": "#fbb03b"
   }
 },
 // ...
]
// after adding `["!=", "mode", "simple_select"]` to each filter

export default [
  // ...
  {
    id: "gl-draw-polygon-and-line-vertex-stroke-inactive",
    type: "circle",
    filter: [
      "all",
      ["==", "meta", "vertex"],
      ["==", "$type", "Point"],
      ["!=", "mode", "static"],
      ["!=", "mode", "simple_select"]
    ],
    paint: {
      "circle-radius": 5,
      "circle-color": "#fff"
    }
  },
  {
    id: "gl-draw-polygon-and-line-vertex-inactive",
    type: "circle",
    filter: [
      "all",
      ["==", "meta", "vertex"],
      ["==", "$type", "Point"],
      ["!=", "mode", "static"],
      ["!=", "mode", "simple_select"]
    ],
    paint: {
      "circle-radius": 3,
      "circle-color": "#fbb03b"
    }
  },
  // ...
]

Expected Behavior

Vertexes should be gone on active features during simple_select mode.

Actual Behavior

Rules seems to be ignored.

Attribution

This solution is extracted from #1078 made on Oct 28, 2021. That PR has a great video explanation of problem and solution. The PR itself has "more things" to it, like changes to theme. I extracted only the fix, to make it more of a atomic PR in hopes that someone from Mapbox team could merge this bugfix instead of waiting two years for nothing.

@varna
Copy link
Contributor Author

varna commented Jun 3, 2024

Hey @stepankuzmin,

Sorry for tagging you, but you seem to be the most active maintainer of this repo. Do you think it's possible to poke someone to merge a couple of bugfixes to this library? Or should I just give up and live on a fork?

Copy link
Contributor

@stepankuzmin stepankuzmin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @varna,

Thanks for the contribution, and I'm sorry for the slow response. We are working on some fixes and plan to release a new version of GL Draw.

@stepankuzmin stepankuzmin requested a review from a team as a code owner June 28, 2024 14:00
@stepankuzmin stepankuzmin merged commit 105e642 into mapbox:main Jun 28, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants