ThinkGeo.com    |     Documentation    |     Premium Support

Using AreaStyle

hello support team

  i want to color the province based on id 

but when i use the below code , my application color outside the province not the inside, can you please guide me.



                    ShapeFileFeatureLayer layer = new ShapeFileFeatureLayer(Server.MapPath(ConfigurationManager.AppSettings["ProvinceFilePath"]));

                    ClassBreakStyle classBreakStyle = new ClassBreakStyle(ColumnId,BreakValueInclusion.IncludeValue);

                        foreach (var d in collfeatures)
                        {
                            int ID = Convert.ToInt32(d.ColumnValues[ColumnId]);

                            if (ID == 4) //ID is changed dynamically but we use 4 simply
                            {

                                Collection<Style> stylecoll = new Collection<Style>();
                                    stylecoll.Add(new TextStyle(ColumnName, new GeoFont("Arial", 10, DrawingFontStyles.Regular), new GeoSolidBrush(GeoColor.StandardColors.Black)));
                                    stylecoll.Add(new AreaStyle(new GeoSolidBrush(GeoColor.FromHtml("#0000FF"))));


                                    classBreakStyle.ClassBreaks.Add(new ClassBreak(Convert.ToDouble(ID), stylecoll));

                            }



                        }

                        layer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(AreaStyles.Country1);
                        layer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);
                        layer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;
                        layer.DrawingMarginPercentage = 100;
                        
                        Proj4Projection proj4 = new Proj4Projection();
                        proj4.InternalProjectionParametersString = Proj4Projection.GetEpsgParametersString(4326);
                        proj4.ExternalProjectionParametersString = Proj4Projection.GetGoogleMapParametersString();
                        layer.FeatureSource.Projection = proj4;
                        if (!proj4.IsOpen)
                            proj4.Open();
                        
                        graduatedoverlay.Layers.Add(layer);






























Hi Hassan, 
  
 Please don’t set areastyle and classBreakStyle at the same time, if you want to show special style for id 4 feature, please assign AreaStyles.Country1 for the other id feature. You add AreaStyles.Country1 and classBreakStyle to map at same time, it won’t render just like what you want. 
  
 Regards, 
  
 Don

Hi Don 
  
 Can you please send me an example for this situation. you have guided me just use areastyle for color the province but don’t sent any example. 


Hi hassan, 
  
 I guess you would like to render each province with different color based on its ID, in other words, different Id has different colors, in that case, maybe ValueStyle is a better option for you, here as following are the explanations of these 2 styles: 
  
   ClassBreakStyle - Used to render feature groups differently based on their data values, ie. 0-100 Red, 100-200 Blue. 
   ValueStyle - Renders features differntly based on absolute values in their data, ie. MiddleSchool = Red, HighSchool=Blue. 
  
 Here as following are the demo code: 
  
                ShapeFileFeatureLayer citiesLayer = new ShapeFileFeatureLayer(Server.MapPath("~/SampleData/World/capital.shp"));   
                citiesLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;  
                  
                // Draw features based on values  
                ValueStyle valueStyle = new ValueStyle();  
                valueStyle.ColumnName = "POP_RANK";  
                valueStyle.ValueItems.Add(new ValueItem("1", PointStyles.Capital1));  
                valueStyle.ValueItems.Add(new ValueItem("2", PointStyles.Capital3));  
                valueStyle.ValueItems.Add(new ValueItem("3", PointStyles.City7));  
                citiesLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);

 
  
 Thanks, 
 Johnny

Thank you , perfect solution

Good, any questions please feel free to let us know. 
  
 Regards, 
 Johnny