Skip to content

Commit bcaf515

Browse files
Merge pull request #665 from MapsPeople/feat/matb/fix_select-highlight
Feat/matb/fix select highlight
2 parents bcf811a + 159d54f commit bcaf515

File tree

7 files changed

+49
-24
lines changed

7 files changed

+49
-24
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/map-template/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.96.16] - 2026-03-25
9+
10+
### Fixed
11+
12+
- Upgraded to Web SDK 4.56.0.
13+
814
## [1.96.15] - 2026-03-24
915

1016
### Fixed

packages/map-template/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77
<meta name="theme-color" content="#005655" />
88
<title>MapsIndoors Web</title>
9-
<script defer src="https://app.mapsindoors.com/mapsindoors/js/sdk/4.55.0/mapsindoors-4.55.0.js.gz"
10-
integrity="sha384-oW7TEiuEViUPGMgbrtXn96vWoBrrtrT+tYYCaVNll6KZTr8GWS5dqjV0sdJOcyhk"
9+
<script defer src="https://app.mapsindoors.com/mapsindoors/js/sdk/4.56.0/mapsindoors-4.56.0.js.gz"
10+
integrity="sha384-jNY73YbOtdlv5xKtZYwPDPMWFym59MhTK1MAfgFrT1kheVpr+LvomZTbuETxf2lj"
1111
crossorigin="anonymous"></script>
1212
</head>
1313

packages/map-template/src/components/MapTemplate/MapTemplate.jsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,8 +236,8 @@ function MapTemplate({ apiKey, gmApiKey, mapboxAccessToken, venue, locationId, p
236236
const miSdkApiTag = document.createElement('script');
237237
miSdkApiTag.setAttribute('type', 'text/javascript');
238238
// Remember to update the root index.html with the same version / integrity
239-
miSdkApiTag.setAttribute('src', 'https://app.mapsindoors.com/mapsindoors/js/sdk/4.55.0/mapsindoors-4.55.0.js.gz');
240-
miSdkApiTag.setAttribute('integrity', 'sha384-oW7TEiuEViUPGMgbrtXn96vWoBrrtrT+tYYCaVNll6KZTr8GWS5dqjV0sdJOcyhk');
239+
miSdkApiTag.setAttribute('src', 'https://app.mapsindoors.com/mapsindoors/js/sdk/4.56.0/mapsindoors-4.56.0.js.gz');
240+
miSdkApiTag.setAttribute('integrity', 'sha384-jNY73YbOtdlv5xKtZYwPDPMWFym59MhTK1MAfgFrT1kheVpr+LvomZTbuETxf2lj');
241241
miSdkApiTag.setAttribute('crossorigin', 'anonymous');
242242
document.body.appendChild(miSdkApiTag);
243243
miSdkApiTag.onload = () => {
@@ -587,6 +587,7 @@ function MapTemplate({ apiKey, gmApiKey, mapboxAccessToken, venue, locationId, p
587587

588588
if (currentLocation && currentLocation.id !== kioskOriginLocationId) {
589589
if (mapsIndoorsInstance?.selectLocation) {
590+
mapsIndoorsInstance.highlight?.([]);
590591
mapsIndoorsInstance.selectLocation(currentLocation);
591592
}
592593
} else {

packages/map-template/src/components/MapWrapper/MapWrapper.jsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import gmApiKeyState from '../../atoms/gmApiKeyState';
1212
import mapboxAccessTokenState from '../../atoms/mapboxAccessTokenState';
1313
import filteredLocationsState from '../../atoms/filteredLocationsState';
1414
import filteredLocationsByExternalIDState from '../../atoms/filteredLocationsByExternalIDState';
15+
import currentLocationState from '../../atoms/currentLocationState';
1516
import tileStyleState from '../../atoms/tileStyleState';
1617
import positionControlState from '../../atoms/positionControlState';
1718
import bearingState from '../../atoms/bearingState';
@@ -78,6 +79,7 @@ function MapWrapper({ onLocationClick, onMapPositionKnown, useMapProviderModule,
7879
const setDirectionsService = useSetRecoilState(directionsServiceState);
7980
const filteredLocations = useRecoilValue(filteredLocationsState);
8081
const filteredLocationsByExternalIDs = useRecoilValue(filteredLocationsByExternalIDState);
82+
const currentLocation = useRecoilValue(currentLocationState);
8183
const tileStyle = useRecoilValue(tileStyleState);
8284
const bearing = useRecoilValue(bearingState);
8385
const pitch = useRecoilValue(pitchState);
@@ -175,17 +177,23 @@ function MapWrapper({ onLocationClick, onMapPositionKnown, useMapProviderModule,
175177
* Dynamically filter or highlight location based on the "filteredLocations", "filteredLocationsByExternalIDs" and "hideNonMatches" property.
176178
*/
177179
useEffect(() => {
180+
if (!mapsIndoorsInstance) return;
181+
178182
const locations = filteredLocations || filteredLocationsByExternalIDs;
179-
if (!locations || locations.length === 0 || !mapsIndoorsInstance) return;
183+
184+
if (currentLocation || !locations || locations.length === 0) {
185+
mapsIndoorsInstance.highlight?.([]);
186+
return;
187+
}
188+
180189
const locationIds = locations.map(location => location.id);
181190

182-
// Check if the hideNonMatches prop or highlight method in the SDK exists
183191
if (hideNonMatches || !mapsIndoorsInstance.highlight) {
184192
mapsIndoorsInstance.filter(locationIds);
185193
} else {
186194
mapsIndoorsInstance.highlight(locationIds);
187195
}
188-
}, [filteredLocations, filteredLocationsByExternalIDs, mapsIndoorsInstance, hideNonMatches]);
196+
}, [filteredLocations, filteredLocationsByExternalIDs, mapsIndoorsInstance, hideNonMatches, currentLocation]);
189197

190198
/*
191199
* React to changes in bearing and pitch props and set them on the map if mapsIndoorsInstance exists.

packages/map-template/src/components/Search/Search.jsx

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ import isNullOrUndefined from '../../helpers/isNullOrUndefined';
3737
import venuesInSolutionState from '../../atoms/venuesInSolutionState';
3838
import initialVenueNameState from '../../atoms/initialVenueNameState';
3939
import primaryColorState from '../../atoms/primaryColorState';
40+
import mapTypeState from '../../atoms/mapTypeState';
41+
import { mapTypes } from '../../constants/mapTypes';
4042
import PropTypes from 'prop-types';
4143

4244
Search.propTypes = {
@@ -88,6 +90,7 @@ function Search({ onSetSize, isOpen, onOpenChat }) {
8890
const [hoveredLocation, setHoveredLocation] = useState();
8991

9092
const mapsIndoorsInstance = useRecoilValue(mapsIndoorsInstanceState);
93+
const mapType = useRecoilValue(mapTypeState);
9194

9295
const setFilteredLocations = useSetRecoilState(filteredLocationsState);
9396

@@ -372,8 +375,6 @@ function Search({ onSetSize, isOpen, onOpenChat }) {
372375
* @param {object} location
373376
*/
374377
function onLocationClicked(location) {
375-
setCurrentLocation(location);
376-
377378
// Set the current venue to be the selected location venue.
378379
if (location.properties.venueId.toLowerCase() !== currentVenueName.toLowerCase()) {
379380
setCurrentVenueName(location.properties.venueId);
@@ -383,9 +384,23 @@ function Search({ onSetSize, isOpen, onOpenChat }) {
383384
const currentFloor = mapsIndoorsInstance.getFloor();
384385
const locationFloor = location.properties.floor;
385386

386-
// Set the floor to the one that the location belongs to.
387387
if (locationFloor !== currentFloor) {
388+
// Register listener before setFloor — floor_changed fires
389+
// synchronously inside setFloor(), so it would be missed otherwise.
390+
mapsIndoorsInstance.once('floor_changed', () => {
391+
const map = mapsIndoorsInstance.getMap();
392+
if (mapType === mapTypes.Mapbox) {
393+
map.once('idle', () => setCurrentLocation(location));
394+
} else if (mapType === mapTypes.Google) {
395+
const listener = map.addListener('idle', () => {
396+
listener.remove();
397+
setCurrentLocation(location);
398+
});
399+
}
400+
});
388401
mapsIndoorsInstance.setFloor(locationFloor);
402+
} else {
403+
setCurrentLocation(location);
389404
}
390405

391406
Promise.all([getBottomPadding(), getLeftPadding()]).then(([bottomPadding, leftPadding]) => {

packages/map-template/src/components/WebComponentWrappers/ListItemLocation/ListItemLocation.jsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import { useTranslation } from 'react-i18next';
55
import './ListItemLocation.scss';
66
import showExternalIDsState from '../../../atoms/showExternalIDsState';
77
import PropTypes from 'prop-types';
8-
import { debounce } from 'lodash';
9-
108
ListItemLocation.propTypes = {
119
location: PropTypes.object,
1210
locationClicked: PropTypes.func,
@@ -34,25 +32,22 @@ function ListItemLocation({ location, locationClicked, icon, isHovered, disableH
3432
const showExternalIDs = useRecoilValue(showExternalIDsState);
3533

3634
useEffect(() => {
37-
const clickHandler = customEvent => locationClicked(customEvent.detail);
38-
const hoverHandler = debounce(() => {
39-
// Skip hover functionality if disabled (e.g., during routing to prevent dual pins)
35+
const clickHandler = customEvent => {
36+
mapsIndoorsInstance.unhoverLocation();
37+
locationClicked(customEvent.detail);
38+
};
39+
const hoverHandler = () => {
4040
if (disableHover) return;
41-
42-
// Check if the location is non-selectable before hovering it
4341
if (location.properties.locationSettings?.selectable !== false) {
4442
mapsIndoorsInstance.hoverLocation(location);
4543
}
46-
}, 150);
47-
const unhoverHandler = debounce(() => {
48-
// Skip unhover functionality if disabled
44+
};
45+
const unhoverHandler = () => {
4946
if (disableHover) return;
50-
51-
// Check if the location is non-selectable before unhovering it
5247
if (location.properties.locationSettings?.selectable !== false) {
5348
mapsIndoorsInstance.unhoverLocation(location);
5449
}
55-
}, 150);
50+
};
5651

5752
// Add a "non-selectable" class to the non-selectable locations.
5853
if (location.properties.locationSettings?.selectable === false) {

0 commit comments

Comments
 (0)