添加动态渲染层分为三步
1.定义一个MapResource类型变量,用来往里面添加动态层
2. 定义一个GraphicLayer,并将存储有需要渲染的地图要素的数据表类型为DataTable的变量转化为GraphicLayer类型,并指定颜色样式
3.将转化后的GraphicLayer添加到步骤1中定义的数据源中,刷新地图。
1
/// <summary>
2
/// 本函数作用是用来给一个指定的GraphicLayer类型的数据源中添加一个动态渲染曾
3
/// </summary>
4
/// <param name="map1">地图控件</param>
5
/// <param name="mapResourceName">数据源名字</param>
6
/// <param name="dt">存储需要渲染的要素的数据表</param>
7
public void showGraphic(Map map1, string mapResourceName,DataTable dt)
8
{
9
System.Collections.IEnumerable enumFunc = map1.GetFunctionalities();
10
//添加一个地图数据源,动态层将添加到这个数据源中
11
MapResource mapResource = null;
12
13
//遍历地图控件的fuanctionality,找到需要的数据源,转化为MapResource类型
14
foreach (IGISFunctionality func in enumFunc)
15
{
16
if (func.Resource.Name == mapResourceName)
17
mapResource =(Graphics.MapResource) func.Resource;
18
//清楚原有数据,如果此处不清除原有数据,每次渲染将保留以前的数据
19
mapResource.Graphics.Tables.Clear();
20
}
21
if (mapResource == null)
22
return;
23
24
//将传进来的DataTable参数转化为GraphicLayer
25
ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsLayer graphicLayer = null;
26
graphicLayer = Converter.ToGraphicsLayer(dt, Color.Yellow, Color.Green);
27
//将转化后的GraphicLayer添加到地图数据源中
28
mapResource.Graphics.Tables.Add(graphicLayer);
29
30
//地图刷新
31
if (map1.ImageBlendingMode == ImageBlendingMode.Browser)
32
{ map1.Refresh(); }
33
else if(map1.ImageBlendingMode==ImageBlendingMode.WebTier)
34
{
35
map1.RefreshResource(mapResource.Name);
36
}
37
}
/// <summary>2
/// 本函数作用是用来给一个指定的GraphicLayer类型的数据源中添加一个动态渲染曾3
/// </summary>4
/// <param name="map1">地图控件</param>5
/// <param name="mapResourceName">数据源名字</param>6
/// <param name="dt">存储需要渲染的要素的数据表</param>7
public void showGraphic(Map map1, string mapResourceName,DataTable dt)8
{9
System.Collections.IEnumerable enumFunc = map1.GetFunctionalities();10
//添加一个地图数据源,动态层将添加到这个数据源中11
MapResource mapResource = null;12

13
//遍历地图控件的fuanctionality,找到需要的数据源,转化为MapResource类型14
foreach (IGISFunctionality func in enumFunc)15
{16
if (func.Resource.Name == mapResourceName)17
mapResource =(Graphics.MapResource) func.Resource;18
//清楚原有数据,如果此处不清除原有数据,每次渲染将保留以前的数据 19
mapResource.Graphics.Tables.Clear();20
}21
if (mapResource == null)22
return;23

24
//将传进来的DataTable参数转化为GraphicLayer25
ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicsLayer graphicLayer = null;26
graphicLayer = Converter.ToGraphicsLayer(dt, Color.Yellow, Color.Green);27
//将转化后的GraphicLayer添加到地图数据源中28
mapResource.Graphics.Tables.Add(graphicLayer);29

30
//地图刷新31
if (map1.ImageBlendingMode == ImageBlendingMode.Browser)32
{ map1.Refresh(); }33
else if(map1.ImageBlendingMode==ImageBlendingMode.WebTier)34
{35
map1.RefreshResource(mapResource.Name);36
}37
}


浙公网安备 33010602011771号