【已测试通过】::ArcGISServer简单查询并高亮显示
2007-12-21 08:51
507 查看
简单查询并高亮显示代码(vb.net)::测试通过
.MapResourceManager属性中增加一个名为Selection的MapResource,并将它移动到编号为0的位置,即显示在所有MapResource最上面。
如图添加相关控件:
以下是vb.net代码:(参考Flyingis C#代码http://flyingis.cnblogs.com/)
在Button1_Click添加如下代码
Dim resource_index As Integer = 1
Dim targetlayername As String = "Country"
Dim datatable As System.Data.DataTable = Nothing
'直接获取MapResourceName为world的MapFunctionality,它的编号为1
Dim mf As ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality = Map1.GetFunctionality(resource_index)
'先得到functionality,再获取resource
Dim gisresource As ESRI.ArcGIS.ADF.Web.DataSources.IGISResource = mf.Resource
Dim supported As Boolean = gisresource.SupportsFunctionality(GetType(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality))
If supported = True Then
Dim qfunc As ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality
qfunc = gisresource.CreateFunctionality(GetType(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), Nothing)
Dim layerIds() As String = Nothing
Dim layerNames() As String = Nothing
qfunc.GetQueryableLayers(Nothing, layerIds, layerNames)
Dim spatialfilter As New ESRI.ArcGIS.ADF.Web.SpatialFilter()
spatialfilter.ReturnADFGeometries = False
spatialfilter.MaxRecords = 1000
spatialfilter.WhereClause = TextBox2.Text
datatable = qfunc.Query(Nothing, layerIds(3), spatialfilter)
End If
If Not datatable Is Nothing Then
Dim ds As New System.Data.DataSet()
ds.Tables.Add(datatable)
TreeViewPlus1.ShowClearAllButton = False
'//将结果绑定到TreeViewPlus控件上
TreeViewPlus1.BindToDataSet(ds)
TreeViewPlus1.Nodes(0).Expanded = True
End If
'查询结果高亮显示
'重新获得Map1控件所有的functionality
Dim getfunc As IEnumerable = Map1.GetFunctionalities()
Dim gResource As ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource = Nothing
Dim gFunc As IGISFunctionality = Nothing
For Each gFunc In getfunc
'找到名为"Selection"的MapResource
If gFunc.Resource.Name = "selection" Then
'down cast到ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource
gResource = gFunc.Resource
End If
Next
If gResource Is Nothing Then
Return
End If
Dim gLayer As ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer = Nothing
Dim dTable As System.Data.DataTable = Nothing
For Each dTable In gResource.Graphics.Tables
If TypeOf dTable Is ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer Then
gLayer = dTable
End If
Next
If gLayer Is Nothing Then
gLayer = New ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer()
gResource.Graphics.Tables.Add(gLayer)
End If
'清除已有数据
gLayer.Clear()
Dim drs As Data.DataRowCollection = datatable.Rows
Dim shpind As Integer = -1
Dim i As Integer = 0
For i = 0 To (datatable.Columns.Count - 1)
If datatable.Columns(i).DataType Is GetType(ESRI.ArcGIS.ADF.Web.Geometry.Geometry) Then
shpind = i
End If
Next
'Throw an exception
Dim ex0 As New Exception("No geometry available in datatable")
Try
Dim dr As Data.DataRow
For Each dr In drs
Dim geom As ESRI.ArcGIS.ADF.Web.Geometry.Geometry = dr(shpind)
'创建一个GraphicElement
Dim ge As New ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(geom, System.Drawing.Color.Yellow)
ge.Symbol.Transparency = 50.0
'将GraphicElement添加到ElementGraphicsLayer中
gLayer.Add(ge)
Next
Catch ex As Exception
Throw ex
End Try
If (Map1.ImageBlendingMode = ImageBlendingMode.WebTier) Then
Map1.Refresh()
ElseIf (Map1.ImageBlendingMode = ImageBlendingMode.Browser) Then
'只刷新Graphics Resource
Map1.RefreshResource(gResource.Name)
End If
效果图
.MapResourceManager属性中增加一个名为Selection的MapResource,并将它移动到编号为0的位置,即显示在所有MapResource最上面。
如图添加相关控件:
以下是vb.net代码:(参考Flyingis C#代码http://flyingis.cnblogs.com/)
在Button1_Click添加如下代码
Dim resource_index As Integer = 1
Dim targetlayername As String = "Country"
Dim datatable As System.Data.DataTable = Nothing
'直接获取MapResourceName为world的MapFunctionality,它的编号为1
Dim mf As ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality = Map1.GetFunctionality(resource_index)
'先得到functionality,再获取resource
Dim gisresource As ESRI.ArcGIS.ADF.Web.DataSources.IGISResource = mf.Resource
Dim supported As Boolean = gisresource.SupportsFunctionality(GetType(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality))
If supported = True Then
Dim qfunc As ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality
qfunc = gisresource.CreateFunctionality(GetType(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), Nothing)
Dim layerIds() As String = Nothing
Dim layerNames() As String = Nothing
qfunc.GetQueryableLayers(Nothing, layerIds, layerNames)
Dim spatialfilter As New ESRI.ArcGIS.ADF.Web.SpatialFilter()
spatialfilter.ReturnADFGeometries = False
spatialfilter.MaxRecords = 1000
spatialfilter.WhereClause = TextBox2.Text
datatable = qfunc.Query(Nothing, layerIds(3), spatialfilter)
End If
If Not datatable Is Nothing Then
Dim ds As New System.Data.DataSet()
ds.Tables.Add(datatable)
TreeViewPlus1.ShowClearAllButton = False
'//将结果绑定到TreeViewPlus控件上
TreeViewPlus1.BindToDataSet(ds)
TreeViewPlus1.Nodes(0).Expanded = True
End If
'查询结果高亮显示
'重新获得Map1控件所有的functionality
Dim getfunc As IEnumerable = Map1.GetFunctionalities()
Dim gResource As ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource = Nothing
Dim gFunc As IGISFunctionality = Nothing
For Each gFunc In getfunc
'找到名为"Selection"的MapResource
If gFunc.Resource.Name = "selection" Then
'down cast到ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource
gResource = gFunc.Resource
End If
Next
If gResource Is Nothing Then
Return
End If
Dim gLayer As ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer = Nothing
Dim dTable As System.Data.DataTable = Nothing
For Each dTable In gResource.Graphics.Tables
If TypeOf dTable Is ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer Then
gLayer = dTable
End If
Next
If gLayer Is Nothing Then
gLayer = New ESRI.ArcGIS.ADF.Web.Display.Graphics.ElementGraphicsLayer()
gResource.Graphics.Tables.Add(gLayer)
End If
'清除已有数据
gLayer.Clear()
Dim drs As Data.DataRowCollection = datatable.Rows
Dim shpind As Integer = -1
Dim i As Integer = 0
For i = 0 To (datatable.Columns.Count - 1)
If datatable.Columns(i).DataType Is GetType(ESRI.ArcGIS.ADF.Web.Geometry.Geometry) Then
shpind = i
End If
Next
'Throw an exception
Dim ex0 As New Exception("No geometry available in datatable")
Try
Dim dr As Data.DataRow
For Each dr In drs
Dim geom As ESRI.ArcGIS.ADF.Web.Geometry.Geometry = dr(shpind)
'创建一个GraphicElement
Dim ge As New ESRI.ArcGIS.ADF.Web.Display.Graphics.GraphicElement(geom, System.Drawing.Color.Yellow)
ge.Symbol.Transparency = 50.0
'将GraphicElement添加到ElementGraphicsLayer中
gLayer.Add(ge)
Next
Catch ex As Exception
Throw ex
End Try
If (Map1.ImageBlendingMode = ImageBlendingMode.WebTier) Then
Map1.Refresh()
ElseIf (Map1.ImageBlendingMode = ImageBlendingMode.Browser) Then
'只刷新Graphics Resource
Map1.RefreshResource(gResource.Name)
End If
效果图
相关文章推荐
- 【已测试通过】::自定义工具按钮进行矩选查询,高亮显示所选择的地图要素
- 测试人员必会MySQL的简单查询语句
- SolrJ 复杂查询 高亮显示
- 查询居中与高亮显示
- 超简单的搜索结果关键字高亮显示(Replace)
- druid sql监控 简单配置(绝对管用,测试通过)
- MySQL数据库通过JDBC操作,简单查询
- 通过 sysprocesses 简单查询死锁及解决死锁办法
- MySQL 查询结果以百分比显示简单实现
- 【Lucene】三个高亮显示模块的简单示例-Highlighter
- hibernate指定值查询与显示的简单改进
- 解决Chrome浏览器打开新标签页,显示“无法访问此网站 连接已重置”的问题【在54.0 beta版上测试通过】
- 01_Linux系统系统语言查询,设置Xshell工具,中文显示,测试Xshell中文字符显示,Linux中文显示乱码设置
- 在html页面用ajax的简单应用通过javascript得到数据库中的图片路径并在表格中显示出来
- 4.hql简单属性查询:测试
- vi采用高亮显示的简单方法
- 通过查询数据库中的数据匹配在页面上:(set单条数据属性是在页面上的显示与foreach的不同) 通过ID修改提取位置表信息
- solr复杂查询;及代码示例;包括查询、过滤、分页、排序、高亮显示等处理 的代码示例;
- Solr查询高亮显示实现方式
- Django 一个简单的图书管理程序(五 通过查询添加借阅人)