ThinkGeo.com    |     Documentation    |     Premium Support

You are trying to use both a default style and the custom style

Hello,


 I need to show the zip codes group by my "sales area". I need to show the sales areas in different color and I also need to show the name of sales area.


 So, I added a custom column "SALES_AREA" (still working on it) with will have multiple zip codes.


 Following code works - to show the red color for the AreaStyle for a sales area.




ShapeFileFeatureLayer saLayer = new ShapeFileFeatureLayer(@"C:\temp\WebSites\ThinkGeo\Data\NJ\tl_2010_34_zcta510.shp", @"C:\temp\WebSites\ThinkGeo\Data\NJ\tl_2010_34_zcta510.idx");
ValueStyle valueStyle = new ValueStyle();
valueStyle.ColumnName = "SALES_AREA";
valueStyle.ValueItems.Add(new ValueItem("SALES_AREA10", new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.Red))));

saLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
saLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;//20 is zoomest
//saLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("SALES_AREA", "Arial", 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);
                
LayerOverlay salesareaOverlay = new LayerOverlay();
salesareaOverlay.Layers.Add("saLayer", saLayer);
salesareaOverlay.IsBaseOverlay = false;
Map1.CustomOverlays.Add(salesareaOverlay);
saLayer.FeatureSource.CustomColumnFetch += new EventHandler<CustomColumnFetchEventArgs>(FeatureSource_CustomColumnFetch);

 


 To be able to see the sales area name, I uncommented a line as below.



ShapeFileFeatureLayer saLayer = new ShapeFileFeatureLayer(@"C:\temp\WebSites\ThinkGeo\Data\NJ\tl_2010_34_zcta510.shp", @"C:\temp\WebSites\ThinkGeo\Data\NJ\tl_2010_34_zcta510.idx");
ValueStyle valueStyle = new ValueStyle();
valueStyle.ColumnName = "SALES_AREA";
valueStyle.ValueItems.Add(new ValueItem("SALES_AREA10", new AreaStyle(new GeoSolidBrush(GeoColor.StandardColors.Red))));

saLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(valueStyle);
saLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;//20 is zoomest
saLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("SALES_AREA", "Arial", 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);
                
LayerOverlay salesareaOverlay = new LayerOverlay();
salesareaOverlay.Layers.Add("saLayer", saLayer);
salesareaOverlay.IsBaseOverlay = false;
Map1.CustomOverlays.Add(salesareaOverlay);
saLayer.FeatureSource.CustomColumnFetch += new EventHandler<CustomColumnFetchEventArgs>(FeatureSource_CustomColumnFetch);

 


 And I got error saying 'You are trying to use both a default style and the custom style..'.


 I believe you have a way to show the custom text styles.


 Can you please advise?


 


Thank you


shwe



shwe, 
  
 Thanks for you post, yes you can add any style to the CusomStyles collection including TextStyles so you all you should need to do is replace this line of code: 
  
  
 saLayer.ZoomLevelSet.ZoomLevel01.DefaultTextStyle = TextStyles.CreateSimpleTextStyle(“SALES_AREA”, “Arial”, 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3); 
  
  
 With this one: 
  
 saLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(TextStyles.CreateSimpleTextStyle(“SALES_AREA”, “Arial”, 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3)); 
  
 Please let us know if this doesn’t work or if you any other questions.  Thanks!