'use script' //开发环境建议开启严格模式
|
;
|
(function (window, mars3d) {
|
//创建widget类,需要继承BaseWidget
|
class MyWidget extends mars3d.widget.BaseWidget {
|
// get resources(){
|
// return [
|
// 'viewl.js'
|
// ]
|
// }
|
|
get view() {
|
return {
|
type: 'window',
|
url: 'view.html',
|
windowOptions: {
|
width: 400,
|
height:350,
|
position: {
|
top: 180,
|
right: 5,
|
bottom: 110
|
},
|
},
|
}
|
}
|
|
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();
|
}
|
//初始化[仅执行1次]
|
create() {
|
//图层管理使用的分组
|
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); //加入分组
|
}
|
|
openTest(word){
|
console.log(word,"eee")
|
}
|
locateAndHighlight(lon, lat) {
|
this.map.flyToPoint(Cesium.Cartesian3.fromDegrees(lon, lat, 0.2));
|
}
|
|
|
addTaxiReplayGraphic(points) {
|
console.log("拿到了数据",points)
|
this.startGraphic = new mars3d.graphic.BillboardEntity({
|
position: points[0],
|
style: {
|
image: this.path + "img/start.png",
|
scale:1.2,
|
opacity:1,
|
scaleByDistance_far:500,
|
distanceDisplayCondition_far:500,
|
scaleByDistance_farValue:0.5,
|
scaleByDistance:true,
|
visibleDepth:true,
|
hasPixelOffset:false,
|
distanceDisplayCondition: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.2,
|
opacity:1,
|
scaleByDistance_far:500,
|
distanceDisplayCondition_far:500,
|
scaleByDistance_farValue:0.5,
|
scaleByDistance:true,
|
visibleDepth:true,
|
hasPixelOffset:false,
|
distanceDisplayCondition:true,
|
},
|
});
|
this.pointLayer.addGraphic(this.endGraphic);
|
let graphic = new mars3d.graphic.PolylineEntity({
|
positions: points,
|
style: {
|
width: 3,
|
material: new mars3d.material.LineFlowMaterialProperty({
|
color: Cesium.Color.AQUA,
|
image: "./img/arrow2.png",
|
repeat: new Cesium.Cartesian2(50, 1),
|
speed: 40, //速度,建议取值范围1-100
|
})
|
},
|
});
|
this.routeLayer.addGraphic(graphic);
|
this.routeLayer.flyTo();
|
}
|
setSingleTaxiReplayData(datas) {
|
let data = datas;
|
}
|
//每个窗口创建完成后调用
|
winCreateOK(opt, result) {
|
this.viewWindow = result;
|
console.log(result,"创建完成")
|
this.taxi_sn = this.config.params.id;
|
this.name = this.config.params.name;
|
this.floor = this.config.params.floor;
|
console.log(this.config)
|
this.viewWindow.resetStartQueryTaxiDataText(this.taxi_sn);
|
}
|
|
//打开激活
|
activate() {
|
console.log("激活完成s")
|
this.map.addLayer(this.groupLayer);
|
console.log("添加完成")
|
}
|
//关闭释放
|
disable() {
|
console.log("释放完毕")
|
if (this.startGraphic) {
|
this.startGraphic.remove();
|
this.startGraphic = null;
|
}
|
if (this.endGraphic) {
|
this.endGraphic.remove();
|
this.endGraphic = null;
|
}
|
this.map.removeLayer(this.groupLayer);
|
}
|
|
}
|
|
//注册到widget管理器中。
|
mars3d.widget.bindClass(MyWidget)
|
|
//每个widet之间都是直接引入到index.html中,会存在彼此命名冲突,所以闭包处理下。
|
})(window, mars3d)
|