Search code examples
mapboxmapbox-gl-jsmapbox-glmapbox-gl-draw

with Mapbox gl draw, after overriding polygon features' circle-radius, how to enlarge the selected vertex's circle-radius?


in the official demo, after creating a polygon in the "draw_polygon" mode, as you direct_select a vertex on the polygon, that vertex will be enlarged. https://docs.mapbox.com/mapbox-gl-js/example/mapbox-gl-draw/

In this js fiddle: https://jsfiddle.net/frankzhang2046/y49mhtjx/16/ after overriding the styling rules for the vertices from line 258-271, the selected vertex under "direct_select" doesn't get enlarged anymore.

Was wondering what API/selector can I use to target the selected vertex to restore the "enlarged when selected" behavior. Thanks.

 {
      id: "i-guess-id-doesnt-matter",
      type: "circle",
      filter: [
        "all",
        ["==", "meta", "vertex"],
        ["==", "$type", "Point"],
        ["!=", "mode", "static"],
      ],
      paint: {
        "circle-radius": 3,
        "circle-color": "green"
      },
    }, 

Solution

  • update: discovered the ruleset used to target the selected vertex in the unminified MapboxDraw library. Changing the circle-radius bigging solved the problem

      {
        'id': 'gl-draw-point-active',
        'type': 'circle',
        'filter': ['all',
          ['==', '$type', 'Point'],
          ['!=', 'meta', 'midpoint'],
          ['==', 'active', 'true']],
        'paint': {
          'circle-radius': 5,
          'circle-color': colorHexVal
        }
      },