cesium引入czml卫星文件,绘制卫星的圆锥覆盖范围

const satellCzml = () => {
	const satelliteNames = ['Satellite/Satellite'];
	const satelliteAll = [];
	viewer.dataSources.removeAll();
	viewer.dataSources
		.add(Cesium.CzmlDataSource.load('/SampleData/FlightProcedure.czml'))
		.then((dataSource) => {
			for (let i = 0; i < satelliteNames.length; i++) {
				satelliteAll.push(dataSource.entities.getById(satelliteNames[i]));
			}
			for (let i = 0; i < satelliteAll.length; i++) {
				let _update = function () {
					let positions1 = satelliteAll[i].position.getValue(viewer.clock.currentTime);
					if (positions1) {
						let cartographic = viewer.scene.globe.ellipsoid.cartesianToCartographic(positions1);
						let lat = Cesium.Math.toDegrees(cartographic.latitude);
						let lng = Cesium.Math.toDegrees(cartographic.longitude);
						let hei = parseFloat(cartographic.height / 2.1);
						return Cesium.Cartesian3.fromDegrees(lng, lat, hei);
					}
				};
				let _updates = function () {
					let positions1s = satelliteAll[i].position.getValue(viewer.clock.currentTime);
					if (positions1s) {
						let cartographics = viewer.scene.globe.ellipsoid.cartesianToCartographic(positions1s);
						let heis = parseFloat(cartographics.height);
						return heis
					}
				};
				var cylinderEntity = viewer.entities.add({
					id: "Satellitegreen",
					position: new Cesium.CallbackProperty(_update, false),
					cylinder: {
						HeightReference: Cesium.HeightReference.CLAMP_TO_GROUND,
						length: new Cesium.CallbackProperty(_updates, false),
						topRadius: 0.0,
						bottomRadius: new Cesium.CallbackProperty(_updates, false).getValue() / 6,
						material: Cesium.Color.GREEN.withAlpha(.8),
						outline: !0,
						numberOfVerticalLines: 0,
						outlineColor: Cesium.Color.GREEN.withAlpha(.8)
					}
				})

			}
		});
};

你可能感兴趣的:(前端,javascript,开发语言)