Themes
A theme styles each feature by its field value. style.themes maps named themes, offered in a dropdown; style.theme names the current one, or the first is used. skip removes a theme; the key is the default title; meta is HTML under the legend.[1] setLabel and setHover switch the label and hover with the theme.
Theme styles merge over style.default; a category style set to null, eg. by toggling it in the legend, hides its features.
type | Style comes from |
|---|---|
basic | theme.style for every feature |
categorized | The category whose value equals the feature's field value |
graduated | The numeric category range the value falls into |
distributed | Categories handed out so that neighbouring features differ |
type must be a key of mapp.layer.themes, which plugins extend;[2] a theme with an unknown or missing type is ignored with a warning and features keep the default style.[3] The ui legend dispatches on the same four types.
Theme categories describes field, categories, graduated breaks and data distributions of the other three types.
Basic
A basic theme spreads style over every feature. Its legend shows one symbol from style (24px by default) with label beside it; without label the legend row has no text.[4]
Legend
legend.layout (default grid) and legend.nowrap set the css classes of the legend; the ui derives legend.classList from them.[5]legend.showEmptyCat keeps categories with a zero count in a count distribution legend. A jenks distribution formats its category labels with the legend object as numeric formatter params, so it may carry formatter keys too.
Examples
Countries in a graduated population theme, and a basic theme.
{
"dbs": "DEVDB",
"locale": {
"layers": {
"countries": {
"display": true,
"format": "geojson",
"table": "naturalearth.countries",
"geom": "geom_4326",
"srid": "4326",
"qID": "id",
"style": {
"default": { "fillOpacity": 0.7, "strokeColor": "#fff", "strokeWidth": 1 },
"themes": {
"population": {
"type": "graduated",
"field": "pop_est",
"categories": [
{ "value": 10000000, "label": "Up to 10m", "style": { "fillColor": "#fee5d9" } },
{ "value": 100000000, "label": "Up to 100m", "style": { "fillColor": "#fb6a4a" } },
{ "value": 2000000000, "label": "Over 100m", "style": { "fillColor": "#a50f15" } }
]
},
"countries": {
"type": "basic",
"label": "Country",
"style": { "fillColor": "#1b9e77" }
}
}
}
}
}
}
}