//采样事件
|
|
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 += '<tbody>';
|
content += '<tr><td style="width:30%;">采样编号</td>';
|
content += '<td style="width:15%;">采样时间</td>';
|
content += '<td style="width:20%;">调查类型</td>';
|
content += '<td style="width:20%;">采样状态</td>';
|
content += '<td style="width:15%;">操作</td></tr>';
|
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 = '<font>初步调查</font>';
|
} else {
|
type = '<font color="red">详细调查</font>';
|
}
|
if (data[i].state == 0) {
|
state = '未采样';
|
} else if (data[i].state == 1) {
|
state = '<font color="red">已采样</font>';
|
} else {
|
state = '<font color="blue">已送检</font>';
|
}
|
|
content += '<tr><td>' + data[i].sample_no + '</td>'
|
+ '<td>' + oDate + '</td>'
|
+ '<td>' + type + '</td>'
|
+ '<td>' + state + '</td>'
|
+ '<td>'
|
+ '<a onclick="toSamplePointOnMap(\'' + data[i].longitude + '\',\'' + data[i].latitude + '\'' + ')"><font color="blue">查看</font></a>'
|
+ '</tr>';
|
}
|
content += '</tbody>';
|
if (data.length == 0) {
|
content += '<font color="red">未查询到数据呀</font>';
|
}
|
$("#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;
|
}
|