diff --git a/public/js/gpx.js b/public/js/gpx.js index 8b8d152..24214f2 100644 --- a/public/js/gpx.js +++ b/public/js/gpx.js @@ -43,6 +43,7 @@ export class GpxPanelControl { this._visible = new Set(); // file paths currently shown on the map 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._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._openDownloadMenu = null; // the one gpx-tree__download-menu currently open, if any @@ -597,6 +598,7 @@ export class GpxPanelControl { this._addClusterLayers(pointsId, path); if (points.features.length > 0) this._pointsByPath.set(path, points); + if (lines.features.length > 0) this._linesByPath.set(path, lines); this._updateLegend(); this._applyCategoryFilter(); @@ -843,6 +845,7 @@ export class GpxPanelControl { if (this._map.getSource(pointsId)) this._map.removeSource(pointsId); this._pointsByPath.delete(path); + this._linesByPath.delete(path); this._updateLegend(); } @@ -853,8 +856,8 @@ export class GpxPanelControl { // on the map, not just a read-only color key. _updateLegend() { const categories = new Map(); // category name -> { color, icon } - for (const points of this._pointsByPath.values()) { - for (const feature of points.features) { + for (const collection of [...this._pointsByPath.values(), ...this._linesByPath.values()]) { + for (const feature of collection.features) { const category = feature.properties.category; if (category && !categories.has(category)) { 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)); 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) {