현재 체류 지점 기존 마커 숨김 처리

This commit is contained in:
seo
2026-07-12 15:01:31 +09:00
parent e036eb0c17
commit 534bc379b5
+25 -2
View File
@@ -1428,6 +1428,9 @@ function initMap(latlng, accuracy = 50) {
naver.maps.Event.addListener(mapState.map, 'zoom_changed', () => { naver.maps.Event.addListener(mapState.map, 'zoom_changed', () => {
if (mapState.map.getZoom() < CURRENT_STAY_MIN_ZOOM) { if (mapState.map.getZoom() < CURRENT_STAY_MIN_ZOOM) {
stopCurrentStayBadge(); stopCurrentStayBadge();
setStayMarkersVisibleForCurrentPoint(
hasValidCoords(lastLat, lastLng) ? { lat: lastLat, lng: lastLng } : null
);
} else if (hasValidCoords(lastLat, lastLng)) { } else if (hasValidCoords(lastLat, lastLng)) {
updateCurrentStayBadge({ updateCurrentStayBadge({
lat: lastLat, lat: lastLat,
@@ -2278,6 +2281,16 @@ function stopCurrentStayBadge() {
mapState.currentStayState = null; mapState.currentStayState = null;
} }
function setStayMarkersVisibleForCurrentPoint(point) {
if (!mapState.stayMarkers?.length) return;
const shouldHideCurrent = point && !_overrideRange && !mapState.playbackTimer && hasValidCoords(point.lat, point.lng);
mapState.stayMarkers.forEach(marker => {
const stay = marker.stayPoint;
const hide = shouldHideCurrent && stay && distanceMeters(stay, point) <= STAY_GROUP_RADIUS_M;
marker.setMap(hide ? null : mapState.map);
});
}
function currentStaySegmentStart(stay, currentPoint) { function currentStaySegmentStart(stay, currentPoint) {
const points = mapState.historyPoints || []; const points = mapState.historyPoints || [];
let startTime = currentPoint.time || new Date().toISOString(); let startTime = currentPoint.time || new Date().toISOString();
@@ -2324,16 +2337,19 @@ function renderCurrentStayBadge() {
function updateCurrentStayBadge(point) { function updateCurrentStayBadge(point) {
if (mapState.playbackTimer || _overrideRange || mapState.map?.getZoom?.() < CURRENT_STAY_MIN_ZOOM) { if (mapState.playbackTimer || _overrideRange || mapState.map?.getZoom?.() < CURRENT_STAY_MIN_ZOOM) {
stopCurrentStayBadge(); stopCurrentStayBadge();
setStayMarkersVisibleForCurrentPoint(point);
return; return;
} }
const state = currentStayStateFor(point); const state = currentStayStateFor(point);
if (!state) { if (!state) {
stopCurrentStayBadge(); stopCurrentStayBadge();
setStayMarkersVisibleForCurrentPoint(point);
return; return;
} }
mapState.currentStayState = state; mapState.currentStayState = state;
setStayMarkersVisibleForCurrentPoint(point);
if (!mapState.currentStayMarker) { if (!mapState.currentStayMarker) {
mapState.currentStayMarker = new naver.maps.Marker({ mapState.currentStayMarker = new naver.maps.Marker({
position: state.latlng, position: state.latlng,
@@ -2557,6 +2573,7 @@ function renderHistoryPoints(rawPoints) {
marker.infoWindow = new naver.maps.InfoWindow({ marker.infoWindow = new naver.maps.InfoWindow({
content: buildStayInfoContent(stay) content: buildStayInfoContent(stay)
}); });
marker.stayPoint = stay;
naver.maps.Event.addListener(marker, "click", () => { naver.maps.Event.addListener(marker, "click", () => {
if (mapState.openInfoWindow && mapState.openInfoWindow !== marker.infoWindow) { if (mapState.openInfoWindow && mapState.openInfoWindow !== marker.infoWindow) {
mapState.openInfoWindow.close(); mapState.openInfoWindow.close();
@@ -2566,6 +2583,9 @@ function renderHistoryPoints(rawPoints) {
}); });
mapState.stayMarkers.push(marker); mapState.stayMarkers.push(marker);
}); });
setStayMarkersVisibleForCurrentPoint(
hasValidCoords(lastLat, lastLng) ? { lat: lastLat, lng: lastLng } : null
);
if (!mapState.historyBoundsFitted) { if (!mapState.historyBoundsFitted) {
fitHistoryOrCurrentBounds(); fitHistoryOrCurrentBounds();
@@ -2608,6 +2628,7 @@ function updateDOMWithData(data) {
applyHistoryCounts(data); applyHistoryCounts(data);
updateHistoryMarkers(data.history); updateHistoryMarkers(data.history);
} }
setStayMarkersVisibleForCurrentPoint(null);
// 상대시간 갱신 중단 // 상대시간 갱신 중단
lastUpdateISOTime = null; lastUpdateISOTime = null;
@@ -2652,12 +2673,14 @@ function updateDOMWithData(data) {
lastLat = data.latitude; lastLat = data.latitude;
lastLng = data.longitude; lastLng = data.longitude;
lastUpdateISOTime = data.updated; lastUpdateISOTime = data.updated;
updateCurrentStayBadge({ const currentPoint = {
lat: data.latitude, lat: data.latitude,
lng: data.longitude, lng: data.longitude,
latlng, latlng,
time: data.updated || new Date().toISOString(), time: data.updated || new Date().toISOString(),
}); };
setStayMarkersVisibleForCurrentPoint(currentPoint);
updateCurrentStayBadge(currentPoint);
} }
function animateCircleRadius(targetRadius) { function animateCircleRadius(targetRadius) {