Skip to content

Commit e55d7cd

Browse files
committed
DBC22-1129: fixed z-index and hierarchy for map components
1 parent 551f5fb commit e55d7cd

File tree

2 files changed

+45
-30
lines changed

2 files changed

+45
-30
lines changed

src/frontend/src/Components/Map.js

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { useSelector, useDispatch } from 'react-redux'
55
import { updateMapState } from '../slices/mapSlice';
66

77
// Third party packages
8-
import { useMediaQuery } from '@uidotdev/usehooks';
98
import Button from 'react-bootstrap/Button';
109

1110
// FA
@@ -92,7 +91,6 @@ export default function MapWrapper({
9291

9392
// Misc
9493
const navigate = useNavigate();
95-
const largeScreen = useMediaQuery('only screen and (min-width : 768px)');
9694

9795
function centerMyLocation(coordinates) {
9896
if (mapView.current) {
@@ -658,7 +656,30 @@ export default function MapWrapper({
658656

659657
return (
660658
<div className="map-container">
661-
<div ref={mapElement} className="map" />
659+
<div ref={mapElement} className="map">
660+
<div className="zoom-btn">
661+
<Button className="zoom-in" variant="primary" onClick={zoomIn}>
662+
<FontAwesomeIcon icon={faPlus} />
663+
</Button>
664+
<div className="zoom-divider" />
665+
<Button
666+
className="zoom-out"
667+
variant="primary"
668+
onClick={zoomOut}>
669+
<FontAwesomeIcon icon={faMinus} />
670+
</Button>
671+
</div>
672+
673+
{!isPreview && (
674+
<Button
675+
className="map-btn my-location"
676+
variant="primary"
677+
onClick={toggleMyLocation}>
678+
<FontAwesomeIcon icon={faLocationCrosshairs} />
679+
My location
680+
</Button>
681+
)}
682+
</div>
662683

663684
<div id="popup" onClick={cameraDetailRoute} className="ol-popup">
664685
<FontAwesomeIcon
@@ -690,29 +711,6 @@ export default function MapWrapper({
690711
</Button>
691712
)}
692713

693-
{!isPreview && (!iconClicked || largeScreen) && (
694-
<Button
695-
className="map-btn my-location"
696-
variant="primary"
697-
onClick={toggleMyLocation}>
698-
<FontAwesomeIcon icon={faLocationCrosshairs} />
699-
My location
700-
</Button>
701-
)}
702-
703-
<div className="zoom-btn">
704-
<Button className="zoom-in" variant="primary" onClick={zoomIn}>
705-
<FontAwesomeIcon icon={faPlus} />
706-
</Button>
707-
<div className="zoom-divider" />
708-
<Button
709-
className="zoom-out"
710-
variant="primary"
711-
onClick={zoomOut}>
712-
<FontAwesomeIcon icon={faMinus} />
713-
</Button>
714-
</div>
715-
716714
{!isPreview && (
717715
<div>
718716
<RouteSearch />

src/frontend/src/Components/Map.scss

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,23 @@
11
@import "../styles/variables.scss";
22
@import '~ol/ol.css';
33

4+
// Z-index
5+
.ol-overlaycontainer-stopevent {
6+
z-index: 20 !important;
7+
8+
.ol-overlay-container {
9+
z-index: 10;
10+
}
11+
12+
.ol-scale-line {
13+
z-index: 5;
14+
}
15+
}
16+
17+
.zoom-btn, .my-location {
18+
z-index: 5;
19+
}
20+
421
.map-wrap {
522
position: absolute;
623
top: 50px;
@@ -23,10 +40,10 @@
2340
.ol-overlay-container:not(:has(> img)) {
2441
//overriding openlayers dynamic styles for mobile layout except for having img as a direct child
2542
@media (max-width: 575px) {
26-
position: fixed !important;
27-
bottom: 0 !important;
28-
transform: none !important;
29-
}
43+
position: fixed !important;
44+
bottom: 0 !important;
45+
transform: none !important;
46+
}
3047

3148
.ol-popup {
3249
width: 100vw;

0 commit comments

Comments
 (0)