Bootstrap

Mapbox icon-image表达式

1.case (依次判断每个条件,结果为true时输出,否则返回默认值)

["case",
    condition: boolean, output: OutputType,
    condition: boolean, output: OutputType,
    ...,
    fallback: OutputType
]: OutputType  
 'icon-image': [
              'case',
              ['==', ['get', 'status'], 3],
              'imageIcon1',
              ['all', ['==', ['get', 'status'], 2], ['==', ['get', 'statusA'], 1]],
              'imageIcon2',
              ['all', ['==', ['get', 'status'], 2], ['==', ['get', 'statusA'], 2]],
              'imageIcon3',
              ['all', ['==', ['get', 'status'], 0], ['==', ['get', 'statusA'], null]],
              'imageIcon4',
              'imageIcon',//默认值
            ],

2.coalesce (依次计算每个表达式,直到获得第一个非null值,并返回该值)

["coalesce", OutputType, OutputType, ...]: OutputType
  'icon-image': [
               'coalesce',
               ['image', ['concat', 'imageIcon', ['get', 'status']]],
               ['image', ['concat', 'imageIcon', ['get', 'statusA']]],
             ],

3.match

["match",
    input: InputType (number or string),
    label: InputType | [InputType, InputType, ...], output: OutputType,
    label: InputType | [InputType, InputType, ...], output: OutputType,
    ...,
    fallback: OutputType
]: OutputType

4.all (如果所有输入均为true,则返回true,否则返回false。输入按顺序求值,求值是短路:一旦输入表达式求值为false,则结果为false,不再求值其他输入表达式。)

["all", boolean, boolean, ...]: boolean 
["all", ["==", "type", "age"], ["==", "status", "5"]  
;