Skip to content

Commit

Permalink
Merge pull request #440 from MapsPeople/bugfix/fix_mitransitionlevel_…
Browse files Browse the repository at this point in the history
…property

Add logic to respect miTransitionLevel prop
  • Loading branch information
matbmapspeople authored Jan 13, 2025
2 parents 93c21eb + 78f967e commit 48bd1b7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/map-template/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [1.65.2] - 2025-01-13

## Fixed

- An issue where miTransitionLevel is not respected for Mapbox map.

## [1.65.1] - 2025-01-08

## Fixed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import './MapboxMap.scss';
import ViewModeSwitch from './ViewModeSwitch/ViewModeSwitch';
import { useIsDesktop } from '../../../hooks/useIsDesktop';
import isNullOrUndefined from '../../../../../map-template/src/helpers/isNullOrUndefined';
import { useRecoilValue } from 'recoil';
import miTransitionLevelState from '../../../../../map-template/src/atoms/miTransitionLevelState';

MapboxMap.propTypes = {
accessToken: PropTypes.string.isRequired,
Expand Down Expand Up @@ -44,6 +46,7 @@ function MapboxMap({ accessToken, onInitialized, onPositionControl, center, zoom
const [hasPositionControl, setHasPositionControl] = useState(false);
const [hasZoomControl, setHasZoomControl] = useState(false);
const isDesktop = useIsDesktop();
const miTransitionLevel = useRecoilValue(miTransitionLevelState);

/*
* React on any props that are used to control the position of the map.
Expand Down Expand Up @@ -134,6 +137,11 @@ function MapboxMap({ accessToken, onInitialized, onPositionControl, center, zoom
...mapOptions
};

// If miTransitionLevel exists and it's a number, set it in the mapViewOptions
if (miTransitionLevel && !isNaN(parseInt(miTransitionLevel))) {
mapViewOptions.mapsIndoorsTransitionLevel = parseInt(miTransitionLevel);
}

const mapView = new window.mapsindoors.mapView.MapboxV3View(mapViewOptions);

setMapViewInstance(mapView);
Expand Down

0 comments on commit 48bd1b7

Please sign in to comment.