From 64a85afe6a95047b4ec4cdb7329ba193d359be1e Mon Sep 17 00:00:00 2001 From: Roman Priesol Date: Tue, 8 Sep 2026 00:39:02 +0200 Subject: [PATCH] Fix a filter-syntax warning found while investigating missing labels Mixing the legacy "$type" filter with an expression (["get", "role"]) in the same filter logs as unsupported in newer MapLibre. Modernized all three measure layer filters to expression syntax; the vertex circle layer's filter simplifies to just checking "role" (it's only ever set on Point features to begin with, so the geometry-type check was redundant once "role" was added). Found while trying to reproduce a report that per-segment distance labels don't show on a longer, several-point measurement -- couldn't reproduce it locally or against production itself (both showed labels correctly on a fresh page load), so this may be unrelated; still worth fixing on its own. --- public/js/measure.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/public/js/measure.js b/public/js/measure.js index ed7dd72..40086b8 100644 --- a/public/js/measure.js +++ b/public/js/measure.js @@ -105,21 +105,28 @@ export class MeasureControl { id: FILL_LAYER_ID, type: "fill", source: SOURCE_ID, - filter: ["==", "$type", "Polygon"], + filter: ["==", ["geometry-type"], "Polygon"], paint: { "fill-color": "#1e5fbf", "fill-opacity": 0.15 }, }); this._map.addLayer({ id: LINE_LAYER_ID, type: "line", source: SOURCE_ID, - filter: ["!=", "$type", "Point"], + filter: ["!=", ["geometry-type"], "Point"], paint: { "line-color": "#1e5fbf", "line-width": 2 }, }); + // "role" alone (not also a geometry-type check) — it's only ever set on + // Point features to begin with (the line/polygon shape feature has no + // "role" property at all), so it already implies the geometry type. + // Mixing the legacy "$type" filter syntax with an expression like + // ["get", "role"] in the same filter logs as unsupported in newer + // MapLibre — this sidesteps that rather than fixing it by switching + // "$type" to ["geometry-type"] and keeping both checks. this._map.addLayer({ id: POINT_LAYER_ID, type: "circle", source: SOURCE_ID, - filter: ["all", ["==", "$type", "Point"], ["==", ["get", "role"], "vertex"]], + filter: ["==", ["get", "role"], "vertex"], paint: { "circle-radius": 4, "circle-color": "#fff", "circle-stroke-color": "#1e5fbf", "circle-stroke-width": 2 }, }); // Distance mode only (see _render) — each segment's own length, not