Skip to content

Commit 1138500

Browse files
aleksprogergithub-actions[bot]
authored andcommitted
Use name instead of zIndex for level button titles (internal-9223)
GitOrigin-RevId: 1bc605dc5f384c178773d11efc96956effa56893
1 parent 4dfb7c0 commit 1138500

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

src/style/indoor_manager.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,16 @@ export default class IndoorManager extends Evented<IndoorEvents> {
147147
}
148148
}
149149

150-
const floors = Array.from(closestBuilding.floorIds).map((floorId) => ({
151-
id: floorId,
152-
name: closestBuilding.floors[floorId].name,
153-
zIndex: closestBuilding.floors[floorId].zIndex,
154-
})).sort((a, b) => b.zIndex - a.zIndex);
150+
// Dedupe floors by zIndex before sending to the control:
151+
// we should only show one floor per zIndex for a given building.
152+
const floors = Array.from(closestBuilding.floorIds)
153+
.map((floorId) => ({
154+
id: floorId,
155+
name: closestBuilding.floors[floorId].name,
156+
zIndex: closestBuilding.floors[floorId].zIndex,
157+
}))
158+
.sort((a, b) => b.zIndex - a.zIndex)
159+
.filter((floor, idx, arr) => idx === 0 || floor.zIndex !== arr[idx - 1].zIndex);
155160

156161
this.fire(new Event('selector-update', {
157162
selectedFloorId: buildingActiveFloorId,

src/ui/control/indoor_control.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,10 @@ class IndoorControl implements IControl {
124124
this._map._selectIndoorFloor(floor.id);
125125
});
126126

127-
this._setButtonTitle(levelButton, floor.zIndex.toString());
127+
const floorName = (floor.name || '').trim();
128+
const zIndexText = floor.zIndex.toString();
129+
const buttonTitle = floorName ? Array.from(floorName).slice(0, 3).join('') : zIndexText;
130+
this._setButtonTitle(levelButton, buttonTitle);
128131

129132
if (this._model && floor.id === this._model.selectedFloorId && showSelectedFloor) {
130133
levelButton.classList.add('mapboxgl-ctrl-level-button-selected');

0 commit comments

Comments
 (0)