//采样事件
function sampleEventQuery() {
var sampleInput = $("#sampleInput").val();
var project = $("#sample_project_select").val();
var starttime = $("#sample_date_start").val();
var endtime = $("#sample_date_end").val();
var radiotype = $('input[name="sampleRadio"]:checked').val()
var type = '';
var url = '';
if (radiotype == 'sampleradio_project') {
type = 'project';
url = path + "/listSampleEventByProject?access_token=" + access_token + "&project_id=" + project +
"&type=" + type + "&sample_name=" + sampleInput;
} else if (radiotype == 'sampleradio_date') {
type = 'time';
url = path + "/listSampleEventByProject?access_token=" + access_token + "&start_time=" + starttime +
"&type=" + type + "&end_time=" + endtime + "&sample_name=" + sampleInput;
} else if (radiotype == 'sampleradio_scope') {
type = 'scope';
}
$.ajax({
type: "post",
async: false,
url: url,
contentType: "application/json;charset=utf-8",
success: function (data) {
if (data != null) {
showSampleTables(data);
}
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
console.log("ajax请求失败!")
}
});
}
//列表显示所有的项目信息
function showSampleTables(data) {
$("#sample_tales").html('');
var content = '';
content += '
';
content += '采样编号 | ';
content += '采样时间 | ';
content += '调查类型 | ';
content += '采样状态 | ';
content += '操作 |
';
for (var i = 0; i < data.length; i++) {
var type = '';
var state = data[i].state;
var oDate = timestampToTime(parseInt(data[i].create_time) * 1000);
if (data[i].type == 0) {
type = '初步调查';
} else {
type = '详细调查';
}
if (data[i].state == 0) {
state = '未采样';
} else if (data[i].state == 1) {
state = '已采样';
} else {
state = '已送检';
}
content += '' + data[i].sample_no + ' | '
+ '' + oDate + ' | '
+ '' + type + ' | '
+ '' + state + ' | '
+ ''
+ '查看'
+ ' |
';
}
content += '';
if (data.length == 0) {
content += '未查询到数据呀';
}
$("#sample_tales").html(content);
showSamplePointOnMap(data);
}
//一个一个点进行绘制
function drawSamplePointOnMap(data) {
var entity = viewer.entities.getById("draw_sample_" + data.id);
if (entity == undefined) {//如果不存在则添加
viewer.entities.add({
id: "draw_sample_" + data.id,
name: data.sample_name,
position: Cesium.Cartesian3.fromDegrees(data.longitude, data.latitude),
point: {
pixelSize: 12,
color: Cesium.Color.BLUE,
outlineColor: Cesium.Color.WHITE,
outlineWidth: 3,
outline: true,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
},
label: {
show: true,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
font: 'bold 14px Helvetica',
fillColor: Cesium.Color.WHITE,
text: data.sample_name,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
}
});
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(data.longitude, data.latitude, 3000),
});
}
}
//加载集合点
function drawSampleListPointOnMap(data) {
for (var i = 0; i < data.length; i++) {
var entity = viewer.entities.getById("draw_sample_" + data[i].id);
if (entity == undefined) {//如果不存在则添加
viewer.entities.add({
id: "draw_sample_" + data[i].id,
name: data[i].sample_name,
position: Cesium.Cartesian3.fromDegrees(data[i].longitude, data[i].latitude),
point: {
pixelSize: 12,
color: Cesium.Color.BLUE,
outlineColor: Cesium.Color.WHITE,
outlineWidth: 3,
outline: true,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
},
label: {
show: true,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
font: 'bold 14px Helvetica',
fillColor: Cesium.Color.WHITE,
text: data[i].sample_name,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
}
});
}
}
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(data[0].longitude, data[0].latitude, 3000),
});
}
//显示点
function showSamplePointOnMap(data) {
var color = $('input[name="sampleColorRadio"]:checked').val();
var cesu;
if (color == "red") {
cesu = Cesium.Color.RED;
} else if (color == "blue") {
cesu = Cesium.Color.BLUE;
} else if (color == "green") {
cesu = Cesium.Color.GREEN;
} else if (color == "dingzi") {
cesu = "dingzi";
}
for (var i = 0; i < data.length; i++) {
var entity = viewer.entities.getById("draw_sample_" + data[i].id);
if (entity == undefined) {//如果不存在则添加
if (cesu == "dingzi") {
viewer.entities.add({
id: "draw_sample_" + data[i].id,
name: data[i].sample_name,
position: Cesium.Cartesian3.fromDegrees(data[i].longitude, data[i].latitude),
label: {
show: true,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
font: 'bold 14px Helvetica',
fillColor: Cesium.Color.WHITE,
text: '',
disableDepthTestDistance: Number.POSITIVE_INFINITY,
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
},
billboard: {
image: '../images/icon/钉子blue.png',
width: 35,
height: 35,
rotation: 0,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
disableDepthTestDistance: Number.POSITIVE_INFINITY,//广告牌不进行深度检测
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
}
});
} else {
viewer.entities.add({
id: "draw_sample_" + data[i].id,
name: data[i].sample_name,
position: Cesium.Cartesian3.fromDegrees(data[i].longitude, data[i].latitude),
point: {
pixelSize: 12,
color: cesu,
outlineColor: Cesium.Color.WHITE,
outlineWidth: 3,
outline: true,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
},
label: {
show: true,
verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
horizontalOrigin: Cesium.HorizontalOrigin.CENTER,
font: 'bold 14px Helvetica',
fillColor: Cesium.Color.WHITE,
text: data[i].sample_name,
disableDepthTestDistance: Number.POSITIVE_INFINITY,
heightReference: Cesium.HeightReference.RELATIVE_TO_GROUND
}
});
}
}
}
}
//清除
function sampleClear() {
$("#sample_tales").html('');
clearPointOnMap();
}
//清除
function clearPointOnMap() {
var entitys = viewer.entities._entities._array;
for (var i = 0; i < entitys.length; i++) {
if (entitys[i]._id.indexOf("draw_sample_") != -1) {
viewer.entities.remove(entitys[i]);
i--;
}
}
}
//跳转到查询的点
function toSamplePointOnMap(lng, lat) {
viewer.camera.flyTo({
destination: Cesium.Cartesian3.fromDegrees(lng, lat, 3000),
});
}
//时间转化
function timestampToTime(timestamp) {
var date = new Date(timestamp)
var Y = date.getFullYear() + '-'
var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-'
var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' '
return Y + M + D;
}