Fix category filter not hiding polygon/line notes, only points
TODO.adoc had this flagged: toggling a category off in the legend only re-sliced the points source (_applyCategoryFilter), so a polygon or line note (Measure's "Save as note") sharing that category stayed visible. Added _linesByPath alongside the existing _pointsByPath, tracked/cleaned up the same way, and reused for both the legend's category scan and the filter's re-slice.
This commit is contained in:
1 parent
d9cc468478
commit
7c664578af
1 file changed
+15
-2
+15
-2
@@ -43,6 +43,7 @@ export class GpxPanelControl {
|
|||||||
this._visible = new Set(); // file paths currently shown on the map
|
this._visible = new Set(); // file paths currently shown on the map
|
||||||
this._interactiveLayers = new Set(); // point layer ids with click/hover wired up
|
this._interactiveLayers = new Set(); // point layer ids with click/hover wired up
|
||||||
this._pointsByPath = new Map(); // path -> its waypoints FeatureCollection, for the category legend
|
this._pointsByPath = new Map(); // path -> its waypoints FeatureCollection, for the category legend
|
||||||
|
this._linesByPath = new Map(); // path -> its lines/polygons FeatureCollection, same reason (a polygon/line note also carries a category)
|
||||||
this._hiddenCategories = new Set(); // category names toggled off in the legend
|
this._hiddenCategories = new Set(); // category names toggled off in the legend
|
||||||
this._openDownloadMenu = null; // the one gpx-tree__download-menu currently open, if any
|
this._openDownloadMenu = null; // the one gpx-tree__download-menu currently open, if any
|
||||||
|
|
||||||
@@ -597,6 +598,7 @@ export class GpxPanelControl {
|
|||||||
this._addClusterLayers(pointsId, path);
|
this._addClusterLayers(pointsId, path);
|
||||||
|
|
||||||
if (points.features.length > 0) this._pointsByPath.set(path, points);
|
if (points.features.length > 0) this._pointsByPath.set(path, points);
|
||||||
|
if (lines.features.length > 0) this._linesByPath.set(path, lines);
|
||||||
this._updateLegend();
|
this._updateLegend();
|
||||||
this._applyCategoryFilter();
|
this._applyCategoryFilter();
|
||||||
|
|
||||||
@@ -843,6 +845,7 @@ export class GpxPanelControl {
|
|||||||
if (this._map.getSource(pointsId)) this._map.removeSource(pointsId);
|
if (this._map.getSource(pointsId)) this._map.removeSource(pointsId);
|
||||||
|
|
||||||
this._pointsByPath.delete(path);
|
this._pointsByPath.delete(path);
|
||||||
|
this._linesByPath.delete(path);
|
||||||
this._updateLegend();
|
this._updateLegend();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -853,8 +856,8 @@ export class GpxPanelControl {
|
|||||||
// on the map, not just a read-only color key.
|
// on the map, not just a read-only color key.
|
||||||
_updateLegend() {
|
_updateLegend() {
|
||||||
const categories = new Map(); // category name -> { color, icon }
|
const categories = new Map(); // category name -> { color, icon }
|
||||||
for (const points of this._pointsByPath.values()) {
|
for (const collection of [...this._pointsByPath.values(), ...this._linesByPath.values()]) {
|
||||||
for (const feature of points.features) {
|
for (const feature of collection.features) {
|
||||||
const category = feature.properties.category;
|
const category = feature.properties.category;
|
||||||
if (category && !categories.has(category)) {
|
if (category && !categories.has(category)) {
|
||||||
categories.set(category, { color: feature.properties.color || TRACK_COLOR, icon: feature.properties.icon });
|
categories.set(category, { color: feature.properties.color || TRACK_COLOR, icon: feature.properties.icon });
|
||||||
@@ -909,6 +912,16 @@ export class GpxPanelControl {
|
|||||||
const visible = points.features.filter((f) => !this._hiddenCategories.has(f.properties.category));
|
const visible = points.features.filter((f) => !this._hiddenCategories.has(f.properties.category));
|
||||||
source.setData({ type: "FeatureCollection", features: visible });
|
source.setData({ type: "FeatureCollection", features: visible });
|
||||||
}
|
}
|
||||||
|
// Same re-slicing for polygon/line notes sharing the "lines" source with
|
||||||
|
// plain tracks/routes — those have no `category` of their own, so
|
||||||
|
// `_hiddenCategories.has(undefined)` is always false and they're never
|
||||||
|
// affected by this, only a hidden Note (or other categorized) shape is.
|
||||||
|
for (const [path, lines] of this._linesByPath) {
|
||||||
|
const source = this._map.getSource(linesSourceId(path));
|
||||||
|
if (!source) continue;
|
||||||
|
const visible = lines.features.filter((f) => !this._hiddenCategories.has(f.properties.category));
|
||||||
|
source.setData({ type: "FeatureCollection", features: visible });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async _uploadFiles(fileList, folder) {
|
async _uploadFiles(fileList, folder) {
|
||||||
|
|||||||
Reference in new issue
Block a user