Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

105
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!