Feature styles
A feature style is an object of the style keys below. layer.style holds the feature styles a layer uses:
defaultapplies to every feature. Without it the MAPP library warns and uses a white fill with a dark stroke, or a dot icon on a cluster layer.[1]highlightapplies to the feature under the pointer. It is drawn on top (zIndexInfinity); itsscalebecomeshighlightScale.selectedreplaces the whole style, including theme and label, of features whose location is open.clusterapplies to features which stand for several locations. It defaults to a dot icon withclusterScale1, which grows the icon with the cluster size, or with its natural log withlogScale.[2]opacitysets the opacity of the whole layer, 0 to 1; 0 is treated as 1.cachereuses the style computed for a feature; highlight, theme and label changes are then not drawn until the features are reloaded.
Themes, labels and hovers add to these; see themes and labels and hovers.
Feature style keys
fillColor, fillOpacity, strokeColor, strokeWidth (1) and strokeOpacity style lines and polygons; lineDash dashes the stroke. Opacities, 0 to 1, are only applied to 4 or 7 character hex colours. zIndex orders the styles within the layer. A point needs an icon; see point icons.[3]
Style panel
The ui shows a style drawer in the layer view unless hidden.[4]elements orders its controls, by default labels, label, hovers, hover, themes, theme, icon_scaling and opacitySlider. An element is only shown when layer.style has its key, so opacitySlider: true adds the opacity slider.[5] drawer is disableOnHide (disabled while the layer is hidden), or false for a panel without drawer; popout, dialog and classList change how it is shown.
Pitfalls
- A cluster layer keeps only
iconandscaleinstyle.default; other keys are removed with a warning. layer.style.zIndex,layer.hoverandlayer.icon_scalingare legacy; uselayer.zIndex,layer.style.hoverandlayer.style.icon_scaling.layer.style.zIndexonly warns and has no effect.- A
styleobject insidestyle.defaultis unwrapped with a warning. layer.style.zoomInScaleandzoomOutScaleare meant to scale icons with the zoom level. The parser moves a cluster style's keys there, but the feature style function reads them fromstyle.cluster, so they currently do not change the render (#3154).
Examples
Grey dashed countries with a yellow highlight and an opacity slider.
{
"dbs": "DEVDB",
"locale": {
"layers": {
"countries": {
"display": true,
"format": "geojson",
"table": "naturalearth.countries",
"geom": "geom_4326",
"srid": "4326",
"qID": "id",
"style": {
"default": { "fillColor": "#d9d9d9", "fillOpacity": 0.5, "strokeColor": "#555", "lineDash": [4, 2] },
"highlight": { "fillColor": "#dbd56e", "fillOpacity": 0.7 },
"opacitySlider": true
}
}
}
}
}