openlayer3計算兩點之間的距離
對應的openlayers的版本為3.7.
主要用的接口是ol.Sphere.haversineDistance([x1,y1],[x2,y2]); 4326坐標系中計算兩點距離的方式為: var wgs84Sphere = new ol.Sphere(6378137); wgs84Sphere.haversineDistance(C1,C2); 示例為: var wgs84Sphere = new ol.Sphere(6378137); wgs84Sphere.haversineDistance([120.21592590991689, 30.210793016606],[120.21670777384473, 30.211168525868086]);