2017-03-15 1 views
0

Mapbox GL JS의 속성 함수에서 둘 이상의 속성을 사용하는 방법이 있습니까? CartoCSS, 나는 다음과 같이 뭔가를 할 것이다 : Mapbox GL JS에서Mapbox GL JS의 복합 속성 함수 JS

.states { 
    [name="California"] { 
     "polygon-fill": "blue" 
    }, 
    [name_abbrev="WA"] { 
     "polygon-fill": "green" 
    } 
} 

내가 재산 name - 또는 name_abbrev하지만, 두 가지 속성이 아닌 조합 중 하나를 기반으로 fill-color 스타일을 지정할 수 있습니다 것으로 보인다. 예를 들어 :이 첫 번째를 무시 두 번째 fill-color 결과 및

'fill-color': { 
    'property': 'name', 
    'type': 'categorical', 
    'stops': [ 
     ['California', 'blue'] 
    ] 
}, 
'fill-color': { 
    'property': 'name_abbrev', 
    'type': 'categorical', 
    'stops': [ 
     ['WA', 'green'] 
    ] 
} 

캘리포니아 간단하게 그린 것이다.

답변

0

지도 상자 GL은 한 레이어 내에서 여러 속성을 기반으로 한 스타일을 지원하지 않습니다. 하나의 레이어로 스타일을 적용하려는 속성을 결합하여 데이터를 재 작업하거나 모든 레이어가 특정 레이어/일부 필요성을 지녔다고 추론 할 경우 두 레이어를 만들고 필터를 사용하여 기능을 분리 할 수 ​​있습니다 대체 속성을 사용하는 경우 :

{ 
    ... layer metadata (id, source, source-layer, type, etc) ... 
    'filter': ['has', 'name'], 
    'paint': { 
     'fill-color': { 
      'property': 'name', 
      'type': 'categorical', 
      'stops': [ 
       ['California', 'blue'] 
      ] 
     } 
    } 
}, 
{ 
    ... layer metadata (id, source, source-layer, type, etc) ... 
    'filter': ['!has', 'name'], 
    'paint': { 
     'fill-color': { 
      'property': 'name_abbrev', 
      'type': 'categorical', 
      'stops': [ 
       ['WA', 'green'] 
      ] 
     } 
    } 
} 
관련 문제