class
UniqueValueRenderer
implements IRenderer
Assigns symbols based on a feature attribute value. Use for categorical data (e.g. country, type, status).
Constructor
new UniqueValueRenderer(options: UniqueValueRendererOptions) | Parameter | Type | Description | |
|---|---|---|---|
options | UniqueValueRendererOptions | required | Renderer configuration |
UniqueValueRendererOptions
| Field | Type | Description | |
|---|---|---|---|
field | string | required | Attribute field name to classify on |
defaultSymbol | Symbol | required | Fallback symbol when no match found |
uniqueValues | UniqueValueInfo[] | required | Array of { value, symbol } pairs |
Properties
| Name | Type | Access | Description |
|---|---|---|---|
type | 'unique-value' | readonly | Renderer type discriminant |
field | string | readonly | Attribute field name |
defaultSymbol | Symbol | readonly | Fallback symbol |
Methods
getSymbol()
getSymbol(feature: Feature, context?: SymbolRenderContext): Symbol Look up symbol by attribute value. Falls back to defaultSymbol.
Returns
Symbol Example
const renderer = new UniqueValueRenderer({
field: 'type',
defaultSymbol: { type: 'simple-marker', color: [128,128,128,255], size: 6 },
uniqueValues: [
{ value: 'airport', symbol: { type: 'simple-marker', color: [0,100,255,255], size: 10 } },
{ value: 'station', symbol: { type: 'simple-marker', color: [0,200,0,255], size: 8 } },
],
});