webgl的三维场景中,同时设置了setInputAction事件和pickEvent事件,需求是在setInputAction事件中,当鼠标在场景中移动时弹出一些监测站点的属性信息;在pickEvent事件中,单击场景中的三维模型,弹出模型的信息。
但是现在setInputAction能在鼠标移动的过程中弹出监测站点的信息,此需求已经满足;但问题是在鼠标移动的过程中也同时会选中三维场景中的模型,如三维管点模型(雨水井、雨水篦等)。而我的需求是在鼠标移动的过程中不要选中管点模型,而是在pickEvent事件中去选中三维管点模型并弹出其属性信息。
1.以上需求需要怎么做呢?超图webgl中有没有setInputAction或者pickEvent的对应事件?
2.setInputAction事件和pickEvent事件在调用的时候先后顺序是什么呢?setInputAction事件和pickEvent事件二者有什么关系呢?
setInputAction的代码如下:
var Cesium=window.Cesium;
var _this=this;
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);
// handler.setInputAction(function(click) {
// var mousePosition = click.position;
//
// var pick = viewer.scene.pick(mousePosition,10,10);
// if(typeof (pick)!=="undefined"){
// console.log("ScreenSpaceEventType.LEFT_CLICK:",pick);
// }
// // if(typeof(callback)==="function"){
// // callback(sceneposition);
// // }
// }, Cesium.ScreenSpaceEventType.LEFT_CLICK);
handler.setInputAction(function(click) {
var mousePosition = click.endPosition;
var pick = viewer.scene.pick(mousePosition,5,5);
if(typeof (pick)!=="undefined"&&typeof (pick.id)!=="undefined"){
var layername=pick.id.name;
switch (layername) {
case "RGCY":
var sceneposition = viewer.scene.pickPosition(mousePosition);
if (!sceneposition) {
sceneposition = Cesium.Cartesian3.fromDegrees(0, 0, 0);
}
thisMapCon.setscenePosition(sceneposition);
_this._RGCYproshow(pick);
break;
default:
$("#bubble").hide();
break;
}
}else{
$("#bubble").hide();
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
pickEvent的代码如下:
function (feature) {
var entity = viewer.selectedEntity;
if (feature.PLPTNO !== undefined) {
axios.get(url + 'plptno=' + feature.PLPTNO + '&mntpcd=' + feature.MNTPCD)
.then(function (response) {
// handle success
// console.log(response);
let res = response.data.data;
showBubble(res, entity);
})
.catch(function (error) {
// handle error
// console.log(error);
alert(error +url+ "服务未启动!");
})
.then(function () {
// always executed
});
} else {
axios.get(url + 'plid=' + feature.PLID + '&mntpcd=' + feature.MNTPCD)
.then(function (response) {
// handle success
// console.log(response);
let res = response.data.data;
showBubble(res, entity);
})
.catch(function (error) {
// handle error
// console.log(error);
alert(error +url+ "服务未启动!");
})
.then(function () {
// always executed
});
}