mirror of
https://github.com/traccar/traccar-web.git
synced 2025-01-07 03:26:42 +08:00
Apply map padding to controls
This commit is contained in:
parent
7a14960ad3
commit
002e5a354f
@ -57,7 +57,7 @@ const MainMap = ({ filteredPositions, selectedPosition, onEventsClick }) => {
|
||||
<MapNotification enabled={eventsAvailable} onClick={onEventsClick} />
|
||||
)}
|
||||
{desktop && (
|
||||
<MapPadding left={parseInt(theme.dimensions.drawerWidthDesktop, 10)} />
|
||||
<MapPadding left={parseInt(theme.dimensions.drawerWidthDesktop, 10) + parseInt(theme.spacing(1.5), 10)} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
|
@ -2,17 +2,19 @@ import { useEffect } from 'react';
|
||||
|
||||
import { map } from './core/MapView';
|
||||
|
||||
const MapPadding = ({
|
||||
top, right, bottom, left,
|
||||
}) => {
|
||||
const MapPadding = ({ left }) => {
|
||||
useEffect(() => {
|
||||
map.setPadding({
|
||||
top, right, bottom, left,
|
||||
});
|
||||
return () => map.setPadding({
|
||||
top: 0, right: 0, bottom: 0, left: 0,
|
||||
});
|
||||
}, [top, right, bottom, left]);
|
||||
const topLeft = document.querySelector('.maplibregl-ctrl-bottom-left');
|
||||
const bottomLeft = document.querySelector('.maplibregl-ctrl-bottom-left');
|
||||
topLeft.style.left = `${left}px`;
|
||||
bottomLeft.style.left = `${left}px`;
|
||||
map.setPadding({ left });
|
||||
return () => {
|
||||
topLeft.style.left = 0;
|
||||
bottomLeft.style.left = 0;
|
||||
map.setPadding({ top: 0, right: 0, bottom: 0, left: 0 });
|
||||
};
|
||||
}, [left]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
@ -9,7 +9,7 @@ const MapScale = () => {
|
||||
const control = useMemo(() => new maplibregl.ScaleControl(), []);
|
||||
|
||||
useEffect(() => {
|
||||
map.addControl(control, 'bottom-right');
|
||||
map.addControl(control, 'bottom-left');
|
||||
return () => map.removeControl(control);
|
||||
}, [control]);
|
||||
|
||||
|
@ -24,15 +24,6 @@ export const map = new maplibregl.Map({
|
||||
container: element,
|
||||
});
|
||||
|
||||
map.on('load', () => {
|
||||
const container = document.querySelector('.maplibregl-ctrl-bottom-right');
|
||||
if (container) {
|
||||
container.style.display = 'flex';
|
||||
container.style.flexDirection = 'row';
|
||||
container.style.alignItems = 'flex-end';
|
||||
}
|
||||
});
|
||||
|
||||
let ready = false;
|
||||
const readyListeners = new Set();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user