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

116
Vistas
determining circle-color with nested expressions

I use a GeoJSON as my source, where every entity has a state. I want to draw circles for every entity, where the circle color is based on the state, and whether the circle has been clicked or not.

Determining the "clicked-state" is done via setFeatureState() where a feature receives the "click" state when clicked.

I tried to first check for the click state and match the state, based on the feature being clicked or not:

    "circle-color": [
        'case',
        ['boolean',
            ['feature-state', 'click'],
            false,
        ],
        ['match',          //Feature clicked = true
            ['get', 'state'],
            'SOME_FEATURE_STATE_STRING',
            '#57E757',  // possible match
            'SOME_OTHER_FEATURE_STATE_STRING',
            '#123456',  // possible match

            '#123456' //fallback
        ],
        '#001ebe'           //Feature clicked = false
    ]

The "unclicked" circle has the correct color. However, when I click the circle, the circle-color is changed to black and not my "match" color.

Any advice is greatly appreciated!

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I think your case expression is incorrect here :

['boolean', 
  ['feature-state', 'click'],
  false,
],

You have used the boolean types expression, which is a type expression (it asserts that the input value is a boolean).

In your case, you want to use a decision expression.

With the == operator, you can return true if the input values are equal, false otherwise.

Your case expression would become :

"circle-color": [
 'case',
 ['==', ['feature-state', 'click'], true],
 ['match',     // Feature clicked = true
   ['get', 'state'],
   'SOME_FEATURE_STATE_STRING',
   '#57E757',  // Possible match
   
   'SOME_OTHER_FEATURE_STATE_STRING',
   '#123456',  // Possible match
   
   '#123456'   // Fallback
 ],
 '#001ebe'     // Feature clicked = false
] 
about 4 years ago · Juan Pablo Isaza Denunciar
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