如果单个实体,可参考此文章
https://blog.csdn.net/zhangqun23/article/details/83056315
若多个实体匹配触发事件
$(document).ready(function () {
$.get('/api/emergency/notFinshed', function (data) {
var idArr = [];
var cid;
for (var i=0;i
var item = data[i];
cid = item.id;
idArr.push(cid);
var placeJson = item.palce;
var opjson = Number(placeJson.split(",")[0]);
var tpjson = Number(placeJson.split(",")[1]);
// if (emerId==id){
viewer.entities.add({
id:cid,
position:Cesium.Cartesian3.fromDegrees(opjson, tpjson),
billboard: {
name:'point',
image:'/img/map/emergency.png',
width:24,
height:24
},
name:'应急事件信息',
// description: '
事件描述: | ' + item.id + ' |
中心点坐标:'+item.palce+'', }); // // 应急点范围 // viewer.entities.add({ // position: Cesium.Cartesian3.fromDegrees(opjson, tpjson), // // name : 'Red ellipse on surface', // ellipse : { // semiMinorAxis :100.0, // semiMajorAxis : 100.0, // material : Cesium.Color.RED.withAlpha(0.5) // } // }); // } } var handler =new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas); handler.setInputAction(function (movement) { var pick = viewer.scene.pick(movement.position); // if (Cesium.defined(pick) && (pick.id.id === cid)) { if (Cesium.defined(pick) && ($.inArray(pick.id.id, idArr)>-1)) { window.open('/emergency-on-duty/onduty?'+"emerId="+pick.id.id); } }, Cesium.ScreenSpaceEventType.LEFT_CLICK); }) }); |