laptop and a wrench

漏洞

Cannot programmatically change the visibility of a ArcWebServices layer using IMapFunctionality.

上次发布: August 25, 2014 No Product Found
漏洞 ID 编号 NIM034021
已提交April 8, 2008
上次修改时间June 5, 2024
适用范围No Product Found
找到的版本9.2
编程语言VB.Net
状态Known Limit

附加信息

No Public Explanation

解决办法

I found that the SetLayerVisibility method works fine in a IMapServerCommandAction.ServerAction as long as a TOC.Refresh is NOT called in order to synchronize the TOC with the current visibility settings of the layer. When you do this, the layer visibility reverts back to the default setting in the Map service. Secondly, I found that the GetLayerVisibility method always returns true no matter what the current visibility setting of the layer is. At this time, the only work around that I could come up with is to make the ArcWebService service not visible in the TOC so you do not have to synchronize the Map with the TOC when the layer visibility changes, then maintain the visibility of the layers in the ArcWebService Map service in the Session (to work around the problem with GetLayerVisibility) and then use it to toggle the visibility of one or more layers.Implementation of the work around in <a href="http://VB.NET" target="_blank">VB.NET</a>: 'Store the visibility of the layers into the Session state by using a unique key created based on the layer name and layer id Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not (IsPostBack) Then Dim func As ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality = CType(Map1.GetFunctionality("MapResourceItem0"), ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality) Dim strLyrID As String() = Nothing Dim strLyrName As String() = Nothing func.GetLayers(strLyrID, strLyrName) Dim i As Integer For i = 0 To strLyrID.Length - 1 Dim strTemp As String = strLyrName(i).ToString().ToLower() + "_" + strLyrID(i) If (Session.Item(strTemp) Is Nothing) Then Session.Add(strTemp, func.GetLayerVisibility(strLyrID(i))) End If Next End If End Sub 'IMapServerCommandAction.ServerAction implementation Public Sub ServerAction(ByVal info As ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools.ToolbarItemInfo) Implements ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools.IServerAction.ServerAction Dim map1 As ESRI.ArcGIS.ADF.Web.UI.WebControls.Map = CType(info.BuddyControls(0), ESRI.ArcGIS.ADF.Web.UI.WebControls.Map) Dim func As ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality = CType(map1.GetFunctionality("MapResourceItem0"), ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality) Dim toc As ESRI.ArcGIS.ADF.Web.UI.WebControls.Toc = CType(map1.Page.FindControl("Toc1"), ESRI.ArcGIS.ADF.Web.UI.WebControls.Toc) Dim toolbar As ESRI.ArcGIS.ADF.Web.UI.WebControls.Toolbar = CType(info.Toolbar, ESRI.ArcGIS.ADF.Web.UI.WebControls.Toolbar) Dim page As System.Web.UI.Page = map1.Page Dim strLyrID As String() = Nothing Dim strLyrName As String() = Nothing func.GetLayers(strLyrID, strLyrName) Dim i As Integer = 0 For i = 0 To strLyrID.Length - 1 '"U.S. Cities" If (strLyrName(i).ToString().ToLower() = "u.s. cities") Then 'First check if the setting is present in the session Dim strTemp As String = strLyrName(i).ToString().ToLower() + "_" + strLyrID(i) If (page.Session.Item(strTemp) Is Nothing) Then page.Session.Add(strTemp, True) End If System.Diagnostics.Debug.WriteLine("Layer ID : " & strLyrID(i) & ", Visibility : " & func.GetLayerVisibility(strLyrID(i))) If (page.Session.Item(strTemp)) Then func.SetLayerVisibility(strLyrID(i), False) 'toc.Nodes.FindByValue("MapResourceItem0").Nodes(i).Checked = False page.Session.Item(strTemp) = False Else func.SetLayerVisibility(strLyrID(i), True) 'toc.Nodes.FindByValue("MapResourceItem0").Nodes(i).Checked = True page.Session.Item(strTemp) = True End If End If Next If map1.ImageBlendingMode = ESRI.ArcGIS.ADF.Web.UI.WebControls.ImageBlendingMode.Browser Then map1.RefreshResource("MapResourceItem0") Else map1.Refresh() End If 'toc.Refresh() 'toolbar.CallbackResults.CopyFrom(map1.CallbackResults) 'toolbar.CallbackResults.CopyFrom(toc.CallbackResults) End Sub

重现步骤

漏洞 ID: NIM034021

软件:

  • No Product Found

当漏洞状态发生变化时获得通知

下载 Esri 支持应用程序

发现关于本主题的更多内容

获取来自 ArcGIS 专家的帮助

联系技术支持部门

下载 Esri 支持应用程序

转至下载选项