Browse Source

거리측정 입력 조건 추가

master
김장현 1 month ago
parent
commit
ff2ed846ad
  1. 134
      src/containers/flight/ControlApprovalsContainer.js
  2. 3
      src/containers/flight/OperationApprovalsContainer.js

134
src/containers/flight/ControlApprovalsContainer.js

@ -715,75 +715,77 @@ export default function ControlApprovalsContainer({ mode }) {
</span> </span>
</p> </p>
<p> <p>
{selected && drawObj.getMode() === 'simple_select' && ( {selected &&
<Input drawObj.getMode() === 'simple_select' &&
type='text' drawType === 'LINE' && (
bsSize='sm' <Input
placeholder='반경을 입력해주세요' type='text'
value={metersRadius} bsSize='sm'
onKeyDown={e => { placeholder='반경을 입력해주세요'
const input = e.target; value={metersRadius}
const { value } = input; onKeyDown={e => {
if (e.key === 'Backspace') { const input = e.target;
if (input.length > 2) { const { value } = input;
input.setSelectionRange( if (e.key === 'Backspace') {
value.length - 2, if (input.length > 2) {
value.length - 2 input.setSelectionRange(
); value.length - 2,
} else { value.length - 2
input.setSelectionRange( );
value.length - 1, } else {
value.length - 1 input.setSelectionRange(
value.length - 1,
value.length - 1
);
}
} else if (e.key === 'Enter') {
let val = value.replace(/[^\d.]/g, '');
if (!val) return;
const sources = drawObj.getAll();
const option = {
steps: 0,
units: 'meters'
};
const rad = turf.circle(
sources.features[0].geometry.coordinates[0],
parseInt(val),
option
); );
drawObj.set({
type: 'FeatureCollection',
features: [
{ ...sources.features[0] },
{
type: 'Feature',
properties: {},
id: 'pal_Polygon_string',
geometry: { ...rad.geometry }
}
]
});
} }
} else if (e.key === 'Enter') { }}
let val = value.replace(/[^\d.]/g, ''); onChange={e => {
if (!val) return; const target = e.target;
const sources = drawObj.getAll(); const { value, selectionStart } = target;
// const numericValue = value.replace(/[^\d.]/g, '');
const option = {
steps: 0, setMetersRadius(
units: 'meters' value
}; .replace(/^0+/, '') // 맨 앞의 0 제거
const rad = turf.circle( .replace(/[^\d.]/g, '') // 숫자가 아닌 문자 제거
sources.features[0].geometry.coordinates[0], .replace(/\B(?=(\d{3})+(?!\d))/g, ',') + 'm'
parseInt(val),
option
); );
}}
drawObj.set({ onBlur={() => {
type: 'FeatureCollection', if (metersRadius === 'm') {
features: [ setMetersRadius('0m');
{ ...sources.features[0] }, }
{ }}
type: 'Feature', />
properties: {}, )}
id: 'pal_Polygon_string',
geometry: { ...rad.geometry }
}
]
});
}
}}
onChange={e => {
const target = e.target;
const { value, selectionStart } = target;
// const numericValue = value.replace(/[^\d.]/g, '');
setMetersRadius(
value
.replace(/^0+/, '') // 맨 앞의 0 제거
.replace(/[^\d.]/g, '') // 숫자가 아닌 문자 제거
.replace(/\B(?=(\d{3})+(?!\d))/g, ',') + 'm'
);
}}
onBlur={() => {
if (metersRadius === 'm') {
setMetersRadius('0m');
}
}}
/>
)}
</p> </p>
</div> </div>
</div> </div>

3
src/containers/flight/OperationApprovalsContainer.js

@ -869,7 +869,8 @@ export default function OperationApprovalsContainer({ mode }) {
<p> <p>
{selectedPlanSno && {selectedPlanSno &&
drawObj.getMode() === 'simple_select' && ( drawObj.getMode() === 'simple_select' &&
drawType === 'LINE' && (
<Input <Input
type='text' type='text'
bsSize='sm' bsSize='sm'

Loading…
Cancel
Save