(function (window, mars3d) {
|
//创建widget类,需要继承BaseWidget
|
class MyWidget extends mars3d.widget.BaseWidget {
|
//弹窗配置
|
get view() {
|
return {
|
type: "window",
|
url: "view.html",
|
windowOptions: {
|
width: 350,
|
},
|
};
|
}
|
|
reloadData(new_taxi_sn) {
|
this.viewWindow.resetStartQueryTaxiDataText(new_taxi_sn);
|
this.taxi_sn = new_taxi_sn;
|
|
if (this.startGraphic) {
|
this.startGraphic.remove();
|
this.startGraphic = null;
|
}
|
if (this.endGraphic) {
|
this.endGraphic.remove();
|
this.endGraphic = null;
|
}
|
this.routeLayer.clear();
|
}
|
|
clearReplayLayers() {
|
this.pointLayer.clear();
|
this.routeLayer.clear();
|
}
|
|
addTaxiReplayGraphic(points) {
|
|
this.startGraphic = new mars3d.graphic.BillboardEntity({
|
position: points[0],
|
style: {
|
image: this.path + "img/start.png",
|
scale: 1,
|
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
clampToGround: true,
|
},
|
});
|
this.pointLayer.addGraphic(this.startGraphic);
|
|
this.endGraphic = new mars3d.graphic.BillboardEntity({
|
position: points[points.length - 1],
|
style: {
|
image: this.path + "img/end.png",
|
scale: 1,
|
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
|
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
|
clampToGround: true,
|
},
|
});
|
this.pointLayer.addGraphic(this.endGraphic);
|
let graphic = new mars3d.graphic.PolylineEntity({
|
positions: points,
|
style: {
|
width: 10,
|
material: new mars3d.material.LineFlowMaterialProperty({
|
color: Cesium.Color.AQUA,
|
image: "./img/textures/arrow2.png",
|
repeat: new Cesium.Cartesian2(50, 1),
|
speed: 40, //速度,建议取值范围1-100
|
})
|
},
|
});
|
this.routeLayer.addGraphic(graphic);
|
this.routeLayer.flyTo();
|
|
}
|
|
setSingleTaxiReplayData(datas) {
|
mars3d.global_variables.singleTaxiReplayData = datas;
|
}
|
|
refreshDetailTable(tmpattr) {
|
this.viewWindow.refreshDetailTable(tmpattr);
|
}
|
|
//初始化[仅执行1次]
|
create() {
|
|
this.gaodeRoute = new mars3d.query.GaodeRoute({
|
// key: ['ae29a37307840c7ae4a785ac905927e0'],
|
});
|
this.gaodePOI = new mars3d.query.GaodePOI({
|
// key: ['ae29a37307840c7ae4a785ac905927e0'],
|
});
|
|
//图层管理使用的分组
|
this.groupLayer = new mars3d.layer.GroupLayer({
|
name: this.config.name,
|
pid: 50, //图层管理 中使用,父节点id
|
});
|
|
//创建矢量数据图层
|
this.pointLayer = new mars3d.layer.GraphicLayer({
|
name: this.config.name + "-起止点",
|
});
|
this.groupLayer.addLayer(this.pointLayer); //加入分组
|
|
this.routeLayer = new mars3d.layer.GraphicLayer({
|
name: this.config.name + "-路线",
|
});
|
this.groupLayer.addLayer(this.routeLayer); //加入分组
|
}
|
//每个窗口创建完成后调用
|
winCreateOK(opt, result) {
|
this.viewWindow = result;
|
this.appDateHourStart = mars3d.global_variables.queryDataTStart;
|
this.appDateHourEnd = mars3d.global_variables.queryDataTEnd;
|
this.nodejs_url_predix = mars3d.global_variables.nodejs_url_predix;
|
this.taxi_sn = this.config.params;
|
this.viewWindow.resetStartQueryTaxiDataText(this.taxi_sn);
|
|
}
|
//打开激活
|
activate() {
|
this.map.addLayer(this.groupLayer);
|
this.map.clock.shouldAnimate = false;
|
this.old_map_clock_startTime = this.map.clock.startTime;
|
this.old_map_clock_currentTime = this.map.clock.currentTime;
|
this.old_map_clock_stopTime = this.map.clock.stopTime;
|
this.old_map_clock_multiplier = this.map.clock.multiplier;
|
mars3d.global_variables.is_single_taxi_replaying = true;
|
|
}
|
//关闭释放
|
disable() {
|
this.map.clock.shouldAnimate = true;
|
this.map.clock.startTime = this.old_map_clock_startTime;
|
this.map.clock.currentTime = this.old_map_clock_currentTime;
|
this.map.clock.stopTime = this.old_map_clock_stopTime;
|
this.map.clock.multiplier = this.old_map_clock_multiplier;
|
mars3d.global_variables.is_single_taxi_replaying = false;
|
|
if (this.startGraphic) {
|
this.startGraphic.remove();
|
this.startGraphic = null;
|
}
|
if (this.endGraphic) {
|
this.endGraphic.remove();
|
this.endGraphic = null;
|
}
|
this.map.removeLayer(this.groupLayer);
|
|
}
|
|
//漫游自动结束 或点击 停止导航按钮 后,重置界面和操作
|
pauseReplay() {
|
// 暂停回放
|
this.map.clock.shouldAnimate = false;
|
}
|
|
//取消当前的视角跟随
|
removeTrack() {
|
if (this.nowFline) {
|
this.nowFline.setCameraOptions({ type: "" });
|
}
|
this.map.trackedEntity = undefined;
|
}
|
//==============开始导航===================
|
startDH() {
|
//导航前释放之前的所有导航操作
|
this.map.clock.shouldAnimate = true;
|
this.map.clock.startTime = Cesium.JulianDate.fromDate(new Date(this.appDateHourStart));
|
this.map.clock.currentTime = Cesium.JulianDate.fromDate(new Date(this.appDateHourStart));
|
this.map.clock.stopTime = Cesium.JulianDate.fromDate(new Date(this.appDateHourEnd));
|
this.map.clock.multiplier = 2.0;
|
|
}
|
//============开始视角跟随=============
|
startGS() {
|
this.nowFline.setCameraOptions({
|
type: "gs",
|
heading: 0,
|
radius: 2500,
|
});
|
}
|
|
}
|
|
//注册到widget管理器中。
|
mars3d.widget.bindClass(MyWidget);
|
|
//每个widet之间都是直接引入到index.html中,会存在彼此命名冲突,所以闭包处理下。
|
})(window, mars3d);
|