cesium根据经纬度计算距离

时间:2023-01-23 20:05:48

var startLatitude = 36;
var startLongitude = 120;

var endLatitude=34;

var endLongitude=121;

var startCartographic = Cesium.Cartographic.fromDegrees(startLongitude, startLatitude);

var endCartographic = Cesium.Cartographic.fromDegrees(endLongitude, endLatitude);

/**根据经纬度计算出距离**/
var geodesic = new Cesium.EllipsoidGeodesic();
geodesic.setEndPoints(startCartographic, endCartographic);

var distance=geodesic.surfaceDistance;