지도 차량 마커 시인성 개선

This commit is contained in:
2026-06-06 22:38:06 +09:00
parent 1bf346a898
commit e488075e36
2 changed files with 143 additions and 51 deletions

View File

@@ -817,11 +817,25 @@ function updateMarkers({ fitBounds = false } = {}) {
updateMarker(location); updateMarker(location);
} }
updateMarkerSelectionClasses();
if (fitBounds && state.markers.size > 0) { if (fitBounds && state.markers.size > 0) {
fitMapToLocations(); fitMapToLocations();
} }
} }
function updateMarkerSelectionClasses() {
for (const [driverId, marker] of state.markers) {
const element = marker.provider === "leaflet"
? marker.marker.getElement?.()
: marker.element;
if (element) {
element.classList.toggle("is-selected", state.selectedDriverId === driverId);
}
}
}
function updateInitialMapFit() { function updateInitialMapFit() {
if (state.hasFittedInitialLocations || !state.map || !state.locations.size) return; if (state.hasFittedInitialLocations || !state.map || !state.locations.size) return;
@@ -889,12 +903,14 @@ function updateKakaoMarker(location) {
content: markerElement, content: markerElement,
yAnchor: 1 yAnchor: 1
}), }),
element: markerElement,
currentPosition: targetPosition currentPosition: targetPosition
}; };
marker.overlay.setMap(state.map); marker.overlay.setMap(state.map);
state.markers.set(location.driverId, marker); state.markers.set(location.driverId, marker);
} else { } else {
marker.overlay.setContent(markerElement); marker.overlay.setContent(markerElement);
marker.element = markerElement;
animateMarkerPosition(marker, targetPosition); animateMarkerPosition(marker, targetPosition);
} }
} }
@@ -906,12 +922,13 @@ function updateLeafletMarker(location) {
const leafletPosition = [targetPosition.latitude, targetPosition.longitude]; const leafletPosition = [targetPosition.latitude, targetPosition.longitude];
const existingMarker = state.markers.get(location.driverId); const existingMarker = state.markers.get(location.driverId);
const markerHeading = resolveMarkerHeading(location, existingMarker?.currentPosition, targetPosition); const markerHeading = resolveMarkerHeading(location, existingMarker?.currentPosition, targetPosition);
const selectedClass = state.selectedDriverId === location.driverId ? "is-selected" : "";
const icon = L.divIcon({ const icon = L.divIcon({
className: `leaflet-truck-marker truck-marker ${status.key} ${vehicleType.className}`, className: `leaflet-truck-marker truck-marker ${status.key} ${vehicleType.className} ${selectedClass}`,
html: createTruckMarkerHtml(location, vehicleType, markerHeading), html: createTruckMarkerHtml(location, vehicleType, markerHeading),
iconSize: [86, 56], iconSize: [106, 82],
iconAnchor: [43, 56], iconAnchor: [53, 78],
popupAnchor: [0, -44] popupAnchor: [0, -66]
}); });
let marker = existingMarker; let marker = existingMarker;
@@ -936,7 +953,8 @@ function updateLeafletMarker(location) {
function createTruckMarkerElement(location, status, heading) { function createTruckMarkerElement(location, status, heading) {
const vehicleType = getVehicleType(location); const vehicleType = getVehicleType(location);
const markerElement = document.createElement("button"); const markerElement = document.createElement("button");
markerElement.className = `truck-marker ${status.key} ${vehicleType.className}`; const selectedClass = state.selectedDriverId === location.driverId ? "is-selected" : "";
markerElement.className = `truck-marker ${status.key} ${vehicleType.className} ${selectedClass}`;
markerElement.type = "button"; markerElement.type = "button";
markerElement.title = `${vehicleType.label} ${location.vehicleNo || location.driverId}`; markerElement.title = `${vehicleType.label} ${location.vehicleNo || location.driverId}`;
markerElement.setAttribute("aria-label", `${vehicleType.label} ${location.vehicleNo || location.driverId} 위치 보기`); markerElement.setAttribute("aria-label", `${vehicleType.label} ${location.vehicleNo || location.driverId} 위치 보기`);
@@ -952,6 +970,7 @@ function createTruckMarkerHtml(location, vehicleType = getVehicleType(location),
const label = location.vehicleNo ? location.vehicleNo.slice(-4) : location.driverId.slice(0, 4); const label = location.vehicleNo ? location.vehicleNo.slice(-4) : location.driverId.slice(0, 4);
const rotation = normalizeMarkerRotation(heading); const rotation = normalizeMarkerRotation(heading);
return ` return `
<span class="truck-marker__halo" aria-hidden="true"></span>
<span class="truck-marker__vehicle" style="--truck-heading: ${rotation}deg"> <span class="truck-marker__vehicle" style="--truck-heading: ${rotation}deg">
<span class="truck-marker__body"></span> <span class="truck-marker__body"></span>
<span class="truck-marker__cab"></span> <span class="truck-marker__cab"></span>
@@ -1300,6 +1319,7 @@ function openMarkerActionPanel(location) {
renderMarkerActionPanel(location); renderMarkerActionPanel(location);
elements.markerActionPanel.classList.remove("is-hidden"); elements.markerActionPanel.classList.remove("is-hidden");
render(); render();
updateMarkerSelectionClasses();
} }
function hideMarkerActionPanel() { function hideMarkerActionPanel() {
@@ -1313,6 +1333,7 @@ function closeMarkerActionPanel() {
} }
state.selectedDriverId = ""; state.selectedDriverId = "";
render(); render();
updateMarkerSelectionClasses();
} }
function renderMarkerActionPanel(location) { function renderMarkerActionPanel(location) {
@@ -1374,6 +1395,7 @@ function showVehicleRoute(location) {
clearInfoOverlay(); clearInfoOverlay();
renderRouteFocusPanel(location); renderRouteFocusPanel(location);
render(); render();
updateMarkerSelectionClasses();
if (!state.map || !state.mapProvider) return; if (!state.map || !state.mapProvider) return;
@@ -1390,6 +1412,7 @@ function showVehicleCargo(location) {
clearRouteOverlay(); clearRouteOverlay();
renderCargoFocusPanel(location); renderCargoFocusPanel(location);
render(); render();
updateMarkerSelectionClasses();
showInfoOverlay(location); showInfoOverlay(location);
} }
@@ -1400,6 +1423,7 @@ function showVehicleHistory(location) {
clearInfoOverlay(); clearInfoOverlay();
renderRouteFocusPanel(location); renderRouteFocusPanel(location);
render(); render();
updateMarkerSelectionClasses();
renderRoutePreview(location, { fit: false }); renderRoutePreview(location, { fit: false });
loadLocationHistory(location); loadLocationHistory(location);
} }
@@ -1412,6 +1436,7 @@ function showVehicleCenter(location) {
clearRouteOverlay(); clearRouteOverlay();
renderCurrentLocationPanel(location); renderCurrentLocationPanel(location);
render(); render();
updateMarkerSelectionClasses();
if (state.map && state.mapProvider) { if (state.map && state.mapProvider) {
centerMapOnLocation(location, { zoom: true }); centerMapOnLocation(location, { zoom: true });
@@ -1484,6 +1509,7 @@ function focusLocation(location) {
loadLocationHistory(location); loadLocationHistory(location);
renderRouteFocusPanel(location); renderRouteFocusPanel(location);
render(); render();
updateMarkerSelectionClasses();
if (!state.map || !state.mapProvider) return; if (!state.map || !state.mapProvider) return;
@@ -1553,6 +1579,7 @@ function closeHistoryDrawer() {
clearInfoOverlay(); clearInfoOverlay();
renderRouteFocusPanel(null); renderRouteFocusPanel(null);
render(); render();
updateMarkerSelectionClasses();
} }
function showInfoOverlay(location) { function showInfoOverlay(location) {

View File

@@ -1053,98 +1053,155 @@ button:hover {
--truck-color: var(--blue); --truck-color: var(--blue);
--truck-cab: #1556b8; --truck-cab: #1556b8;
--truck-accent: rgba(255, 255, 255, 0.2); --truck-accent: rgba(255, 255, 255, 0.2);
--marker-status: var(--green);
--marker-outline: #ffffff;
--truck-heading: 0deg; --truck-heading: 0deg;
--body-width: 42px; --body-width: 50px;
--body-height: 24px; --body-height: 28px;
--cab-width: 19px; --cab-width: 22px;
position: relative; position: relative;
display: grid; display: grid;
place-items: center; place-items: center;
width: 86px; width: 106px;
min-width: 86px; min-width: 106px;
height: 56px; height: 82px;
min-height: 56px; min-height: 82px;
border: 0; border: 0;
padding: 0; padding: 0;
background: transparent; background: transparent;
color: #ffffff; color: #ffffff;
filter: drop-shadow(0 8px 13px rgba(16, 32, 48, 0.28)); filter:
drop-shadow(0 2px 0 rgba(255, 255, 255, 0.92))
drop-shadow(0 10px 16px rgba(16, 32, 48, 0.34));
font-family: inherit; font-family: inherit;
cursor: pointer; cursor: pointer;
transition: filter 0.18s ease, transform 0.18s ease; transition: filter 0.18s ease, transform 0.18s ease;
} }
.truck-marker:hover { .truck-marker:hover,
filter: drop-shadow(0 10px 16px rgba(16, 32, 48, 0.34)); .truck-marker.is-selected {
z-index: 8;
filter:
drop-shadow(0 2px 0 rgba(255, 255, 255, 0.96))
drop-shadow(0 13px 20px rgba(16, 32, 48, 0.44));
transform: translateY(-1px); transform: translateY(-1px);
} }
.truck-marker.stale { .truck-marker.stale {
--truck-color: var(--amber); --truck-color: var(--amber);
--truck-cab: #8f4307; --truck-cab: #8f4307;
--marker-status: var(--amber);
} }
.truck-marker.offline { .truck-marker.offline {
--truck-color: var(--red); --truck-color: var(--red);
--truck-cab: #8f1d15; --truck-cab: #8f1d15;
--marker-status: var(--red);
} }
.truck-marker.type-trailer { .truck-marker.type-trailer {
--truck-color: #334155; --truck-color: #7c3aed;
--truck-cab: #0f172a; --truck-cab: #4c1d95;
--body-width: 62px; --body-width: 70px;
--body-height: 24px; --body-height: 27px;
} }
.truck-marker.type-container { .truck-marker.type-container {
--truck-color: #475569; --truck-color: #f97316;
--truck-cab: #1e293b; --truck-cab: #c2410c;
--body-width: 58px; --body-width: 66px;
--body-height: 24px; --body-height: 27px;
--truck-accent: repeating-linear-gradient( --truck-accent: repeating-linear-gradient(
90deg, 90deg,
rgba(255, 255, 255, 0.18) 0 2px, rgba(255, 255, 255, 0.32) 0 2px,
transparent 2px 8px transparent 2px 9px
); );
} }
.truck-marker.type-box, .truck-marker.type-box,
.truck-marker.type-wing { .truck-marker.type-wing {
--body-width: 48px; --truck-color: #059669;
--body-height: 25px; --truck-cab: #047857;
--body-width: 56px;
--body-height: 28px;
} }
.truck-marker.type-van { .truck-marker.type-van {
--truck-color: #0284c7; --truck-color: #0ea5e9;
--truck-cab: #0369a1; --truck-cab: #0369a1;
--body-width: 34px; --body-width: 40px;
--body-height: 21px; --body-height: 24px;
--cab-width: 22px; --cab-width: 25px;
} }
.truck-marker.type-cold { .truck-marker.type-cold {
--truck-color: #0e7490; --truck-color: #0891b2;
--truck-cab: #155e75; --truck-cab: #155e75;
--body-width: 47px; --body-width: 55px;
--body-height: 25px; --body-height: 28px;
--truck-accent: linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent 45%); --truck-accent: linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent 45%);
} }
.truck-marker.stale { .truck-marker.stale {
--truck-color: var(--amber); --truck-color: var(--amber);
--truck-cab: #8f4307; --truck-cab: #8f4307;
--marker-status: var(--amber);
} }
.truck-marker.offline { .truck-marker.offline {
--truck-color: var(--red); --truck-color: var(--red);
--truck-cab: #8f1d15; --truck-cab: #8f1d15;
--marker-status: var(--red);
}
.truck-marker::after {
content: "";
position: absolute;
top: 6px;
right: 14px;
z-index: 4;
width: 12px;
height: 12px;
border: 2px solid #ffffff;
border-radius: 50%;
background: var(--marker-status);
box-shadow: 0 2px 7px rgba(15, 23, 42, 0.32);
pointer-events: none;
}
.truck-marker__halo {
position: absolute;
top: 5px;
left: 50%;
z-index: 0;
width: 98px;
height: 50px;
border: 2px solid rgba(15, 23, 42, 0.12);
border-radius: 999px;
background:
radial-gradient(circle at 48% 46%, rgba(255, 255, 255, 0.98) 0 54%, rgba(255, 255, 255, 0.82) 55% 100%);
box-shadow:
0 0 0 2px rgba(255, 255, 255, 0.72),
0 8px 18px rgba(15, 23, 42, 0.24);
transform: translateX(-50%);
pointer-events: none;
}
.truck-marker.is-selected .truck-marker__halo {
border-color: rgba(31, 111, 235, 0.78);
box-shadow:
0 0 0 3px rgba(255, 255, 255, 0.86),
0 0 0 6px rgba(31, 111, 235, 0.22),
0 10px 22px rgba(15, 23, 42, 0.28);
} }
.truck-marker__vehicle { .truck-marker__vehicle {
position: relative; position: relative;
z-index: 2;
display: inline-flex; display: inline-flex;
align-items: flex-end; align-items: flex-end;
justify-content: center; justify-content: center;
margin-bottom: 12px;
padding-bottom: 8px; padding-bottom: 8px;
transform: rotate(var(--truck-heading)); transform: rotate(var(--truck-heading));
transform-origin: 50% 44%; transform-origin: 50% 44%;
@@ -1156,19 +1213,20 @@ button:hover {
content: ""; content: "";
position: absolute; position: absolute;
bottom: 1px; bottom: 1px;
width: 7px; width: 8px;
height: 7px; height: 8px;
border: 2px solid #ffffff; border: 2px solid var(--marker-outline);
border-radius: 50%; border-radius: 50%;
background: #17212b; background: #17212b;
box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.14);
} }
.truck-marker__vehicle::before { .truck-marker__vehicle::before {
left: 11px; left: 12px;
} }
.truck-marker__vehicle::after { .truck-marker__vehicle::after {
right: 12px; right: 13px;
} }
.truck-marker__body { .truck-marker__body {
@@ -1176,12 +1234,13 @@ button:hover {
display: block; display: block;
width: var(--body-width); width: var(--body-width);
height: var(--body-height); height: var(--body-height);
border: 2px solid #ffffff; border: 3px solid var(--marker-outline);
border-right: 0; border-right: 0;
border-radius: 5px 0 0 5px; border-radius: 7px 0 0 6px;
background: background:
var(--truck-accent), var(--truck-accent),
var(--truck-color); var(--truck-color);
box-shadow: inset 0 -5px 0 rgba(15, 23, 42, 0.13);
} }
.truck-marker.type-van .truck-marker__body { .truck-marker.type-van .truck-marker__body {
@@ -1191,19 +1250,20 @@ button:hover {
.truck-marker__label { .truck-marker__label {
position: absolute; position: absolute;
left: 50%; left: 50%;
bottom: 0; bottom: 2px;
z-index: 3;
display: inline-flex; display: inline-flex;
align-items: center; align-items: center;
gap: 4px; gap: 4px;
max-width: 82px; max-width: 98px;
min-height: 18px; min-height: 21px;
padding: 2px 6px; padding: 2px 7px;
border: 1px solid rgba(255, 255, 255, 0.7); border: 2px solid rgba(255, 255, 255, 0.9);
border-radius: 999px; border-radius: 999px;
background: rgba(15, 23, 42, 0.88); background: rgba(15, 23, 42, 0.94);
box-shadow: 0 4px 10px rgba(15, 23, 42, 0.22); box-shadow: 0 5px 12px rgba(15, 23, 42, 0.3);
color: #ffffff; color: #ffffff;
font-size: 10px; font-size: 11px;
font-weight: 900; font-weight: 900;
line-height: 1.1; line-height: 1.1;
transform: translateX(-50%); transform: translateX(-50%);
@@ -1225,9 +1285,10 @@ button:hover {
position: relative; position: relative;
width: var(--cab-width); width: var(--cab-width);
height: calc(var(--body-height) - 3px); height: calc(var(--body-height) - 3px);
border: 2px solid #ffffff; border: 3px solid var(--marker-outline);
border-radius: 0 6px 5px 0; border-radius: 0 8px 6px 0;
background: var(--truck-cab); background: var(--truck-cab);
box-shadow: inset 0 -4px 0 rgba(15, 23, 42, 0.14);
} }
.truck-marker__cab::before { .truck-marker__cab::before {
@@ -1246,6 +1307,10 @@ button:hover {
background: transparent; background: transparent;
} }
.leaflet-truck-marker.is-selected {
z-index: 1000 !important;
}
.kakao-popup { .kakao-popup {
min-width: 180px; min-width: 180px;
padding: 12px; padding: 12px;