|
|
@@ -33,6 +33,7 @@
|
|
|
<script>
|
|
|
import InfoLayer from "./map-components/InfoLayer";
|
|
|
let viewer = undefined;
|
|
|
+ let scratch = new Cesium.Cartesian2();
|
|
|
export default {
|
|
|
name: "Map3D",
|
|
|
components: {InfoLayer},
|
|
|
@@ -86,14 +87,15 @@ export default {
|
|
|
this.$viewer = viewer;
|
|
|
// 隐藏logo
|
|
|
viewer._cesiumWidget._creditContainer.style.display = "none";
|
|
|
- viewer.scene.globe.baseColor = Cesium.Color.fromCssColorString("rgba(20,56,76,0.5)");
|
|
|
+
|
|
|
// viewer.imageryLayers.removeAll();
|
|
|
// viewer.imageryLayers.addImageryProvider(
|
|
|
// new Cesium.BaiduImageryProvider({
|
|
|
- // style: 'midnight',
|
|
|
+ // style: 'normal',
|
|
|
// crs: 'WGS84'
|
|
|
// })
|
|
|
// );
|
|
|
+ viewer.scene.globe.baseColor = Cesium.Color.fromCssColorString("rgba(20,56,76,0.5)");
|
|
|
viewer.scene.preRender.addEventListener(this.moveListener);
|
|
|
},
|
|
|
//添加建筑矢量数据,url为建模json数据
|
|
|
@@ -150,6 +152,16 @@ export default {
|
|
|
}
|
|
|
);
|
|
|
},
|
|
|
+ //添加百度地图地图
|
|
|
+ addBaiduLayer(){
|
|
|
+ viewer.imageryLayers.removeAll();
|
|
|
+ viewer.imageryLayers.addImageryProvider(
|
|
|
+ new Cesium.BaiduImageryProvider({
|
|
|
+ style: 'midnight',
|
|
|
+ crs: 'WGS84'
|
|
|
+ })
|
|
|
+ );
|
|
|
+ },
|
|
|
//添加图标覆盖物(多个)
|
|
|
addBillBoards(element,option= {},layerId){
|
|
|
let layer = new Cesium.BillboardCollection(option);
|
|
|
@@ -175,19 +187,20 @@ export default {
|
|
|
},
|
|
|
//屏幕坐标转化
|
|
|
convertScreen(position){
|
|
|
- let scratch = new Cesium.Cartesian2();
|
|
|
return viewer.scene.cartesianToCanvasCoordinates(
|
|
|
- Cesium.Cartesian3.fromDegrees(position[0], position[1]),
|
|
|
- scratch
|
|
|
+ Cesium.Cartesian3.fromDegrees(position[0], position[1], 0),
|
|
|
+ new Cesium.Cartesian2()
|
|
|
);
|
|
|
},
|
|
|
//相机移动事件
|
|
|
moveListener(){
|
|
|
+
|
|
|
this.positionListenerList.forEach(item => {
|
|
|
- let location = this.convertScreen(item.position);
|
|
|
- item.x = location.x-300;
|
|
|
- item.y = location.y-300;
|
|
|
- console.log(item)
|
|
|
+ let location = this.convertScreen(item.position);
|
|
|
+ if(Cesium.defined(location)) {
|
|
|
+ item.x = location.x;
|
|
|
+ item.y = location.y;
|
|
|
+ }
|
|
|
})
|
|
|
},
|
|
|
//添加坐标监控
|
|
|
@@ -203,7 +216,7 @@ export default {
|
|
|
//初始化弹框图层
|
|
|
this.$refs['infoLayer'].onload();
|
|
|
//添加建筑矢量数据
|
|
|
- this.addBuildingData('http://139.9.103.171/mapData/zhengzhou/tileset.json')
|
|
|
+ this.addBuildingData('http://139.9.103.171/mapData/zhengzhou/tileset.json')
|
|
|
//定位建筑群位置
|
|
|
this.flyToPosition(113.682062,34.662187, 2000.0,0,-20.0,0.0);
|
|
|
},
|