Arcgis server for net hides and controls the bound toc

Source: Internet
Author: User

Hello everyone, I have been updated for a long time. Recently, my project is busy. I am working on MAP CACHE. Tens of GB of data has produced millions of files. The system is suffering, I have the opportunity to write some ideas and share them with you. The following is the code in Layer Control!

 

Reference Column

HideLayer (Map1, "kuwait ");

Private void HideLayer (ESRI. ArcGIS. ADF. Web. UI. WebControls. Map map, string layerName)
{
// Loop through all map services in the Map/MapResourceManager
Foreach (IMapFunctionality mapFunct in map. GetFunctionalities ())
{
String layerId = GetLayerId (layerName, mapFunct );
// Turn layer off if found
If (! String. IsNullOrEmpty (layerId ))
MapFunct. SetLayerVisibility (layerId, false );
}

// Find Toc buddied to the Map, if any
Toc tocCtrl = FindControlOfType (typeof (Toc), Page. Controls) as Toc;
If (tocCtrl! = Null & tocCtrl. BuddyControl = map. ID)
{
// Remove Toc nodes for layer in each resource, if found
Foreach (TreeViewPlusNode resource in tocCtrl. Nodes)
{
TreeViewPlusNode nodeToRemove = null;

Foreach (TreeViewPlusNode layerNode in resource. Nodes)
{
TreeViewPlusNode matchNode = FindNodeRecursive (layerNode, layerName );
If (matchNode! = Null)
{
NodeToRemove = matchNode;
Break;
}
}
If (nodeToRemove! = Null)
NodeToRemove. Remove ();
}
}
}
Private string GetLayerId (string layerName, IMapFunctionality mapFunctionality)
{
String layerId = String. Empty;

// Get layerIDs/names for the service
String [] layerIDs, layerNames;
MapFunctionality. GetLayers (out layerIDs, out layerNames );

// Loop through names, find matching ID
For (int I = 0; I <layerIDs. Length; I ++)
{
If (layerNames [I] = layerName)
{
LayerId = layerIDs [I];
Break;
}
}
Return layerId;
}

Public static System. Web. UI. Control FindControlOfType (Type type, ControlCollection controls)
{
// Finds the first control matching the Type in the control collection
Foreach (System. Web. UI. Control ctl in controls)
{
If (type. IsInstanceOfType (ctl ))
Return ctl;
Else if (ctl. HasControls ())
{
System. Web. UI. Control childCtl = FindControlOfType (type, ctl. Controls );
If (childCtl! = Null)
Return childCtl;
}
}
Return null;
}

Private TreeViewPlusNode FindNodeRecursive (TreeViewPlusNode node, string nodeName)
{
If (node. Text = nodeName)
Return node;

Foreach (TreeViewPlusNode node2 in node. Nodes)
{
TreeViewPlusNode childNode = FindNodeRecursive (node2, nodeName );
If (childNode! = Null)
Return childNode;
}
Return null;
}

 

I only want to delete all the layers in a service by myself. For example, there are too many small slices in the remote sensing image, so users are not allowed to click here :-)

 

Protected void Page_PreRenderComplete (object sender, EventArgs e)
{
// If no tasks have been defined, hide the tasks panel
// If (TaskMenu. Items. Count = 0) Tasks_Menu_Panel.Visible = false;
// Check to see if any of the resource items are non-pooled
If (! Page. IsCallback |! Page. IsPostBack)
{
// CloseHyperLink. Visible = HasNonPooledResources ();
OverviewMap ov = Page. FindControl ("OverviewMap1") as OverviewMap;
If (ov! = Null &&! OverviewMapResourceIsValid (ov ))
Ov. OverviewMapResource = Map1.PrimaryMapResource;

Int tocnum = Toc1.Nodes [1]. Nodes. Count;
If (tocnum> 0 ){
For (int I = tocnum-1; I>-1; I --)
{

Toc1.Nodes [1]. Nodes [I]. Remove ();
}

// The above code should be put in this method. If it is put in another cycle, the data in toc has not been loaded yet ..
}

}
CopyrightTextHolder. Visible = HasCopyrightText ();

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.