function addThemeRange() {
console.log("进入");
removeTheme();
queryBySQL();
var themeService = new SuperMap.REST.ThemeService(url, {eventListeners:{"processCompleted": themeCompleted, "processFailed": themeFailed}}),
style1 = new SuperMap.REST.ServerStyle({
fillForeColor: new SuperMap.REST.ServerColor(137,203,187),
lineColor: new SuperMap.REST.ServerColor(0,0,0),
lineWidth: 0.1
}),
style2 = new SuperMap.REST.ServerStyle({
fillForeColor: new SuperMap.REST.ServerColor(233,235,171),
lineColor: new SuperMap.REST.ServerColor(0,0,0),
lineWidth: 0.1
}),
style3 = new SuperMap.REST.ServerStyle({
fillForeColor: new SuperMap.REST.ServerColor(135,157,157),
lineColor: new SuperMap.REST.ServerColor(0,0,0),
lineWidth: 0.1
}),
themeRangeIteme1 = new SuperMap.REST.ThemeRangeItem({
start: 1,
end: 100000000,
style: style1
}),
themeRangeIteme2 = new SuperMap.REST.ThemeRangeItem({
start: 2,
end: 2,
style: style2
}),
themeRangeIteme3 = new SuperMap.REST.ThemeRangeItem({
start: 4,
end: 4,
style: style3
}),
themeRange = new SuperMap.REST.ThemeRange({
rangeExpression: "dbqk_id",//SmSdriW dbqk_id
rangeMode: SuperMap.REST.RangeMode.EQUALINTERVAL,
items: [themeRangeIteme1,themeRangeIteme2,themeRangeIteme3]
}),
joinItem = new SuperMap.REST.JoinItem({
foreignTableName:"zl_gxslx_pa_prov_1701",
joinFillter:"China_province_city_pg.AD_CODE=zl_gxslx_pa_prov_1701.prov_code",
joinType:"LEFTJOIN"
}),
themeParameters = new SuperMap.REST.ThemeParameters({
datasetNames: ["省面","zl_gxslx_pa_prov_1701"],//zl_gxslx_pa_prov_1701
dataSourceNames: ["User_Polygon","yunzhuli_test"],//yunzhuli_test
joinItems: [joinItem],
themes: [themeRange]
});
//console.log(themeParameters.datasetNames);
//console.log(themeParameters.dataSourceNames);
themeService.processAsync(themeParameters);
}
function addThemelayer() {
map.addLayer(themeLayer);
}
function removeTheme() {
if (map.layers.length > 1) {
map.removeLayer(themeLayer, true);
}
}
function themeCompleted(themeEventArgs) {
console.log(themeEventArgs);
if(themeEventArgs.result.resourceInfo.id) {
themeLayer = new SuperMap.Layer.TiledDynamicRESTLayer("中国各省面积_分段专题图", url, {cacheEnabled:false,transparent: true,layersID: themeEventArgs.result.resourceInfo.id}, {"maxResolution":"auto"});
themeLayer.events.on({"layerInitialized":addThemelayer});
}
}
function addThemelayer() {
map.addLayer(themeLayer);
}
function themeFailed(serviceFailedEventArgs) {
//doMapAlert("",serviceFailedEventArgs.error.errorMsg,true);
alert(serviceFailedEventArgs.error.errorMsg);
}
function queryBySQL() {
// 设置关联的外部数据库信息,alias表示数据库别名
var dc = new SuperMap.REST.DatasourceConnectionInfo({
dataBase: "yunzhuli_test",//数据库名
server: "10.31.18.190",//服务器名
user: "sa",//用户名
password: "Sql2008r2",//密码
driver: "SQL Server",//数据库驱动名称
connect: true,//是否自动连接
OpenLinkTable: false,
alias: "yunzhuli_test",//数据源别名
engineType: SuperMap.REST.EngineType.SQLPLUS,//数据源连接引擎类型ORACLEPLUS
readOnly: false,//是否以只读方式打开数据源
exclusive: false//是否以独立方式打开数据源
});
// 设置关联信息
var linkItem = new SuperMap.REST.LinkItem({
datasourceConnectionInfo: dc,//关联外部数据源信息
foreignKeys: ["AD_CODE"],//主空间数据集外键
foreignTable: "zl_gxslx_pa_prov_1701",//关联外部属性表的名称
linkFields: ["dbqk_id"],//外部属性表的需要保留字段名称
name: "link",//此关联信息对象的名称
primatryKeys: ["prov_code"],//需要关联外部属性表的主键
});
// 设置查询参数,在查询参数中添加linkItem关联条件3信息
var queryParam, queryBySQLParams, queryBySQLService;
queryParam = new SuperMap.REST.FilterParameter({
name: "zl_gxslx_pa_prov_1701@yunzhuli_test#1#1#1#1#1",//数据集名称@数据源别名
//zl_gxslx_pa_prov_1701@yunzhuli_test
//China_province_city_pg@User_Polygon
fields: ["AD_CODE","dbqk_id"],//查询字段数组
attributeFilter: "dbqk_id<5",//查询条件SmSdriW>10000000 dbqk_id<4
linkItems: [linkItem]
});
queryBySQLParams = new SuperMap.REST.QueryBySQLParameters({
queryParams: [queryParam]
});
queryBySQLService = new SuperMap.REST.QueryBySQLService(url, {
eventListeners: {
"processCompleted": processCompleted,
"processFailed": processFailed
}
});
queryBySQLService.processAsync(queryBySQLParams);
}
function processCompleted(queryEventArgs) {//todo
//console.log(queryEventArgs);
if(queryEventArgs){
var result = queryEventArgs.result.recordsets[0].features;
/*for (var i = 0; i < result.length; i++) {
console.log(result[i].data.dbqk_id);
}*/
console.log(result[3].data.dbqk_id);
//addThemeRange();
}
}
function processFailed(e) {//todo
console.log(e);
}
***********************************************************************************************
目前我的外表数据值能够请求到,若要根据外表的某个字段生成分段专题图,怎么设置?怎么将两者结合起来使用? (坐等!!!!)