here is a function of JS to compute the distance of two GPS points:
PHP calculates the distance between two GPS points
MySQL calculates the distance between two GPS coordinates
JavaScript calculates the distance function between two GPS points Torad (d) {return d * math.pi/180;} function Getdisance (LAT1, Lng1, LAT2, lng2) {#lat For latitude, LNG is longitude, must not be mistaken var dis = 0; var radLat1 = Torad (LAT1); var radLat2 = Torad (LAT2); var deltalat = Radlat1-radlat2; var deltalng = Torad (lng1)-Torad (LNG2); var dis = 2 * math.asin (MATH.SQRT (Math.pow (Math.sin (DELTALAT/2), 2) + Math.Cos (RADLAT1) * MATH.COS (RADLAT2) * MATH.POW (M Ath.sin (DELTALNG/2), 2)); return dis * 6378137; Alert (Getdisance (39.91917,116.3896,39.91726,116.3940));
1 2 3 4 5 6 7 8 9 Ten |
function Torad (d) { return d * Ma Th. pi/180; function Getdisance (LAT1, Lng1, LAT2, lng2) {#lat为纬度, LNG is longitude, must not be mistaken var dis = 0; ; var radLat1 = Torad (LAT1); var radLat2 = Torad (LAT2); var deltalat = radlat1-radlat2; var deltalng = Torad (lng1)-Torad (LNG2); var dis = 2 * Math. ASIN (Math. sqrt (Math. Pow (DELTALAT/2), 2) + math. cos (RADLAT1) * math. cos (RADLAT2) * Ma Th. Pow (Math. Sin (DELTALNG/2), 2)); return dis * 6378137; Alert ( getdisance (39.91917, 116.3896, 39.91726, 116.3940)); |