예제 #1
0
        private void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            CheckBox tickedCheckBox = sender as CheckBox;

            string serviceName = tickedCheckBox.Name;
            bool   visible     = (bool)tickedCheckBox.IsChecked;

            int layerIndex = (int)tickedCheckBox.Tag;

            ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer dynamicServiceLayer = MyMap.Layers[serviceName] as
                                                                                  ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer;

            List <int> visibleLayerList =
                dynamicServiceLayer.VisibleLayers != null
                ? dynamicServiceLayer.VisibleLayers.ToList() : new List <int>();

            if (visible)
            {
                if (!visibleLayerList.Contains(layerIndex))
                {
                    visibleLayerList.Add(layerIndex);
                }
            }
            else
            {
                if (visibleLayerList.Contains(layerIndex))
                {
                    visibleLayerList.Remove(layerIndex);
                }
            }


            dynamicServiceLayer.VisibleLayers = visibleLayerList.ToArray();
        }
예제 #2
0
 private void ArcGISDynamicMapServiceLayer_Initialized(object sender, EventArgs e)
 {
     ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer myArcGISDynamicMapServiceLayer =
         MyMap.Layers["Fire Perimeter"] as ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer;
     int[] myVisibleLayers = { 2 };
     myArcGISDynamicMapServiceLayer.VisibleLayers = myVisibleLayers;
 }
예제 #3
0
 private void ArcGISDynamicMapServiceLayer_Initialized(object sender, EventArgs e)
 {
     ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer dynamicServiceLayer =
         sender as ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer;
     if (dynamicServiceLayer.VisibleLayers == null)
     {
         dynamicServiceLayer.VisibleLayers = GetDefaultVisibleLayers(dynamicServiceLayer);
     }
 }
예제 #4
0
        private int[] GetDefaultVisibleLayers(ESRI.ArcGIS.Client.ArcGISDynamicMapServiceLayer dynamicService)
        {
            List <int> visibleLayerIDList = new List <int>();

            ESRI.ArcGIS.Client.LayerInfo[] layerInfoArray = dynamicService.Layers;

            for (int index = 0; index < layerInfoArray.Length; index++)
            {
                if (layerInfoArray[index].DefaultVisibility)
                {
                    visibleLayerIDList.Add(index);
                }
            }
            return(visibleLayerIDList.ToArray());
        }