'use script' //开发环境建议开启严格模式
;
function addItemToLayer(item, target_layer) {
$.getJSON("http://58.246.27.194:7012/dataapi/Bdata?bid=get_1004_single_path&siteid=" + item["code"], {
datatime1: "2021-07-01 10:00:00",
datatime2: "2021-07-01 10:15:00"
}, (result) => {
if (result.data.result.length > 0) {
var tmpPositionProperty = new Cesium.SampledPositionProperty();
for (var i = 0, len = result.data.result.length; i < len; i++) {
let item = result.data.result[i];
//console.log(item);
tmpPositionProperty.addSample(Cesium.JulianDate.fromDate(new Date(item["datatime"])), Cesium.Cartesian3.fromDegrees(item["lon"], item["lat"], 0.2))
}
let graphic = new mars3d.graphic.ModelEntity({
attr: result.data.result[0],
style: {
url: "gltf/" + (item["code"]).substring(0, 2) + ".gltf",
scale: 100,
minimumPixelSize: 20,
highlight: {
type: mars3d.EventType.click,
silhouette: true,
silhouetteColor: "#ff0000",
silhouetteSize: 4,
},
label: {
//不需要文字时,去掉label配置即可
text: item["code"],
font_size: 16,
// TODO need to be changed according to qindex color.
color: "#ff00ff",
outline: true,
outlineColor: "#000000",
pixelOffsetY: -20,
distanceDisplayCondition: true,
distanceDisplayCondition_far: 50000,
distanceDisplayCondition_near: 0,
},
},
});
graphic.position = tmpPositionProperty;
target_layer.addGraphic(graphic);
}
});
}
(function (window, mars3d) {
//创建widget类,需要继承BaseWidget
class MyWidget extends mars3d.widget.BaseWidget {
//初始化[仅执行1次]
create() {
map.clock.shouldAnimate = true;
map.clock.startTime = Cesium.JulianDate.fromDate(new Date("2021-07-01 10:00:00"));
map.clock.currentTime = Cesium.JulianDate.fromDate(new Date("2021-07-01 10:00:00"));
map.clock.stopTime = Cesium.JulianDate.fromDate(new Date("2021-07-01 10:15:00"));
map.clock.multiplier = 5.0;
map.clock.clockRange = Cesium.ClockRange.LOOP_STOP;
let taxi_layer = new mars3d.layer.GraphicLayer({
name: '移动监测点',
pid: 99, //图层管理 中使用,父节点id
center: {"lat":30.62156,"lng":121.44918,"alt":48716,"heading":359,"pitch":-40},
show: true,
onWidget: "widgetsTS/taxi_layer_setting/widget.js",
});
map.addLayer(taxi_layer);
taxi_layer.on(mars3d.EventType.click, function (event) {
console.log("监听layer,单击了矢量对象", event);
//console.log(event.graphic?.attr)
var item = event.graphic?.attr;
//haoutil.msg('单击了:' + item['高校名称'])
});
taxi_layer.bindPopup(function (event) {
let item = event.graphic?.attr;
var html =
"
类型: " +
item["code"].substring(0, 2) == "BS" ? "公交车" : "出租车" +
"
车辆编号: " +
item["code"] +
"
数据时间: " +
item["datatime"] +
"
瞬时车速: " +
item["speed"] + " (km/h)" +
"
粉尘PM2.5: " +
item["pm25"] + " (ug/m3)" +
"
粉尘PM10: " +
item["pm10"] + " (ug/m3)" +
"
NO浓度: " +
item["no"] + " (ug/m3)" +
"
NO2浓度: " +
item["no2"] + " (ug/m3)" +
"
NO+NO2浓度: " +
item["nox"] + " (ug/m3)" +
"
CO浓度值: " +
item["co"] +" (mg/m3)"+
"