在缓冲区分析上,SuperMap.IS.AjaxScript提供的主要功能函数有spatialAnalystManager.BufferQuery(bufferParam,qeruyParam,onComplete,onError),以及最近地物查询的函数QueryManager.FindNearest(point,tolerance,queryparam,onComplete,onError)这两个。(后者只会显示一条记录,曾因这个方法而以为是程序出了问题而调试了半天……^_^)。bufferParam对象的相关属性可以查询该类的帮助,包括高亮显示,是否查询所有图层,查询字段等,写的时候感觉比写AGS的ADF要舒服很多。先贴是缓冲区的代码。^_^
Code
1
///<summary>缓冲区半径、最近物查询</summary>
2![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
HJMapUtils.AnalysisUtils = Class(object,
{
4![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
5![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
Create: function(mapControl, divResult)
{
6![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7
///<summary>构造函数</summary>
8![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
///<param name="mapControl">操作的mapcontrol对象</param>
10![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
11
///<param name="divResult">查询结果显示的div块</param>
12![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
13
this.MapControl1 = mapControl;
14![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15
object.divResult = divResult;
16![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
},
18![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
FindNearestByMapCoord_Buffer: function(x, y, distance, hasGeometry, returnFields, whereClause, queryLayers, highLight, penColor, brushColor, backTransparent)
{
20![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
///<summary>根据坐标值来进行缓冲区分析</summary>
22![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
///<param name="x">坐标x值</param>
24![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
25
///<param name="y">坐标x值</param>
26![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
27
///<param name="distance">缓冲区查询范围</param>
28![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
29
///<param name="hasGeometry">是否查询空间数据</param>
30![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
31
///<param name="returnFields">返回字段(多字段用','隔开)</param>
32![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
33
///<param name="whereClause">图层限制条件(多字段用','隔开)</param>
34![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
35
///<param name="queryLayers">查询图层(多字段用','隔开)</param>
36![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
37
///<param name="highLight">是否高亮显示</param>
38![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
39
///<param name="penColor">线颜色</param>
40![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
41
///<param name="brushColor">填充颜色</param>
42![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
43
///<param name="backTransparent">背景色是否透明</param>
44![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
45
46![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
47
var spatialAnalystManager = this.MapControl1.GetSpatialAnalystManager();
48![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
49
var bufferParam = new SuperMap.IS.BufferParam();//设置缓冲区查询参数
50![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
51
bufferParam.distance = parseFloat(distance);
52![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
53
bufferParam.fromCustomGeo = true;
54![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
55
bufferParam.geometries = new Array();
56![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
57
bufferParam.queryMode = 9;//缓冲区查询模式(很多的,具体参照帮助)
58![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
59
var geo = new SuperMap.IS.Geometry();//这里是指定单点查询,自定义类别
60![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
61
geo.feature = 1;
62![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
63
geo.points = new Array();
64![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
65
var point = new SuperMap.IS.MapCoord(parseFloat(x), parseFloat(y));
66![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
67
geo.points[0] = point;
68![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
69
bufferParam.geometries[0] = geo;
70![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
71
72![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
73
var queryParam = new SuperMap.IS.QueryParam();//查询参数(高亮等)
74![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
75
queryParam.hasGeometry = hasGeometry;
76![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
77
queryParam.expectCount = 10000;
78![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
79
queryParam.highlight = new SuperMap.IS.Highlight();
80![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
81
queryParam.highlight.highlightResult = highLight;
82![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
83
queryParam.highlight.queryAreaStyle = new SuperMap.IS.Style();
84![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
85
queryParam.highlight.queryAreaStyle.penColor = parseInt(penColor);
86![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
87
queryParam.highlight.queryAreaStyle.brushBackTransparent = backTransparent;
88![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
89
90![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
91
var returnFields = returnFields.split(';');//查询字段
92![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
93
var wc = null;
94![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
95![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
if (whereClause != null && whereClause)
{
96![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
97
wc = whereClause.split(",");
98![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
99
}
100![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
101
var queryLayers = queryLayers.split(',');
102![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
103
queryParam.queryLayers = new Array();
104![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
105![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
for (var i = 0; i < queryLayers.length; i++)
{
106![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
107
queryParam.queryLayers[i] = new SuperMap.IS.QueryLayer();
108![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
109
queryParam.queryLayers[i].layerName = queryLayers[i];
110![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
111
var returnFields2 = returnFields[i];
112![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
113
queryParam.queryLayers[i].returnFields = returnFields2.split(",");
114![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
115![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
if (wc && wc != null)
{
116![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
117
queryParam.queryLayers[i].whereClause = wc[i];
118![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
119
}
120![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
121
}
122![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
123
this.MapControl1.ClearHighlight();
124![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
125
spatialAnalystManager.BufferQuery(bufferParam, queryParam, this.onQueryComplete, this.onError);//调用bufferquery方法进行查询,在onQueryComplete这个函数中进行对结果数据集的处理。
126![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
127
}
128![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
129
130![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
131
}
132![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
133
专题制作上SuperMap.IS.Ajax提供了不同专题的解决方案,很多类别,可以参照那些以theme结尾的一些类。不过在写的过程中发现一些问题,颜色不知道咋处理,貌似都是ole颜色….有知道的能否指教下.下面是分段专题相关编写。贴代码,^_^。
Code
1![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
2![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
3
///<summary>分段专题</summary>
4![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
5![ExpandedBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
HJMapUtils.ThemeUtils = Class(object,
{
6![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
7![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
Create: function(mapControl, divResult)
{
8![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
9
this.MapControl1 = mapControl;
10![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
11
object.divResult = divResult;
12![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
13
},
14![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
15![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
ThemeRangeMap: function(layerName, expressionName, rangeList, caption)
{
16![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
17
///<summary>分段专题图</summary>
18![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
19
///<param name="layerName">专题图所在图层</param>
20![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
21
///<param name="expressionName">所在字段</param>
22![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
23
///<param name="rangeList">范围及颜色,格式为(范围(多个用','隔开);颜色(对应范围多一个颜色,同样多个用','隔开))</param>
24![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
25
///<param name="caption">专题标题</param>
26![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
27![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
if (!this.MapControl1.layers || !this.MapControl1.layers.length)
{ alert("不存在图层!"); return; }
28![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
29
var rangeLayer = new SuperMap.IS.Layer();//专题图层
30![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
31![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
for (var j = 0; j < this.MapControl1.layers.length; j++)
{
32![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
33
var layertext = this.MapControl1.layers[j].name;
34![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
35![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
if (layerName.toLowerCase() == layertext.toLowerCase())
{
36![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
37
rangeLayer = this.MapControl1.layers[j];
38![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
39
break;
40![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
41
}
42![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
43
};
44![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
45
if (rangeLayer == null)
46![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
47![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
{ alert("没有对应图层!"); return; };
48![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
49
this.ClearTheme(rangeLayer);
50![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
51
var theme = new SuperMap.IS.RangeTheme();//分段专题类相关设置
52![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
53
theme.caption = caption;
54![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
55
theme.enabled = true;
56![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
57
theme.expression = expressionName;
58![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
59
theme.breakValues = new Array();
60![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
61
var breaks = rangeList.split(';')[0].split(',');//分段点断点的设置
62![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
63
var breaksarr = new Array();
64![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
65![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
for (var k = 0; k < breaks.length; k++)
{
66![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
67
theme.breakValues[k] = parseFloat(breaks[k]);
68![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
69![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
if (k == 0)
{
70![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
71
breaksarr.push("0~" + breaks[k]);
72![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
73![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
} else
{
74![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
75
breaksarr.push(breaks[k - 1] + "~" + breaks[k]);
76![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
77
}
78![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
79
};
80![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
81
breaksarr.push(breaks[breaks.length - 1] + "~![](https://www.cnblogs.com/Images/dot.gif)
");
82![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
83
theme.displays = new Array();
84![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
85
var colors = rangeList.split(';')[1].split(',');//各分段的颜色设置(貌似只支持ole颜色)
86![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
87
var colorsarr = new Array();
88![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
89![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
for (var i = 0; i < colors.length; i++)
{
90![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
91
theme.displays[i] = new SuperMap.IS.Style();
92![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
93
theme.displays[i].brushColor = parseInt(colors[i]);
94![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
95
colorsarr.push(colors[i]);
96![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
97
}
98![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
99
var strHtml = "";
100![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
101![ExpandedSubBlockStart.gif](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
for (var l = 0; l < colorsarr.length; l++)
{
102![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
103
strHtml += "<span style='display:block;width:20px;height:20px;background-color:" + colorsarr[l] + "'></span><div>" + breaksarr[l] + "</div><br/>";//返回一个html块标示(不过颜色很郁闷)
104![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
105
}
106![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
107
rangeLayer.themeRange = theme;
108![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
109
this.MapControl1.Update();
110![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
111
return strHtml;
112![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
113
}
114![](https://www.cnblogs.com/Images/OutliningIndicators/InBlock.gif)
115
}