通过iServer发布的多个数据服务,怎么进行属性查询?
http://qa.supermap.com/44657这个里面是对一个数据服务进行查询,此方式是可以实现的,现在我有3个数据服务,我用循环遍历服务,但是查询不到内容。
var Cesium = window.Cesium;
var _this = thisMapCon;
var viewer = window.CesiumViewer;
//todo: yjw添加数据服务
var scene = viewer.scene;
var widget = viewer.cesiumWidget;
var supScene=URL_CONFIG.SupScene;
for (var i=0;i<supScene.length;i++) {
if (supScene[i].GWServerUrl!=undefined) {
//变量1
// var promise = tempp[URL_CONFIG.qxsyName];
var promise = tempp[supScene[i].key];
try {
Cesium.when(promise, function (layers) {
if (!scene.pickPositionSupported) {
alert('不支持深度拾取,属性查询功能无法使用!');
}
// var testLayer = viewer.scene.layers;
for (var i = 0; i < layers.length; i++) {
var strLayer = scene.layers.findByIndex(i).name;
var layer = scene.layers.find(strLayer);
// layer.selectEnabled=false;
var str_before = strLayer.split("@")[0];
//设置属性查询参数
layer.setQueryParameter({
//变量2和变量3
// url: URL_CONFIG.dataSerUrl,
// dataSourceName: URL_CONFIG.dataSourceName,
url: supScene[i].DataSerUrl,
dataSourceName: supScene[i].DataSourceName,
dataSetName: str_before,
keyWord: 'SmID'
});
}
}, function (e) {
if (widget._showRenderLoopErrors) {
var title = '渲染时发生错误,已停止渲染。';
widget.showErrorPanel(title, undefined, e);
}
});
} catch (e) {
if (widget._showRenderLoopErrors) {
var title = '渲染时发生错误,已停止渲染。';
widget.showErrorPanel(title, undefined, e);
}
}
}
}
// viewer.pickEvent.removeEventListener(query0);
// viewer.pickEvent.removeEventListener(query1);
// debugger;
if(type==0){
// viewer.pickEvent.addEventListener(query0,"query0");
viewer.pickEvent.addEventListener(query0);
}else if(type==1){
//TODO:区别1:设置监听事件
// viewer.pickEvent.addEventListener(query1,"query1");
viewer.pickEvent.addEventListener(query1);
}
function query0(feature){
var entity = viewer.selectedEntity;
var url = Cons.superMap_host + '/cjpl/getCjPlById?';
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
});
}
viewer.pickEvent.removeEventListener(query0);
}
function query1(feature) {
var url = Cons.superMap_host + '/pipeline/byPldeId?';
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[0]);
})
.catch(function (error) {
alert(error + url + "服务未启动!");
})
.then(function () {
// always executed
});
}
viewer.pickEvent.removeEventListener(query1);
}