地图位置调整
This commit is contained in:
parent
2b4ccc1e5e
commit
9fa1e63438
|
@ -374,21 +374,23 @@ export default {
|
||||||
var url = "factory.glb";
|
var url = "factory.glb";
|
||||||
var height = 0;
|
var height = 0;
|
||||||
viewer.entities.removeAll() //加载之前先清楚所有entity
|
viewer.entities.removeAll() //加载之前先清楚所有entity
|
||||||
var position = Cesium.Cartesian3.fromDegrees(87.62594666147378, 42.975362631477815, height)
|
var position = Cesium.Cartesian3.fromDegrees(88.644, 42.7229, height)
|
||||||
var heading = Cesium.Math.toRadians(310) //135度转弧度
|
var heading = Cesium.Math.toRadians(191) //310度转弧度
|
||||||
var pitch = Cesium.Math.toRadians(0);
|
var pitch = Cesium.Math.toRadians(0);
|
||||||
var roll = Cesium.Math.toRadians(0);
|
var roll = Cesium.Math.toRadians(0);
|
||||||
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll)
|
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll)
|
||||||
var orientation = Cesium.Transforms.headingPitchRollQuaternion(
|
var orientation = Cesium.Transforms.headingPitchRollQuaternion(
|
||||||
position,hpr
|
position,hpr
|
||||||
)
|
)
|
||||||
|
var modelScale = 30.0; // 假设模型原始单位是厘米,需要转换为米
|
||||||
var modelEntity = viewer.entities.add({
|
var modelEntity = viewer.entities.add({
|
||||||
name: 'photon',
|
name: 'photon',
|
||||||
position: position,
|
position: position,
|
||||||
orientation: orientation,
|
orientation: orientation,
|
||||||
model: {
|
model: {
|
||||||
uri: url,//注意entitits.add方式加载gltf文件时,这里是uri,不是url,并且这种方式只能加载.glb格式的文件
|
uri: url,//注意entitits.add方式加载gltf文件时,这里是uri,不是url,并且这种方式只能加载.glb格式的文件
|
||||||
scale: 1.0,//缩放比例
|
scale: modelScale,//缩放比例
|
||||||
|
modelMatrix: Cesium.Transforms.eastNorthUpToFixedFrame(position),
|
||||||
minimumPixelSize: 256,//最小像素大小,可以避免太小看不见
|
minimumPixelSize: 256,//最小像素大小,可以避免太小看不见
|
||||||
maximumScale: 20000,//模型的最大比例尺大小。minimumPixelSize的上限
|
maximumScale: 20000,//模型的最大比例尺大小。minimumPixelSize的上限
|
||||||
incrementallyLoadTextures: true,//加载模型后纹理是否可以继续流入
|
incrementallyLoadTextures: true,//加载模型后纹理是否可以继续流入
|
||||||
|
@ -397,14 +399,17 @@ export default {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
viewer.trackedEntity = modelEntity; // 聚焦模型
|
viewer.trackedEntity = modelEntity; // 聚焦模型
|
||||||
viewer.zoomTo(modelEntity, new Cesium.HeadingPitchRange(-4.2, -0.5, 30));
|
//设置相机位置
|
||||||
|
viewer.zoomTo(modelEntity, new Cesium.HeadingPitchRange(-3.1, -0.6, 900));
|
||||||
that.getEquipmentList();
|
that.getEquipmentList();
|
||||||
// 监听鼠标左键点击事件
|
// 监听鼠标左键点击事件
|
||||||
var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
|
var handler = new Cesium.ScreenSpaceEventHandler(viewer.canvas);
|
||||||
handler.setInputAction(function (click) {
|
handler.setInputAction(function (click) {
|
||||||
var feature = viewer.scene.pick(click.position);
|
var feature = viewer.scene.pick(click.position);
|
||||||
|
if (feature.id._attrs) {
|
||||||
that.objItem = feature.id._attrs;
|
that.objItem = feature.id._attrs;
|
||||||
that.getInfo(feature.id._id);
|
that.getInfo(feature.id._id);
|
||||||
|
}
|
||||||
if (Cesium.defined(feature)) {
|
if (Cesium.defined(feature)) {
|
||||||
// 判断点击位置是否有模型被选中
|
// 判断点击位置是否有模型被选中
|
||||||
var pickedPosition = viewer.scene.pickPosition(click.position);
|
var pickedPosition = viewer.scene.pickPosition(click.position);
|
||||||
|
@ -423,7 +428,6 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
Cesium.ScreenSpaceEventType.LEFT_CLICK);
|
||||||
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getChartTime() {
|
getChartTime() {
|
||||||
|
@ -522,7 +526,7 @@ export default {
|
||||||
let imgUrl = that.getItemIcon(item.cate_code)
|
let imgUrl = that.getItemIcon(item.cate_code)
|
||||||
let lon = parseFloat(item.coordinates.longitude);
|
let lon = parseFloat(item.coordinates.longitude);
|
||||||
let lat = parseFloat(item.coordinates.latitude);
|
let lat = parseFloat(item.coordinates.latitude);
|
||||||
let height = parseInt(item.coordinates.height) + 0.5;
|
let height = parseInt(item.coordinates.height) + 15;
|
||||||
let type = item.cate_code;
|
let type = item.cate_code;
|
||||||
let arrs = { name:item.name, lon: lon, lat:lat, height:height, id:item.id, type: type };
|
let arrs = { name:item.name, lon: lon, lat:lat, height:height, id:item.id, type: type };
|
||||||
let config = { show: true, fontSize: '16px', fillColor: '#ffffff', fillWidth: 1, pixelOffsetX: 10, pixelOffsetY: -30, image: imgUrl, imgWidth: 50, imgHeight: 50, textDistance: 550000, imgDistance: 550000 };
|
let config = { show: true, fontSize: '16px', fillColor: '#ffffff', fillWidth: 1, pixelOffsetX: 10, pixelOffsetY: -30, image: imgUrl, imgWidth: 50, imgHeight: 50, textDistance: 550000, imgDistance: 550000 };
|
||||||
|
|
Loading…
Reference in New Issue