(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);
var Pointsdata = mars3d.global_variables.singleTaxiReplayData
for (var i = 0, len = Pointsdata.length; i < len; i++) {
var item = Pointsdata[i];
var lng = Number(item["lon"]); //经度
var lat = Number(item["lat"]); //纬度
var position = null;
if (lng && lat) {
position = Cesium.Cartesian3.fromDegrees(lng, lat);
}
item = changeNullAndundefinedToEmpty(item)
let graphic = new mars3d.graphic.PolylineEntity({
positions: points,
style: {
width: 10,
material: new mars3d.material.LineFlowMaterialProperty({
color:this.viewWindow.getLayerPointColorByQindexandValue(1004,this.qindex, item[this.qindex]),
image: "./img/textures/arrow2.png",
repeat: new Cesium.Cartesian2(30, 1),
speed: 30, //速度,建议取值范围1-100
})
},
});
this.routeLayer.addGraphic(graphic);
this.routeLayer.flyTo();
}}
addTaxiPointInfoGraphic() {
var Pointsdata = mars3d.global_variables.singleTaxiReplayData;
for (var i = 0, len = Pointsdata.length; i < len; i++) {
var item = Pointsdata[i];
// var lng = Number(item["lon"]); //经度
// var lat = Number(item["lat"]); //纬度
// var position = null;
// if (lng && lat) {
// position = Cesium.Cartesian3.fromDegrees(lng, lat);
// }
let keys = ["lon","lat"]
let array = []
Pointsdata.map(item => {
array.push(keys.reduce((result, key) => ({ ...result, [key]: item[key] }), {}))
})
let points = []
array.map(item => {
points.push(Object.values(item))
})
item = changeNullAndundefinedToEmpty(item)
//points[Pointsdata.length] = [lon,lat]
var CorridorPrimitive = new mars3d.graphic.CorridorPrimitive({
positions: points,
style: {
with: 50,
height: 0,
diffHeight: this.qindex == "co" ? 1000 * item[this.qindex] : item[this.qindex] || item[qindex] == "/" ? 3000 : item[qindex], //高度
color:this.viewWindow.getLayerPointColorByQindexandValue(1004,this.qindex, item[this.qindex]),
opacity: 0.5,
highlight: {
opacity: 1
}
},
item: item,
popup:"编号:" +
item["code"] +
"
时间:" +
item["datatime"] +
"
车速:" +
item["speed"] +
"
| PM₂.₅: | " + item["pm25"] + ' ' + " | μg/m³ |
| PM₁₀: | " + item["pm10"] + ' ' + " | μg/m³ |
| NO: | " + item["no"] + ' ' + " | μg/m³ |
| NO₂: | " + item["no2"] + ' ' + " | μg/m³ |
| NOₓ: | " + item["nox"] + ' ' + " | μg/m³ |
| CO: | " + item["co"] + ' ' + " | mg/m³ |