Cannot programmatically change the visibility of a ArcWebServices layer using IMapFunctionality.
最後に公開された状態: August 25, 2014No Product Found
不具合 ID 番号
NIM034021
送信されました
April 8, 2008
最終更新日
June 5, 2024
適用対象
No Product Found
見つかったバージョン
9.2
プログラム言語
VB.Net
ステータス
Known Limit
開発チームによる確認後に、この問題が、Esri の管理の範囲外にあるソフトウェアの既知の制限に関するものであると判断されました。 問題の「参考情報」セクションに、さらに詳細な説明が示されていることがあります。
参考情報
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