Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

218
Vistas
How do I hide the undrawn side of a polygon during draw mode of polygon using mapbox-gl-draw?

The normal function of the polygon draw tool of mapbox-gl-draw, shows the polygon that would be created if you clicked the original point from where you started.

enter image description here

But what I would like is to NOT show the line that hasn't yet been drawn by the user during draw mode.

In this image, the left side and the bottom side are fine because the user placed the top point and the second point at the bottom. But I do not want to see line connecting where my cursor is to the original point.

I am able to remove the fill color by changing the fill styling but I am unable to hide the "ghost" line as it uses the same stroke as the other user-drawn lines.

I have used the section "Lines and polygons" from this link: https://github.com/mapbox/mapbox-gl-draw/blob/main/docs/EXAMPLES.md

What I have tried to edit:

{
    id: "gl-draw-polygon-stroke-active",
    type: "line",
    filter: ["all", ["==", "$type", "Polygon"], ["!=", "mode", "static"]],
    layout: {
      "line-cap": "round",
      "line-join": "round",
    },
    paint: {
      "line-color": "#D20C0C",
      "line-dasharray": [0.2, 2],
      "line-width": 3,
    },
  }

But this changes the stroke of the "ghost" line as well. Is it possible to just hide the ghost line or do I need to make a custom polygon implementation of mapbox-gl-draw polygon mode?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda