Browse Source

비행 비물레이션 숫자 -> hh:mm 형식 변환

pull/2/head
sanguu516(박상현) 1 year ago
parent
commit
a8152c92b9
  1. 29
      src/components/analysis/simulation/AnalysisSimulatorSlider.js
  2. 4
      src/components/map/MapControl.js

29
src/components/analysis/simulation/AnalysisSimulatorSlider.js

@ -7,6 +7,22 @@ const AnalysisSimulatorSlider = ({
playCount,
setSliderCount
}) => {
// hh:mm 형식으로 바꿔주는 코드
function convertToTimeFormat(number) {
// 시간과 분 계산
const hours = Math.floor(number / 60);
const minutes = Math.floor(number % 60);
// 2자리 숫자로 포맷팅
const formattedHours = String(hours).padStart(2, '0');
const formattedMinutes = String(minutes).padStart(2, '0');
// 시간 문자열 생성
const timeString = `${formattedHours}:${formattedMinutes}`;
return timeString;
}
const colorOptions = {
start: [playCount ? playCount : 0],
// connect: true,
@ -20,9 +36,10 @@ const AnalysisSimulatorSlider = ({
format: {
// 'to' the formatted value. Receives a number.
to: function (value) {
return Math.round(value);
return convertToTimeFormat(value);
},
// 'from' the formatted value.
// // 'from' the formatted value.
// Receives a string, should return a number.
from: function (value) {
return Math.round(value);
@ -34,7 +51,13 @@ const AnalysisSimulatorSlider = ({
density: 3
},
onChange: e => {
setSliderCount(e);
function timeStringToMinutes(timeString) {
const [hours, minutes] = timeString.split(':').map(Number);
const totalMinutes = hours * 60 + minutes;
return totalMinutes.toString();
}
setSliderCount(e.map(timeStringToMinutes));
},
direction
};

4
src/components/map/MapControl.js

@ -5,8 +5,8 @@ import MapBoxMap from './mapbox/MapBoxMap';
export const MapControl = props => {
return (
<>{props.mapType === 'google' ? <GoogleCustomMap /> : <NaverCustomMap />}</>
// <>{props.mapType === 'google' ? <GoogleCustomMap /> : <NaverCustomMap />}</>
// <NaverCustomMap />
// <MapBoxMap />
<MapBoxMap />
);
};

Loading…
Cancel
Save