使用地理数据库和sqlserver联合查询,但是结果却查不到
代码如下:
//选中vectorLayer弹出popup
function onFeatureSelect(feature) {
var x = feature.geometry.getBounds().getCenterLonLat().lon;
var y = feature.geometry.getBounds().getCenterLonLat().lat;
var contentHTML = "<div style='font-size:.8em; opacity: 0.8; width:150px; height:50px;'>" +
"<span style='font-weight: bold; font-size: 18px;'>详细信息</span><br>";
contentHTML += "<div>所属:" + feature.attributes.NAME + "</div>";
contentHTML += "<div>region表:" + feature.attributes['region.region_flower'] + "</div>";
contentHTML += "<div>region表:" + feature.attributes['region.region_name'] + "</div>";
contentHTML += "</div>"
popup = new SuperMap.Popup.FramedCloud("chicken",
new SuperMap.LonLat(x, y),
null,
contentHTML,
null,
true);
feature.popup = popup;
popup.panMapIfOutOfView = true;
map.addPopup(popup);
}
function onFeatureUnselect(feature) {
map.removePopup(feature.popup);
feature.popup.destroy();
feature.popup = null;
}
function queryBy() {
// 设置关联的外部数据库信息,alias表示数据库别名
var dc = new SuperMap.REST.DatasourceConnectionInfo({
dataBase: "flower",
server: ".",
driver: "SQL Server",
connect: true,
OpenLinkTable: false,
//alias: "RelQuery",
//engineType: SuperMap.REST.EngineType.SQLPLUS,
readOnly: false,
exclusive: false
});
// 设置关联信息
var linkItem = new SuperMap.REST.LinkItem({
datasourceConnectionInfo: dc,
foreignKeys: ["region_name"],
foreignTable: "region",
linkFields: ["region_flower", "region_name"],
name: "link",
primatryKeys: ["region_name"]
});
// 设置查询参数,在查询参数中添加linkItem关联条件信息
var queryParam, queryBySQLParams, queryBySQLService;
queryParam = new SuperMap.REST.FilterParameter({
name: "County_R_1@China400",
fields: ["region_flower", "region_name"],
attributeFilter: "SmID<100",
linkItems: [linkItem]
}),
queryBySQLParams = new SuperMap.REST.QueryBySQLParameters({
queryParams: [queryParam]
}),
queryBySQLService = new SuperMap.REST.QueryBySQLService(url, {
eventListeners: { "processCompleted": querybySqlCompleted,
"processFailed": querybySqlFailed
}
});
queryBySQLService.processAsync(queryBySQLParams);
}
function querybySqlCompleted(queryEventArgs) {
var i, j, feature,
result = queryEventArgs.result;
if (result && result.recordsets) {
for (i = 0; i < result.recordsets.length; i++) {
if (result.recordsets[i].features) {
for (j = 0; j < result.recordsets[i].features.length; j++) {
feature = result.recordsets[i].features[j];
feature.style = style;
vectorLayer.addFeatures(feature);
}
}
}
}
}
function querybySqlFailed(e) {
alert(e.error.errorMsg);
}