You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: `Label a layer's legend. Use after you build a map whose meaning isn't visible from the tiles — above all after styling a layer with a \`match\` expression over codes you invented in SQL.
311
+
312
+
The legend already mirrors the map's colors automatically: a \`match\` recolor renders one swatch per category, a gradient recolor renders a colorbar. What it cannot know is what your codes MEAN. If your SQL emitted \`CASE WHEN ... THEN 1\` for amphibians, the legend shows a swatch labelled "1" until you name it here.
313
+
314
+
So: whenever you post a color key in chat, call this instead — that key belongs on the map.
labels class value → name, for a categorical/swatch legend. Keys are the values in
321
+
your \`match\` expression, as strings. Merged with labels already set.
322
+
title heading for the layer, in both the legend and the layer panel.
323
+
units unit shown after a colorbar's end values (e.g. "observations", "kg/ha").
324
+
visible false hides this layer's legend section; true brings it back.
325
+
326
+
Colors and value ranges are NOT settable — they are read from the layer's paint, so the legend can never disagree with the map. To change the colors, call set_style; the legend follows.
327
+
328
+
Call get_map_state to see what a legend currently says (its \`legend.type\`, and \`legend.classes\` with the label each class shows now). Use reset_legend to return to the app's own labels.`,
329
+
inputSchema: {
330
+
type: 'object',
331
+
properties: {
332
+
layer_id: {type: 'string',description: 'Layer ID whose legend to label'},
333
+
labels: {
334
+
type: 'object',
335
+
description: 'Class value → display name, e.g. {"1": "Amphibians", "2": "Reptiles"}. Keys are the values from the layer\'s `match` expression, as strings.',
336
+
additionalProperties: {type: 'string'},
337
+
},
338
+
title: {type: 'string',description: 'Heading for this layer in the legend and layer panel'},
339
+
units: {type: 'string',description: 'Unit suffix for a colorbar\'s end values, e.g. "species"'},
340
+
visible: {type: 'boolean',description: 'false hides this layer\'s legend section'},
description: `Discard legend labels, title, units, and hiding you set with set_legend, returning the layer to the app's own legend. Does not change the map's colors — a legend derived from a restyle stays derived. Use when the user asks to "reset the legend" or "put the labels back".`,
355
+
inputSchema: {
356
+
type: 'object',
357
+
properties: {
358
+
layer_id: {type: 'string',description: 'Layer ID whose legend to reset'},
description: `Update a layer's paint/style properties. Provide MapLibre paint properties — every property name carries a layer-type prefix (\`fill-\`, \`line-\`, \`circle-\`, \`raster-\`).
After a \`match\` recolor over codes you defined in SQL, the legend shows one swatch per code labelled with the bare number — call set_legend with \`labels\` to name them, rather than writing the color key out in chat.
384
+
326
385
For dynamic hex layers (\`hex-…\` ids from add_hex_tile_layer), \`PROP\` is the layer's value column (the \`value_column\` you passed to add_hex_tile_layer, e.g. "species_richness") — NOT "count" unless that is literally the column. If unsure, call get_map_state to read the layer's \`valueColumn\`.
Copy file name to clipboardExpand all lines: docs/guide/configuration.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -138,6 +138,8 @@ A layer with no `legend_type` at all gains a legend when the agent recolors it i
138
138
139
139
Swatches derived from a `match` are labelled with the matched value itself (`1`, `2`, …), because the vector tiles carry only the code — what the code *means* usually lives in the SQL that produced the layer. Author-supplied `legend_classes` labels are used whenever the layer has not been recolored past them.
140
140
141
+
The agent closes that last gap with `set_legend`, which names the classes (`{"1": "Amphibians"}`), retitles the layer, adds a colorbar unit, or hides the section. It cannot set colors or value ranges — those stay derived from the paint, so a legend can't be made to contradict the map. `reset_legend` restores the labels configured here. Nothing in this file needs to change to allow it; `set_legend` overrides `legend_label` and `legend_classes` names for the session only.
0 commit comments