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>
</p>
<p>
{selected && drawObj.getMode() === 'simple_select' && (
<Input
type='text'
bsSize='sm'
placeholder='반경을 입력해주세요'
value={metersRadius}
onKeyDown={e => {
const input = e.target;
const { value } = input;
if (e.key === 'Backspace') {
if (input.length > 2) {
input.setSelectionRange(
value.length - 2,
value.length - 2
);
} else {
input.setSelectionRange(
value.length - 1,
value.length - 1
{selected &&
drawObj.getMode() === 'simple_select' &&
drawType === 'LINE' && (
<Input
type='text'
bsSize='sm'
placeholder='반경을 입력해주세요'
value={metersRadius}
onKeyDown={e => {
const input = e.target;
const { value } = input;
if (e.key === 'Backspace') {
if (input.length > 2) {
input.setSelectionRange(
value.length - 2,
value.length - 2
);
} else {
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, '');
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
}}
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'
);
drawObj.set({
type: 'FeatureCollection',
features: [
{ ...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');
}
}}
/>
)}
}}
onBlur={() => {
if (metersRadius === 'm') {
setMetersRadius('0m');
}
}}
/>
)}
</p>
</div>
</div>

3
src/containers/flight/OperationApprovalsContainer.js

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

Loading…
Cancel
Save