var arr=[ [116.90259541467819,36.66764758857364],[116.90259541467819,36.667700713502974],[116.9026,36.668] ],scene=viewer.scene; function sampleHeights() { const cartesians =arr.map(A=>{ var c=bmgl.Cartesian3.fromDegrees(...A) return c }); console.log(cartesians,57) scene .clampToHeightMostDetailed(cartesians) .then(function (clampedCartesians) { for (let i = 0; i < cartesians.length; ++i) { viewer.entities.add({ position: clampedCartesians[i], ellipsoid: { radii: new bmgl.Cartesian3(0.2, 0.2, 0.2), material: bmgl.Color.ORANGE, }, }); } viewer.entities.add({ polyline: { positions: clampedCartesians, arcType: bmgl.ArcType.NONE, width: 2, material: new bmgl.PolylineOutlineMaterialProperty({ color: bmgl.Color.BLUE, }), depthFailMaterial: new bmgl.PolylineOutlineMaterialProperty( { color: bmgl.Color.BLUE, } ), }, }); }); }
源码