Labels and hovers
Labels
style.label draws the value of label.field next to each feature, while label.display is true. The ui offers a toggle titled label.title. On a cluster layer, count shows the number of locations on cluster features instead. Without the field the feature's label property is drawn; the text is always taken from the feature, never from the configuration.[1] minZoom and maxZoom limit the zoom range.
The text is styled with font (12px sans-serif), fillColor (#000), a halo of strokeColor and strokeWidth, offsetX/offsetY in pixels, and overflow to draw labels which exceed their polygon.[2]
Hovers
style.hover shows an infotip for the feature under the pointer while hover.display is true.[3]
- If the feature already has the
hover.fieldproperty, it is shown directly. - Otherwise the MAPP library queries the
hover.querytemplate,infotipby default, withfield, the featureid, the layer table and the layerqueryparams, and shows the returnedlabel. Responses are cached unlesshover.dynamicis set.
label.hidden and hover.hidden remove their toggles and dropdowns from the style panel, and hide an entry of labels or hovers from the dropdown.[4]
Several labels or hovers
style.labels and style.hovers are maps of named configurations; the key is the default title. style.label or style.hover may name one of them, or the first is used.[5] A theme's setLabel and setHover switch them with the theme; see themes.
Label, hover, theme and icon scaling fields are added to the layer query's fields automatically; see layer data source.
Pitfalls
- A label or hover without
display: trueis configured but not shown. - A hover
fieldmust be a column of the current table, or a template theinfotipquery can use.
Examples
Retail point labels from zoom 12 and an infotip with the store name.
{
"dbs": "DEVDB",
"locale": {
"layers": {
"retail_points": {
"display": true,
"format": "wkt",
"table": "geodata.uk_glx_open_retail_points",
"geom": "geom_p_4326",
"srid": "4326",
"qID": "id",
"style": {
"default": { "icon": { "type": "dot", "fillColor": "#e66" } },
"label": {
"title": "Store names",
"field": "store_name",
"display": true,
"minZoom": 12,
"strokeColor": "#fff",
"strokeWidth": 3
},
"hover": { "field": "store_name", "display": true }
}
}
}
}
}