# Change Corlor a line or polygon... in a layer

**URL:** <https://community.thinkgeo.com/t/change-corlor-a-line-or-polygon-in-a-layer/1845>\
**Category:** WinForms\
**Created:** [November 24, 2011, 2:50am UTC](https://community.thinkgeo.com/t/change-corlor-a-line-or-polygon-in-a-layer/1845 "2011-11-24T02:50:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![nguyen](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/n/eb8c5e/32.png) [@nguyen](https://community.thinkgeo.com/u/nguyen)\
**Post date:** [November 24, 2011, 2:50am UTC](https://community.thinkgeo.com/t/change-corlor-a-line-or-polygon-in-a-layer/1845/1 "2011-11-24T02:50:53Z")

</div>

Hi&nbsp;all!

In&nbsp;my&nbsp;map,&nbsp;example&nbsp;it&nbsp;has&nbsp;a&nbsp;many&nbsp;blue&nbsp;rivers.&nbsp;And&nbsp;i&nbsp;want&nbsp;to&nbsp;change&nbsp;color&nbsp;rivers&nbsp;which&nbsp;are&nbsp;polluted&nbsp;into&nbsp;red&nbsp;color.

How&nbsp;can&nbsp;i&nbsp;do&nbsp;in&nbsp;the&nbsp;mapsuite&nbsp;desktop?

Thanks!

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [November 24, 2011, 1:21pm UTC](https://community.thinkgeo.com/t/change-corlor-a-line-or-polygon-in-a-layer/1845/2 "2011-11-24T13:21:47Z")

</div>

Hello&nbsp;nguyen，&nbsp;  
  
  
  
Thanks&nbsp;for&nbsp;your&nbsp;post,&nbsp;I'm&nbsp;not&nbsp;sure&nbsp;what's&nbsp;the&nbsp;states&nbsp;in&nbsp;your&nbsp;layer,&nbsp;is&nbsp;it&nbsp;only&nbsp;contains&nbsp;the&nbsp;river&nbsp;data?&nbsp;  
  
  
  
If&nbsp;so,&nbsp;you&nbsp;can&nbsp;simply&nbsp;set&nbsp;the&nbsp;default&nbsp;AreaStyle&nbsp;or&nbsp;LineStyle&nbsp;to&nbsp;this&nbsp;layer&nbsp;to&nbsp;change&nbsp;the&nbsp;color,&nbsp;please&nbsp;see&nbsp;the&nbsp;code&nbsp;below:&nbsp;  
  
`worldLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(new GeoSolidBrush(GeoColor.SimpleColors.Red));worldLayer.ZoomLevelSet.ZoomLevel01.DefaultLineStyle = new LineStyle(new GeoPen(GeoColor.SimpleColors.Red));worldLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;`  
  
  
If&nbsp;not,&nbsp;could&nbsp;you&nbsp;please&nbsp;give&nbsp;more&nbsp;information?&nbsp;How&nbsp;can&nbsp;you&nbsp;define&nbsp;the&nbsp;river?&nbsp;  
  
  
  
Regards,&nbsp;  
  
  
  
Gary&nbsp;

---

<div class="post-metadata">

**Author:** ![nguyen](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/n/eb8c5e/32.png) [@nguyen](https://community.thinkgeo.com/u/nguyen)\
**Post date:** [November 24, 2011, 8:00pm UTC](https://community.thinkgeo.com/t/change-corlor-a-line-or-polygon-in-a-layer/1845/3 "2011-11-24T20:00:43Z")

</div>

I&nbsp;want&nbsp;to&nbsp;use&nbsp;colors&nbsp;to&nbsp;show&nbsp;information&nbsp;about&nbsp;river’s&nbsp;problem.&nbsp;  
&nbsp;Example:&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It&nbsp;has&nbsp;0-20%&nbsp;pollution&nbsp;-\>&nbsp;color:&nbsp;blue&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It&nbsp;has&nbsp;20&nbsp;-40%&nbsp;pollution&nbsp;-\>&nbsp;color:&nbsp;yellow&nbsp;green&nbsp;  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It&nbsp;has&nbsp;\>&nbsp;40%&nbsp;pollution&nbsp;-\>&nbsp;color:&nbsp;red.&nbsp;  
&nbsp;Do&nbsp;you&nbsp;understand&nbsp;my&nbsp;infomation&nbsp;:)?&nbsp;  
&nbsp;&nbsp;

---

<div class="post-metadata">

**Author:** ![Gary2](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/g/49beb7/32.png) [@Gary2](https://community.thinkgeo.com/u/Gary2)\
**Post date:** [November 25, 2011, 12:39pm UTC](https://community.thinkgeo.com/t/change-corlor-a-line-or-polygon-in-a-layer/1845/4 "2011-11-25T12:39:12Z")

</div>

Hello&nbsp;nguyen,&nbsp;  
  
  
  
Yes,&nbsp;thanks&nbsp;for&nbsp;your&nbsp;further&nbsp;information.&nbsp;  
  
  
  
For&nbsp;this&nbsp;requirement,&nbsp;we&nbsp;have&nbsp;the&nbsp;ClassBreakStyle&nbsp;can&nbsp;do&nbsp;this&nbsp;job,&nbsp;this&nbsp;class&nbsp;represents&nbsp;a&nbsp;style&nbsp;based&nbsp;on&nbsp;a&nbsp;range&nbsp;of&nbsp;values.&nbsp;Please&nbsp;see&nbsp;the&nbsp;code&nbsp;below:&nbsp;  
  
`ClassBreakStyle classBreakStyle = new ClassBreakStyle("YourRiverPollutionColumnName");classBreakStyle.ClassBreaks.Add(new ClassBreak(20, new AreaStyle(new GeoSolidBrush(GeoColor.SimpleColors.Blue))));classBreakStyle.ClassBreaks.Add(new ClassBreak(40, new AreaStyle(new GeoSolidBrush(GeoColor.SimpleColors.Yellow))));classBreakStyle.ClassBreaks.Add(new ClassBreak(100, new AreaStyle(new GeoSolidBrush(GeoColor.SimpleColors.Red))));riverFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);riverFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;`  
  
  
Or&nbsp;you&nbsp;can&nbsp;see&nbsp;HowDoISamples&nbsp;--&nbsp;\>&nbsp;Data&nbsp;Providers&nbsp;--\>&nbsp;LoadAGridFeatureLayer&nbsp;  
  
  
  
Regards,&nbsp;  
  
  
  
Gary

---

<div class="post-metadata">

**Author:** ![Val](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/v/e56c9b/32.png) [@Val](https://community.thinkgeo.com/u/Val)\
**Post date:** [November 28, 2011, 12:34pm UTC](https://community.thinkgeo.com/t/change-corlor-a-line-or-polygon-in-a-layer/1845/5 "2011-11-28T12:34:44Z")

</div>

Nguyen,

&nbsp;I&nbsp;would&nbsp;like&nbsp;to&nbsp;bring&nbsp;some&nbsp;more&nbsp;information&nbsp;because&nbsp;I&nbsp;think&nbsp;that&nbsp;Gary's&nbsp;answer&nbsp;is&nbsp;uncomplete.&nbsp;Indeed&nbsp;the&nbsp;correct&nbsp;style&nbsp;to&nbsp;use&nbsp;is&nbsp;ClassBreakStyle&nbsp;but&nbsp;you&nbsp;have&nbsp;to&nbsp;be&nbsp;aware&nbsp;on&nbsp;how&nbsp;the&nbsp;break&nbsp;value&nbsp;in&nbsp;each&nbsp;ClassBreak&nbsp;works.&nbsp;The&nbsp;first&nbsp;parameter&nbsp;that&nbsp;you&nbsp;pass&nbsp;in&nbsp;ClassBreak&nbsp;is&nbsp;actually&nbsp;the&nbsp;value&nbsp;the&nbsp;range&nbsp;of&nbsp;the&nbsp;class&nbsp;break&nbsp;is&nbsp;going&nbsp;to&nbsp;start&nbsp;from.&nbsp;So&nbsp;for&nbsp;your&nbsp;case,&nbsp;you&nbsp;are&nbsp;going&nbsp;to&nbsp;have&nbsp;to&nbsp;have&nbsp;the&nbsp;following&nbsp;code.&nbsp;Also,&nbsp;you&nbsp;will&nbsp;see&nbsp;that&nbsp;I&nbsp;am&nbsp;using&nbsp;LineStyle&nbsp;and&nbsp;not&nbsp;AreaStyle&nbsp;because&nbsp;your&nbsp;river&nbsp;data&nbsp;is&nbsp;more&nbsp;than&nbsp;likely&nbsp;line&nbsp;based.&nbsp;I&nbsp;hope&nbsp;this&nbsp;will&nbsp;have&nbsp;helped.&nbsp;Thank&nbsp;you.

`ShapeFileFeatureLayer riverFeatureLayer = new ShapeFileFeatureLayer();ClassBreakStyle classBreakStyle = new ClassBreakStyle("YourRiverPollutionColumnName");//From 0 until the value of the next ClassBreak (20). From 0 to 19.9999classBreakStyle.ClassBreaks.Add(new ClassBreak(0,new LineStyle(new GeoPen(GeoColor.StandardColors.Blue,3))));//From 20 until the value of the next ClassBreak (40). From 20 to 39.9999classBreakStyle.ClassBreaks.Add(new ClassBreak(20, new LineStyle(new GeoPen(GeoColor.StandardColors.YellowGreen, 3))));//From 40 and beyond. classBreakStyle.ClassBreaks.Add(new ClassBreak(40, new LineStyle(new GeoPen(GeoColor.StandardColors.Red, 3))));riverFeatureLayer.ZoomLevelSet.ZoomLevel01.CustomStyles.Add(classBreakStyle);riverFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;`
