[code] public void Button1_Click() { Map1 = (Map)Session["map"]; LayerOverlay dynamicOverlay = (LayerOverlay)Map1.CustomOverlays["StaticOverlay"]; ShapeFileFeatureLayer provinceLayer = (ShapeFileFeatureLayer)dynamicOverlay.Layers["ProvinceLayer"]; ShapeFileFeatureLayer divisionLayer = (ShapeFileFeatureLayer)dynamicOverlay.Layers["DivisionLayer"]; //InMemoryFeatureLayer provinceDivisionLayer = (InMemoryFeatureLayer)dynamicOverlay.Layers["ProvinceDivisionLayer"]; List featureName = new List(); //string Provinces = ProvincesList.SelectedValue; bool flage1 = false; bool flage2 = false; foreach (FeatureLayer layer in dynamicOverlay.Layers) { if (layer == provinceLayer) { provinceLayer.Open(); Collection layerFeatures = provinceLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns); provinceLayer.Close(); Collection columns = new Collection(); foreach (string columnName in layerFeatures[0].ColumnValues.Keys) { columns.Add(new FeatureSourceColumn(columnName)); } InMemoryFeatureLayer provinceDivisionLayer = new InMemoryFeatureLayer(columns, new Collection() { layerFeatures[0] }); provinceDivisionLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(50, GeoColor.SimpleColors.BrightRed))); provinceDivisionLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; provinceLayer.Open(); Collection features = provinceLayer.QueryTools.GetFeaturesByColumnValue("NAME_1", "Punjab"); provinceLayer.Close(); provinceDivisionLayer.InternalFeatures.Clear(); if (features.Count > 0) { Map1.CurrentExtent = features[0].GetBoundingBox(); divisionLayer.Open(); Collection divisionFeatures = divisionLayer.QueryTools.GetFeaturesWithin(features[0], ReturningColumnsType.AllColumns); divisionLayer.Close(); foreach (Feature feature in features) { provinceDivisionLayer.InternalFeatures.Add(feature); featureName.Add(feature.ColumnValues["NAME_1"]); //TextBox1.Text += featureName; } flage1 = true; if (i > 0) { dynamicOverlay.Layers.Remove("ProvinceDivisionLayer"); } dynamicOverlay.Layers.Add("ProvinceDivisionLayer", provinceDivisionLayer); i++; break; } } else if (layer == divisionLayer) { divisionLayer.Open(); Collection layerFeatures = divisionLayer.FeatureSource.GetAllFeatures(ReturningColumnsType.AllColumns); divisionLayer.Close(); Collection columns = new Collection(); foreach (string columnName in layerFeatures[0].ColumnValues.Keys) { columns.Add(new FeatureSourceColumn(columnName)); } InMemoryFeatureLayer provinceDivisionLayer = new InMemoryFeatureLayer(columns, new Collection() { layerFeatures[0] }); provinceDivisionLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.CreateSimpleAreaStyle(GeoColor.SimpleColors.Transparent, GeoColor.FromArgb(50, GeoColor.SimpleColors.BrightRed))); provinceDivisionLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; divisionLayer.Open(); Collection divisionFeatures = divisionLayer.QueryTools.GetFeaturesByColumnValue("NAME_2", "Lahore"); divisionLayer.Close(); provinceDivisionLayer.InternalFeatures.Clear(); if (divisionFeatures.Count > 0) { Map1.CurrentExtent = divisionFeatures[0].GetBoundingBox(); provinceDivisionLayer.InternalFeatures.Clear(); foreach (Feature feature in divisionFeatures) { provinceDivisionLayer.InternalFeatures.Add(feature); featureName.Add(feature.ColumnValues["NAME_2"]); //TextBox1.Text += featureName; } flage2 = true; if (i > 0) { dynamicOverlay.Layers.Remove("ProvinceDivisionLayer"); } dynamicOverlay.Layers.Add("ProvinceDivisionLayer", provinceDivisionLayer); i++; break; } } } InMemoryFeatureLayer provincedivisionLayer = (InMemoryFeatureLayer)dynamicOverlay.Layers["ProvinceDivisionLayer"]; if (provincedivisionLayer.InternalFeatures.Count() > 0) { //--------------populate data on map---------------------------// // provincedivisionLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(TextStyles.CreateSimpleTextStyle("Test", "Arial", 10, DrawingFontStyles.Regular, GeoColor.StandardColors.Red, 0, -12)); //provincedivisionLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; //provincedivisionLayer.DrawingMarginPercentage = 50; //// -----------event rigistertom for custom data usage--------------------// //provincedivisionLayer.FeatureSource.CustomColumnFetch += new EventHandler(FeatureSource_CustomColumnFetch); //provincedivisionLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle.RequiredColumnNames.Add("Test"); //-------------------------------end------------------------------------------// //-------------- apply value style-----------------------// int featureCount = provincedivisionLayer.InternalFeatures.Count(); Collection colorsInFamily = GeoColor.GetColorsInHueFamily(GeoColor.StandardColors.Green, featureCount); ValueStyle valueStyle = new ValueStyle(); if (flage1 == true) { //int featureCount = provinceDivisionLayer.InternalFeatures.Count(); // TextBox2.Text = featureCount.ToString(); valueStyle.ColumnName = "NAME_1"; valueStyle.ValueItems.Add(new ValueItem(featureName[0], new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.LightGreen)))); for (int j = 0; j < featureCount; j++) { //valueStyle.ValueItems.Add(new ValueItem(featureName[j], new AreaStyle(new GeoSolidBrush(colorsInFamily[j])))); } } //--------------------------------end----------------------------------------------------------// else if (flage2 == true) { //TextBox2.Text = featureCount.ToString(); valueStyle.ColumnName = "NAME_2"; //valueStyle.ValueItems.Add(new ValueItem(featureName[0], new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.LightGreen)))); for (int j = 1; j < featureCount; j++) { valueStyle.ValueItems.Add(new ValueItem(featureName[j], new AreaStyle(new GeoSolidBrush(colorsInFamily[j])))); } } provincedivisionLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Clear(); provincedivisionLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle); provincedivisionLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20; dynamicOverlay.Layers.Add(provincedivisionLayer); //dynamicOverlay.Redraw(); } } [/code]