Browse Source

Merge branch 'ZHNY_DCF' into ZHNY_LHR

Administrator 2 years ago
parent
commit
1052b3d933
2 changed files with 82 additions and 36 deletions
  1. 31 0
      src/views/Main/components/map.vue
  2. 51 36
      src/views/Map3d/components/sbyxjc.vue

+ 31 - 0
src/views/Main/components/map.vue

@@ -93,6 +93,7 @@
 			 * 初始化
 			 */
 			init(el) {
+				let that = this
 				//初始化大球
 				this.initMap3d(el);
 
@@ -109,6 +110,36 @@
 				this.$emit("onload", jt3d);
 				// console.log(this.$parent)
 				this.$parent.jtMap3DOnload(jt3d);
+				
+				that.entity1 = new Cesium.Entity({
+					name: "add billboard",
+					//位置
+					position: Cesium.Cartesian3.fromDegrees(120.623, 36.9157, 100),
+					//图片标签
+					billboard: {
+						image: 'jt3dSDK/imgs/point/point.png',
+						horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //水平
+						verticalOrigin: Cesium.VerticalOrigin.BOTTOM, //垂直位置
+						// scale: billboard.scale, //尺寸
+						// pixelOffset: new Cesium.Cartesian2(0, billboard.pixelOffset),
+						disableDepthTestDistance: Number.POSITIVE_INFINITY,
+						scale: 1,
+						// scaleByDistance: new Cesium.NearFarScalar(1.5e2, 1, 2400,
+						// 		0
+						// 		) //按距离缩放,即距离大于180米时,图标不显示  Cesium.NearFarScalar(near, nearValue, far, farValue)相机范围的下界。相机范围下界的值。相机范围的上限。该值位于摄像机范围的上界。
+					}
+					// point:{
+					// 	pixelSize:20,
+					// 	color:Cesium.Color.RED,
+					// }
+				});
+				var entity = jt3d._viewer.entities.add(that.entity1, {
+					// range: 1000
+				});
+				setTimeout(res=>{
+					jt3d.LocateUtil.flyToEntity(that.entity)
+				},6000)
+				
 
 				//单击事件
 				// this.clickEntity(jt3d);

+ 51 - 36
src/views/Map3d/components/sbyxjc.vue

@@ -115,47 +115,62 @@
 		},
 		methods: {
 			flyto(num) {
+				return
 				let terrainProvider = jt3d._viewer.terrainProvider;
 				//异步函数
 				let lon = 116.30
 				let lat = 36.88
 				let that = this
-				return new Promise((resolve, reject) => {
-					let promise = new Cesium.sampleTerrainMostDetailed(terrainProvider, [Cesium
-						.Cartographic.fromDegrees(lon, lat)
-					]);
-					promise.then(function(updatedPositions) {
-						if (that.entity) {
-							jt3d._viewer.entities.remove(that.entity)
-						}
-						// if that.entity && jt3d._viewer.entities.remove(that.entity)
-						console.log('高度', updatedPositions)
-						let height = 1000
+				if (that.entity) {
+					jt3d._viewer.entities.remove(that.entity)
+				}
+				// if that.entity && jt3d._viewer.entities.remove(that.entity)
+				// console.log('高度', updatedPositions)
+				let height = 1000
 
-						that.entity = new Cesium.Entity({
-							name: "add billboard",
-							//位置
-							position: Cesium.Cartesian3.fromDegrees(lon, lat, height),
-							//图片标签
-							billboard: {
-								image: 'jt3dSDK/imgs/point/point.png',
-								horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //水平
-								verticalOrigin: Cesium.VerticalOrigin.BOTTOM, //垂直位置
-								// scale: billboard.scale, //尺寸
-								// pixelOffset: new Cesium.Cartesian2(0, billboard.pixelOffset),
-								disableDepthTestDistance: Number.POSITIVE_INFINITY,
-								scale: 1,
-								scaleByDistance: new Cesium.NearFarScalar(1.5e2, 1, 2400,
-									0) //按距离缩放,即距离大于180米时,图标不显示  Cesium.NearFarScalar(near, nearValue, far, farValue)相机范围的下界。相机范围下界的值。相机范围的上限。该值位于摄像机范围的上界。
-							}
-						});
-						jt3d._viewer.entities.add(that.entity, {
-							range: 1000
-						});
-						jt3d.LocateUtil.flyToEntity(that.entity)
+				that.entity1 = new Cesium.Entity({
+					name: "add billboard",
+					//位置
+					position: Cesium.Cartesian3.fromDegrees(120.623, 36.9157, 100),
+					//图片标签
+					billboard: {
+						image: 'jt3dSDK/imgs/point/point.png',
+						horizontalOrigin: Cesium.HorizontalOrigin.CENTER, //水平
+						verticalOrigin: Cesium.VerticalOrigin.BOTTOM, //垂直位置
+						// scale: billboard.scale, //尺寸
+						// pixelOffset: new Cesium.Cartesian2(0, billboard.pixelOffset),
+						disableDepthTestDistance: Number.POSITIVE_INFINITY,
+						scale: 1,
+						// scaleByDistance: new Cesium.NearFarScalar(1.5e2, 1, 2400,
+						// 		0
+						// 		) //按距离缩放,即距离大于180米时,图标不显示  Cesium.NearFarScalar(near, nearValue, far, farValue)相机范围的下界。相机范围下界的值。相机范围的上限。该值位于摄像机范围的上界。
+					}
+					// point:{
+					// 	pixelSize:20,
+					// 	color:Cesium.Color.RED,
+					// }
+				});
+				var entity = jt3d._viewer.entities.add(that.entity1, {
+					// range: 1000
+				});
+				jt3d.LocateUtil.flyToEntity(that.entity)
+				setTimeout(res=>{
+					console.log('定位')
+					console.log('实体', entity)
+					jt3d.LocateUtil.flyToEntity(that.entity)
+					jt3d._viewer.flyTo(entity,{
+						duration:5.0,
+						maximumHeight:1500
+					}).then(res=>{
+						console.log('定位结束' + res)
+					}).catch(err=>{
+						console.log("err" + err);
 					})
-					resolve(true)
-				})
+					// jt3d._viewer.camera.flyTo({
+					//     destination : Cesium.Cartesian3.fromDegrees(120.623, 36.9157, 1500)
+					// });
+				},2000)
+				
 				// let lng = Number(114.22) + Number(num)
 				// this.entity = new Cesium.Entity({
 				// 	name: "add billboard",
@@ -173,11 +188,11 @@
 				// 		scaleByDistance: new Cesium.NearFarScalar(1.5e2, 1, 2400, 0) //按距离缩放,即距离大于180米时,图标不显示  Cesium.NearFarScalar(near, nearValue, far, farValue)相机范围的下界。相机范围下界的值。相机范围的上限。该值位于摄像机范围的上界。
 				// 	}
 				// });
-				console.log('实体', this.entity)
+				
 				// jt3d._viewer.entities.add(this.entity, {
 				// 	range: 1000
 				// });
-				
+
 			}
 		},
 		mounted() {