좌표계산1 [Javascript] GPS 좌표상 거리 계산 방법 function calcDistance(locLat, locLng, myLat, myLng){ const earth_r = 6371; //지구 반지름(km) const dLat = deg2Rad(myLat - locLat); const dLng = def2Rad(myLng - locLng); const a = Math.sin(dLat/2) * Math.sin(dLat/2) + Math.cos(deg2Rad(LocLat)) * Math.cos(deg2Rad(myLat)) * Math.sin(dLng/2) * Math.sin(dLng/2); const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a)); const distance = earth_r * c; return d.. 2023. 12. 1. 이전 1 다음