1.需要获取场景中的管线属性信息,去查属性表,在一个函数中用了viewer.pickEvent.addEventListener调用属性查询接口
//设置监听事件
var url = URL_CONFIG.queryApiUrl + '/cjpl/getCjPlById?';
viewer.pickEvent.addEventListener(
function (feature) {
var entity = viewer.selectedEntity;
if (feature.PLPTNO !== undefined) {
axios.get(url + 'plptno=' + feature.PLPTNO + '&mntpcd=' + feature.MNTPCD)
.then(function (response) {
let res = response.data.data;
_this.rightDrawerOpen(res);
})
.catch(function (error) {
alert(error + url + "服务未启动!");
})
.then(function () {
// always executed
});
} else {
axios.get(url + 'plid=' + feature.PLID + '&mntpcd=' + feature.MNTPCD)
.then(function (response) {
let res = response.data.data;
_this.rightDrawerOpen(res);
})
.catch(function (error) {
alert(error + url + "服务未启动!");
})
.then(function () {
// always executed
});
}
// _this.viewer.scene.layers.getSelectedLayer().refresh();
});
2.需要获取场景中的管线缺陷信息,需要去查缺陷表,在一个函数中用了viewer.pickEvent.addEventListener调用属性查询接口
var url = URL_CONFIG.queryApiUrl + '/pipeline/byPldeId?';
viewer.pickEvent.addEventListener(
function (feature) {
var entity = viewer.selectedEntity;
//TODO:区别2:只有管线,没有管点
if (feature.PLID !== undefined) {
//TODO:区别3:此接口可以查询单多条管线数据
axios.get(url + 'pldeid=' + feature.PLID)
.then(function (response) {
let res = response.data.data;
_this.defectRightDrawerOpen(res);
})
.catch(function (error) {
alert(error + url + "服务未启动!");
})
.then(function () {
// always executed
});
}
// _this.viewer.scene.layers.getSelectedLayer().refresh();
});
这两个需求一个是查属性表,一个是查缺陷表,接口不一样,但是都会用到点击模型事件,但是用viewer.pickEvent.addEventListener添加绑定事件后,二者会出现冲突,这个怎么解决???