Fork Copy class Point { constructor(lat, lng) { this.lat = lat; this.lng = lng } distance(p) { const R_EARTH = 6367.445 const R_HN = Math.cos(this.lat * Math.PI/180) * R_EARTH; const _1k = R_HN * 2 * Math.PI / 360; const _1v = R_EARTH * 2 * Math.PI / 360; console.log(Math.abs(this.lng - p.lng)); let dk = Math.abs(this.lng - p.lng) * _1k; let dv = Math.abs(this.lat - p.lat) * _1v; return Math.sqrt(dk * dk + dv * dv); } } let cuaSo = new Point(21.0461635, 105.7955456) let choNgoi = new Point(21.0461659, 105.7955152) document.write(choNgoi.distance(cuaSo))