From a65a38650fcfcbe879640a1b08b9f71200700264 Mon Sep 17 00:00:00 2001 From: JANGHYUNn Date: Fri, 19 Jul 2024 15:02:08 +0900 Subject: [PATCH] =?UTF-8?q?=EA=B1=B0=EB=A6=AC=EC=B8=A1=EC=A0=95(=EC=A7=81?= =?UTF-8?q?=EC=84=A0,=EB=8B=A4=EA=B8=B0=EB=8A=A5)=20=ED=83=80=EC=9E=85=20?= =?UTF-8?q?=EB=B3=84=20=EA=B1=B0=EB=A6=AC=EA=B3=84=EC=82=B0=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utility/MapUtils.js | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/src/utility/MapUtils.js b/src/utility/MapUtils.js index 7ae40c4f..f9d2e186 100644 --- a/src/utility/MapUtils.js +++ b/src/utility/MapUtils.js @@ -713,16 +713,27 @@ export const handlerDrawEvents = (mapInstance, callback, refObj, drawObj) => { if (startPoint) { mouseCursorRef.current.style.display = 'none'; if (drawMode === 'direct_select') { + const type = drawObj.getAll(); // distanceMarkers.map(i => i.remove()); - - const distance = getDrawDistance(drawObj, drawMode); - totalDistanceRef.current.innerText = `총 거리 : ${distance.toLocaleString()}m`; + if (type.features[0].geometry.type === 'LineString') { + const markerList = getDintancePointPopupList(drawObj); + callback(mapInstance, markerList, drawObj); + const distance = getDrawDistance(drawObj, 'draw_line_string'); + totalDistanceRef.current.innerText = `총 거리 : ${distance.toLocaleString()}m`; + } else { + const distance = getDrawDistance(drawObj, 'draw_polygon'); + const area = getArea(drawObj); + totalDistanceRef.current.innerText = `둘레 : ${distance.toLocaleString()}m`; + totalAreaRef.current.innerText = `면적 : ${area}m²`; + } } } - if (drawMode === 'direct_select') { - const markerList = getDintancePointPopupList(drawObj); - callback(mapInstance, markerList, drawObj); - } + // if (drawMode === 'direct_select') { + // if (drawMode === 'draw_line_string') { + // const markerList = getDintancePointPopupList(drawObj); + // callback(mapInstance, markerList, drawObj); + // } + // } if (drawMode === 'draw_line_string') { if (drawObj.getAll().features[0].geometry.coordinates.length === 1) { mouseCursorRef.current.style.display = 'block'; @@ -765,6 +776,7 @@ export const getDrawDistance = (drawObj, drawMode) => { coordinates: [...feature] } }; + distance = turf.length(obj, { units: 'kilometers' }); distance = distance * 1000; distance = distance