Skip to content

Commit

Permalink
chore: add zoom undefined condition
Browse files Browse the repository at this point in the history
  • Loading branch information
danji90 committed Feb 5, 2025
1 parent 5d94606 commit 38c506f
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/components/FloorSwitcher/FloorSwitcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ class FloorSwitcher extends PureComponent {
this.onBaseLayerChange();
this.addMapListeners();
const visibleLevelLayer = this.getVisibleLevelLayer();

if (!visibleLevelLayer || zoom < 16) {
this.selectFloor("2D");
return;
Expand All @@ -130,7 +131,7 @@ class FloorSwitcher extends PureComponent {
this.abortController = new AbortController();
const { signal } = this.abortController;

if (!baseLayerHasLevelLayers || zoom < 16) {
if (!baseLayerHasLevelLayers || zoom <= 16 || !WALKING_BASE_URL) {
this.setState({
floors: [],
});
Expand Down Expand Up @@ -189,7 +190,12 @@ class FloorSwitcher extends PureComponent {
const { zoom } = this.props;
const { floors, activeFloor, baseLayerHasLevelLayers } = this.state;

if (zoom <= 16 || floors?.length <= 2 || !baseLayerHasLevelLayers) {
if (
!zoom || // When app is loaded without z param
zoom <= 16 ||
floors?.length <= 2 ||
!baseLayerHasLevelLayers
) {
return null;
}

Expand Down Expand Up @@ -261,8 +267,6 @@ const mapStateToProps = (state) => ({
activeTopic: state.app.activeTopic,
});

const mapDispatchToProps = {};

FloorSwitcher.propTypes = propTypes;

export default connect(mapStateToProps, mapDispatchToProps)(FloorSwitcher);
export default connect(mapStateToProps)(FloorSwitcher);

0 comments on commit 38c506f

Please sign in to comment.