Commit c67ed13d authored by xxx's avatar xxx

1

parent 78c02a89
...@@ -26,6 +26,7 @@ Vue.prototype.mars3d = mars3d ...@@ -26,6 +26,7 @@ Vue.prototype.mars3d = mars3d
Vue.prototype.Cesium = mars3d.Cesium Vue.prototype.Cesium = mars3d.Cesium
var map; var map;
let pathEntity = null;
export default { export default {
name: 'mars3dViewer', name: 'mars3dViewer',
...@@ -195,7 +196,7 @@ export default { ...@@ -195,7 +196,7 @@ export default {
// 抛出事件 // 抛出事件
this.$emit('onload', map) this.$emit('onload', map)
}, },
//车辆轨迹 //车辆轨迹1
addGraphic_02(graphicLayer2,positions,truckName) { addGraphic_02(graphicLayer2,positions,truckName) {
let that = this; let that = this;
var property = new Cesium.SampledPositionProperty(); var property = new Cesium.SampledPositionProperty();
...@@ -244,6 +245,81 @@ export default { ...@@ -244,6 +245,81 @@ export default {
graphicLayer2.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer) graphicLayer2.addGraphic(graphic); //还可以另外一种写法: graphic.addTo(graphicLayer)
}, },
//车辆轨迹2
initPath(data,graphicLayer2,positions,truckName) {
const property = new Cesium.SampledPositionProperty()
property.forwardExtrapolationType = Cesium.ExtrapolationType.HOLD
let start;
let stop;
for (let i = 0, len = data.length; i < len; i++) {
const item = data[i]
const lng = Number(item.x.toFixed(6)) // 经度
const lat = Number(item.y.toFixed(6)) // 纬度
const height = item.z // 高度
const time = item.time // 时间
let position = null
if (lng && lat) {
position = Cesium.Cartesian3.fromDegrees(lng, lat, height)
}
let juliaDate = null
if (time) {
juliaDate = Cesium.JulianDate.fromIso8601(time)
}
if (position && juliaDate) {
property.addSample(juliaDate, position)
}
if (i === 0) {
start = juliaDate
} else if (i === len - 1) {
stop = juliaDate
}
}
// 设置时钟属性
map.clock.startTime = start.clone()
map.clock.stopTime = stop.clone()
map.clock.currentTime = start.clone()
map.clock.clockRange = Cesium.ClockRange.LOOP_STOP
map.clock.multiplier = 5
if (map.controls.timeline) {
map.controls.timeline.zoomTo(start, stop)
}
// 创建path对象
pathEntity = new mars3d.graphic.PathEntity({
position: property,
orientation: new Cesium.VelocityOrientationProperty(property),
style: {
width: 3,
color: "#ff0000",
opacity: 1.0,
leadTime: 0, // 前方的路线不显示
},
label: {
text: truckName,
font_size: 22,
font_family: "楷体",
color: "#ff0000",
outline: true,
outlineColor: Cesium.Color.BLACK,
outlineWidth: 2,
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
pixelOffset: new Cesium.Cartesian2(10, -25) // 偏移量
},
model: {
url: '//data.mars3d.cn/gltf/mars/car/tufangche.glb',
scale: 1,
minimumPixelSize: 50,
},
})
graphicLayer2.addGraphic(pathEntity)
},
getSampledPositionProperty(points){ getSampledPositionProperty(points){
let property = new Cesium.SampledPositionProperty(); let property = new Cesium.SampledPositionProperty();
let start = this.map.clock.currentTime; let start = this.map.clock.currentTime;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment