(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 Pointsdata = mars3d.global_variables.singleTaxiReplayData
for (var i = 0, len = Pointsdata.length; i < len-1; i++) {
var item = Pointsdata[i];
var item2 = Pointsdata[i+1];
var lng = Number(item["lon"]); //经度
var lat = Number(item["lat"]); //纬度
var lng2 = Number(item2["lon"]); //经度
var lat2 = Number(item2["lat"]); //纬度
var position = null;
var position2 = null;
if (lng && lat&&lng2&&lat2) {
position = Cesium.Cartesian3.fromDegrees(lng, lat);
position2 = Cesium.Cartesian3.fromDegrees(lng2, lat2);
}
item = changeNullAndundefinedToEmpty(item)
let graphic = new mars3d.graphic.PolylineEntity({
positions: [position,position2],
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(1, 1),
speed: 40, //速度,建议取值范围1-100
})
},
});
this.routeLayer.addGraphic(graphic);
}
// console.log(items,"items")
// 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();
}
addTaxiPointInfoGraphic() {
<<<<<<< HEAD
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,
=======
var Pointsdata = mars3d.global_variables.singleTaxiReplayData
for (var i = 0, len = Pointsdata.length; i < len-1; i++) {
var item = Pointsdata[i];
var item2 = Pointsdata[i+1];
var lng = Number(item["lon"]); //经度
var lat = Number(item["lat"]); //纬度
var lng2 = Number(item2["lon"]); //经度
var lat2 = Number(item2["lat"]); //纬度
var position = null;
var position2 = null;
if (lng && lat&&lng2&&lat2) {
position = Cesium.Cartesian3.fromDegrees(lng, lat);
position2 = Cesium.Cartesian3.fromDegrees(lng2, lat2);
}
item = changeNullAndundefinedToEmpty(item)
var CircleEntity = new mars3d.graphic.CorridorEntity({
positions: [position,position2],
>>>>>>> 6c1b125337b8a53e57151f36661ded58daf4d534
style: {
// length: 60.0,
width: 10.0,
height: 0,
cornerType: Cesium.CornerType.BEVELED,
// radius: 8.0,
diffHeight: this.qindex == "co" ? 300 * item[this.qindex] : item[this.qindex] || item[this.qindex] == "/" ? 500 : item[this.qindex], //高度
color:this.viewWindow.getLayerPointColorByQindexandValue(1004,this.qindex, item[this.qindex]),
opacity: 0.6,
// rotationDegree: 45,
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³ |