0

在我的项目中,我有一张地图,上面有一个 MapboxGLDraw 图层,可以让用户绘制多边形。在我的 MapboxDrawGl 对象中,我有以下样式:

          // ACTIVE (being drawn)
          // polygon outline
          {
            "id": "gl-draw-polygon-stroke-active",
            "type": "line",
            "filter": ["all", ["==", "$type", "Polygon"], ["!=", "mode", "static"]],
            "layout": {
              "line-cap": "round",
              "line-join": "round"
            },
            "paint": {
              "line-color": "#fff",
              "line-width": 3
            }
          },
      
          // INACTIVE (static, already drawn)
          // polygon outline
          {
            "id": "gl-draw-polygon-stroke-static",
            "type": "line",
            "filter": ["all", ["==", "$type", "Polygon"], ["==", "mode", "simple_select"]],
            "layout": {
              "line-cap": "round",
              "line-join": "round"
            },
            "paint": {
              "line-color": "#fff",
              "line-width": 3
            }
          },
          // polygon fill
          {
            "id": "gl-draw-polygon-fill-static",
            "type": "fill",
            "filter": ["all", ["==", "$type", "Polygon"], ["==", "mode", "simple_select"]],
            "paint": {
              "fill-color": "#225DB3",
              "fill-opacity": 0.4
            }
          },
        ]

这会在绘制时产生一个带有白色轮廓的多边形,在完成绘制时产生一个带有白色轮廓和蓝色填充的多边形。到目前为止,一切都很好。

除了在绘制时,我只希望实际绘制的线(因此两个放置点之间的多边形笔划)是可见的,而不是绘制点和尚未绘制点之间的线。上面的样式是后者。我该如何做到这一点?

所以不是这个,而是只有在实际绘制第三点时才能看到对角线笔划。

4

0 回答 0