현재 체류 지점 기존 마커 숨김 처리
This commit is contained in:
+25
-2
@@ -1428,6 +1428,9 @@ function initMap(latlng, accuracy = 50) {
|
||||
naver.maps.Event.addListener(mapState.map, 'zoom_changed', () => {
|
||||
if (mapState.map.getZoom() < CURRENT_STAY_MIN_ZOOM) {
|
||||
stopCurrentStayBadge();
|
||||
setStayMarkersVisibleForCurrentPoint(
|
||||
hasValidCoords(lastLat, lastLng) ? { lat: lastLat, lng: lastLng } : null
|
||||
);
|
||||
} else if (hasValidCoords(lastLat, lastLng)) {
|
||||
updateCurrentStayBadge({
|
||||
lat: lastLat,
|
||||
@@ -2278,6 +2281,16 @@ function stopCurrentStayBadge() {
|
||||
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) {
|
||||
const points = mapState.historyPoints || [];
|
||||
let startTime = currentPoint.time || new Date().toISOString();
|
||||
@@ -2324,16 +2337,19 @@ function renderCurrentStayBadge() {
|
||||
function updateCurrentStayBadge(point) {
|
||||
if (mapState.playbackTimer || _overrideRange || mapState.map?.getZoom?.() < CURRENT_STAY_MIN_ZOOM) {
|
||||
stopCurrentStayBadge();
|
||||
setStayMarkersVisibleForCurrentPoint(point);
|
||||
return;
|
||||
}
|
||||
|
||||
const state = currentStayStateFor(point);
|
||||
if (!state) {
|
||||
stopCurrentStayBadge();
|
||||
setStayMarkersVisibleForCurrentPoint(point);
|
||||
return;
|
||||
}
|
||||
|
||||
mapState.currentStayState = state;
|
||||
setStayMarkersVisibleForCurrentPoint(point);
|
||||
if (!mapState.currentStayMarker) {
|
||||
mapState.currentStayMarker = new naver.maps.Marker({
|
||||
position: state.latlng,
|
||||
@@ -2557,6 +2573,7 @@ function renderHistoryPoints(rawPoints) {
|
||||
marker.infoWindow = new naver.maps.InfoWindow({
|
||||
content: buildStayInfoContent(stay)
|
||||
});
|
||||
marker.stayPoint = stay;
|
||||
naver.maps.Event.addListener(marker, "click", () => {
|
||||
if (mapState.openInfoWindow && mapState.openInfoWindow !== marker.infoWindow) {
|
||||
mapState.openInfoWindow.close();
|
||||
@@ -2566,6 +2583,9 @@ function renderHistoryPoints(rawPoints) {
|
||||
});
|
||||
mapState.stayMarkers.push(marker);
|
||||
});
|
||||
setStayMarkersVisibleForCurrentPoint(
|
||||
hasValidCoords(lastLat, lastLng) ? { lat: lastLat, lng: lastLng } : null
|
||||
);
|
||||
|
||||
if (!mapState.historyBoundsFitted) {
|
||||
fitHistoryOrCurrentBounds();
|
||||
@@ -2608,6 +2628,7 @@ function updateDOMWithData(data) {
|
||||
applyHistoryCounts(data);
|
||||
updateHistoryMarkers(data.history);
|
||||
}
|
||||
setStayMarkersVisibleForCurrentPoint(null);
|
||||
|
||||
// 상대시간 갱신 중단
|
||||
lastUpdateISOTime = null;
|
||||
@@ -2652,12 +2673,14 @@ function updateDOMWithData(data) {
|
||||
lastLat = data.latitude;
|
||||
lastLng = data.longitude;
|
||||
lastUpdateISOTime = data.updated;
|
||||
updateCurrentStayBadge({
|
||||
const currentPoint = {
|
||||
lat: data.latitude,
|
||||
lng: data.longitude,
|
||||
latlng,
|
||||
time: data.updated || new Date().toISOString(),
|
||||
});
|
||||
};
|
||||
setStayMarkersVisibleForCurrentPoint(currentPoint);
|
||||
updateCurrentStayBadge(currentPoint);
|
||||
}
|
||||
|
||||
function animateCircleRadius(targetRadius) {
|
||||
|
||||
Reference in New Issue
Block a user