Show default history on map
This commit is contained in:
+12
-9
@@ -666,8 +666,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
endTime: toServerTime(endEl.value)
|
||||
};
|
||||
|
||||
// ✅ 사용자가 변경했거나 URL에 기간이 있으면 히스토리 모드
|
||||
const shouldUseHistory = userTriggered || hasQS;
|
||||
const shouldRequestHistory = shouldUseHistory || !userTriggered;
|
||||
if (shouldUseHistory) {
|
||||
_overrideRange = range;
|
||||
resetHistoryLayer();
|
||||
@@ -676,13 +676,16 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
|
||||
try {
|
||||
const data = await fetchDeviceData(true, shouldUseHistory ? range : null);
|
||||
const data = await fetchDeviceData(true, shouldRequestHistory ? range : null);
|
||||
updateDOMWithData(data);
|
||||
|
||||
const last = data.history && data.history[data.history.length - 1];
|
||||
if (last && mapState.map) {
|
||||
mapState.map.panTo(new naver.maps.LatLng(last.lat, last.lng));
|
||||
}
|
||||
if (!shouldUseHistory && data.history?.length > 0) {
|
||||
updateHistoryMarkers(data.history);
|
||||
}
|
||||
|
||||
const last = data.history && data.history[data.history.length - 1];
|
||||
if (shouldUseHistory && last && mapState.map) {
|
||||
mapState.map.panTo(new naver.maps.LatLng(last.lat, last.lng));
|
||||
}
|
||||
} catch (err) {
|
||||
alert(langCode === 'ko' ? '기록을 불러오지 못했습니다.' : 'Failed to load history.');
|
||||
}
|
||||
@@ -1528,7 +1531,7 @@ function updateHistoryMarkers(history) {
|
||||
mapState.historyStartMarker = makeMarker(first, 'start');
|
||||
mapState.historyEndMarker = makeMarker(last, 'end');
|
||||
|
||||
const maxDots = 60;
|
||||
const maxDots = 180;
|
||||
const step = Math.max(1, Math.ceil(points.length / maxDots));
|
||||
points.forEach((pos, idx) => {
|
||||
if (idx === 0 || idx === points.length - 1 || idx % step !== 0) return;
|
||||
@@ -1693,7 +1696,7 @@ function fetchDeviceData(includeLang = true, range = null) {
|
||||
if (e) params.set('endTime', e);
|
||||
if (hasHistoryRange) {
|
||||
params.set('history', '1');
|
||||
params.set('maxPoints', '300');
|
||||
params.set('maxPoints', '800');
|
||||
}
|
||||
|
||||
const url = `https://chaegeon.com/custom/findmydevice/php/api.php?${params.toString()}`;
|
||||
|
||||
Reference in New Issue
Block a user