public double distance(double n1, double e1, double n2, double e2) { double jl_jd = 102834.74258026089786013677476285//每经度单位米; double jl_wd = 111712.69150641055729984301412873//每纬度单位米; double b = Math.abs((e1 - e2) * jl_jd); double a = Math.abs((n1 - n2) * jl_wd); return Math.sqrt((a * a + b * b)); }
这里用的是百度地图的经纬度,参数是百度地图上获取的2个点的经纬度