# LegendItem text alignment

**URL:** <https://community.thinkgeo.com/t/legenditem-text-alignment/2156>\
**Category:** WinForms\
**Created:** [January 17, 2013, 10:16am UTC](https://community.thinkgeo.com/t/legenditem-text-alignment/2156 "2013-01-17T10:16:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dib](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/dib/32/19493_2.png) [@Dib](https://community.thinkgeo.com/u/Dib)\
**Post date:** [January 17, 2013, 10:16am UTC](https://community.thinkgeo.com/t/legenditem-text-alignment/2156/1 "2013-01-17T10:16:12Z")

</div>

&nbsp;Hello,

&nbsp;

I&nbsp;am&nbsp;adding&nbsp;legends&nbsp;to&nbsp;our&nbsp;map,&nbsp;and&nbsp;am&nbsp;having&nbsp;issues&nbsp;with&nbsp;the&nbsp;text&nbsp;aligment.&nbsp;&nbsp;If&nbsp;the&nbsp;legend&nbsp;item&nbsp;spans&nbsp;the&nbsp;entire&nbsp;width&nbsp;of&nbsp;the&nbsp;map,&nbsp;as&nbsp;some&nbsp;of&nbsp;ours&nbsp;do,&nbsp;and&nbsp;the&nbsp;item&nbsp;only&nbsp;contains&nbsp;text,&nbsp;with&nbsp;no&nbsp;images,&nbsp;I&nbsp;can't&nbsp;get&nbsp;the&nbsp;text&nbsp;to&nbsp;left-justify.&nbsp;&nbsp;It&nbsp;either&nbsp;shows&nbsp;up&nbsp;indented&nbsp;a&nbsp;good&nbsp;bit,&nbsp;or,&nbsp;in&nbsp;some&nbsp;cases,&nbsp;we&nbsp;have&nbsp;seen&nbsp;it&nbsp;draw&nbsp;correctly&nbsp;initially,&nbsp;and&nbsp;then&nbsp;once&nbsp;anything&nbsp;is&nbsp;done&nbsp;to&nbsp;the&nbsp;map,&nbsp;if&nbsp;the&nbsp;extent&nbsp;is&nbsp;changed&nbsp;at&nbsp;all,&nbsp;the&nbsp;legend&nbsp;item&nbsp;redraws&nbsp;with&nbsp;the&nbsp;text&nbsp;indented&nbsp;again.&nbsp;&nbsp;When&nbsp;creating&nbsp;legend&nbsp;items&nbsp;that&nbsp;don't&nbsp;span&nbsp;the&nbsp;entire&nbsp;width,&nbsp;I&nbsp;can&nbsp;add&nbsp;a&nbsp;new&nbsp;LegendItem&nbsp;to&nbsp;LedendAdornmentLayer,&nbsp;and&nbsp;the&nbsp;text&nbsp;will&nbsp;be&nbsp;left-aligned&nbsp;as&nbsp;expected.

&nbsp;

Here&nbsp;is&nbsp;the&nbsp;code&nbsp;that&nbsp;is&nbsp;currently&nbsp;not&nbsp;working&nbsp;as&nbsp;expected:

&nbsp;

Dim&nbsp;stormInfoBoxLayer&nbsp;As&nbsp;New&nbsp;LegendAdornmentLayer

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stormInfoBoxLayer.Name&nbsp;=&nbsp;layerName\_StormInfoLegend

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stormInfoBoxLayer.BackgroundMask&nbsp;=&nbsp;AreaStyles.CreateLinearGradientStyle(New&nbsp;GeoColor(255,&nbsp;255,&nbsp;255,&nbsp;255),&nbsp;New&nbsp;GeoColor(255,&nbsp;230,&nbsp;230,&nbsp;230),&nbsp;90,&nbsp;GeoColor.SimpleColors.Black)

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stormInfoBoxLayer.Location&nbsp;=&nbsp;AdornmentLocation.LowerRight

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stormInfoBoxLayer.Height&nbsp;=&nbsp;lineHeight&nbsp;+&nbsp;8

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;stormInfoBoxLayer.Width&nbsp;=&nbsp;Me.Map.Width

&nbsp;

&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Dim&nbsp;sibItemText&nbsp;As&nbsp;New&nbsp;LegendItem

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sibItemText.TextStyle&nbsp;=&nbsp;New&nbsp;TextStyle(stormInfoText,&nbsp;New&nbsp;GeoFont("Arial",&nbsp;9,&nbsp;DrawingFontStyles.Regular),&nbsp;New&nbsp;GeoSolidBrush(GeoColor.SimpleColors.Black))

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sibItemText.ImageJustificationMode&nbsp;=&nbsp;LegendImageJustificationMode.JustifyImageRight

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sibItemText.Height&nbsp;=&nbsp;lineHeight

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sibItemText.TextLeftPadding&nbsp;=&nbsp;0

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sibItemText.TextTopPadding&nbsp;=&nbsp;1

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sibItemText.TextBottomPadding&nbsp;=&nbsp;1

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sibItemText.TopPadding&nbsp;=&nbsp;0

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;sibItemText.BottomPadding&nbsp;=&nbsp;0

&nbsp;

&nbsp;

stormInfoBoxLayer.LegendItems.Add(layerName\_StormInfoLegend,&nbsp;sibItemText)

Me.Map.AdornmentOverlay.Layers.Add(layerName\_StormInfoLegend,&nbsp;stormInfoBoxLayer)

---

<div class="post-metadata">

**Author:** ![Dib](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/dib/32/19493_2.png) [@Dib](https://community.thinkgeo.com/u/Dib)\
**Post date:** [January 17, 2013, 12:28pm UTC](https://community.thinkgeo.com/t/legenditem-text-alignment/2156/2 "2013-01-17T12:28:05Z")

</div>

A&nbsp;few&nbsp;more&nbsp;notes:&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;have&nbsp;my&nbsp;LegendAdornmentLayer&nbsp;.Location&nbsp;=&nbsp;AdornmentLocation.LowerLeft.&nbsp;&nbsp;The&nbsp;map’s&nbsp;width&nbsp;is&nbsp;718.&nbsp;&nbsp;If&nbsp;I&nbsp;set&nbsp;the&nbsp;adornment&nbsp;layer&nbsp;to&nbsp;301&nbsp;or&nbsp;less&nbsp;(or&nbsp;lower&nbsp;than&nbsp;43%&nbsp;of&nbsp;map&nbsp;width),&nbsp;the&nbsp;legend&nbsp;items&nbsp;stack&nbsp;on&nbsp;top&nbsp;of&nbsp;each&nbsp;other&nbsp;when&nbsp;added,&nbsp;so&nbsp;that&nbsp;they&nbsp;can&nbsp;be&nbsp;read&nbsp;easily.&nbsp;&nbsp;If&nbsp;the&nbsp;width&nbsp;is&nbsp;set&nbsp;to&nbsp;302&nbsp;or&nbsp;higher&nbsp;(or&nbsp;43%&nbsp;or&nbsp;higher)&nbsp;the&nbsp;second&nbsp;added&nbsp;legend&nbsp;item&nbsp;shows&nbsp;up&nbsp;on&nbsp;the&nbsp;same&nbsp;horizontal&nbsp;line&nbsp;as&nbsp;the&nbsp;first,&nbsp;around&nbsp;the&nbsp;midpoint&nbsp;of&nbsp;the&nbsp;first&nbsp;item.&nbsp;  
&nbsp;&nbsp;

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [January 18, 2013, 2:24am UTC](https://community.thinkgeo.com/t/legenditem-text-alignment/2156/3 "2013-01-18T02:24:52Z")

</div>

Hi&nbsp;Dib,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks&nbsp;for&nbsp;your&nbsp;post,&nbsp;we&nbsp;have&nbsp;fix&nbsp;the&nbsp;bug,&nbsp;please&nbsp;get&nbsp;the&nbsp;6.0.0.250&nbsp;or&nbsp;6.0.250.0&nbsp;and&nbsp;have&nbsp;a&nbsp;try.&nbsp;  
&nbsp;&nbsp;  
&nbsp;One&nbsp;more&nbsp;thing&nbsp;is&nbsp;that&nbsp;if&nbsp;you&nbsp;need&nbsp;to&nbsp;display&nbsp;two&nbsp;legenditems&nbsp;in&nbsp;two&nbsp;rows,&nbsp;you&nbsp;need&nbsp;to&nbsp;make&nbsp;stormInfoBoxLayer.Height&nbsp;high&nbsp;enough&nbsp;to&nbsp;display&nbsp;them.&nbsp;otherwise&nbsp;they&nbsp;will&nbsp;be&nbsp;displayed&nbsp;in&nbsp;one&nbsp;row&nbsp;automatically.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Hope&nbsp;it&nbsp;helps.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Edgar&nbsp;

---

<div class="post-metadata">

**Author:** ![Dib](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/dib/32/19493_2.png) [@Dib](https://community.thinkgeo.com/u/Dib)\
**Post date:** [January 18, 2013, 10:13am UTC](https://community.thinkgeo.com/t/legenditem-text-alignment/2156/4 "2013-01-18T10:13:00Z")

</div>

Will&nbsp;do.&nbsp;&nbsp;I&nbsp;see&nbsp;the&nbsp;.250&nbsp;eval&nbsp;version&nbsp;under&nbsp;Evaluation&nbsp;Daily&nbsp;Builds\Daily&nbsp;Productions&nbsp;Builds,&nbsp;but&nbsp;the&nbsp;full&nbsp;version&nbsp;isn’t&nbsp;available&nbsp;under&nbsp;My&nbsp;Product&nbsp;Downloads&nbsp;yet.&nbsp;&nbsp;Once&nbsp;it&nbsp;is&nbsp;there&nbsp;I&nbsp;will&nbsp;get&nbsp;to&nbsp;work&nbsp;on&nbsp;it.

---

<div class="post-metadata">

**Author:** ![Dib](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/dib/32/19493_2.png) [@Dib](https://community.thinkgeo.com/u/Dib)\
**Post date:** [January 22, 2013, 9:12am UTC](https://community.thinkgeo.com/t/legenditem-text-alignment/2156/5 "2013-01-22T09:12:35Z")

</div>

Looks&nbsp;good&nbsp;so&nbsp;far.&nbsp;&nbsp;Thanks

---

<div class="post-metadata">

**Author:** ![Edgar](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/e/b487fb/32.png) [@Edgar](https://community.thinkgeo.com/u/Edgar)\
**Post date:** [January 22, 2013, 7:34pm UTC](https://community.thinkgeo.com/t/legenditem-text-alignment/2156/6 "2013-01-22T19:34:31Z")

</div>

You’re&nbsp;welcome,&nbsp;if&nbsp;you&nbsp;have&nbsp;any&nbsp;other&nbsp;questions,&nbsp;please&nbsp;let&nbsp;us&nbsp;know.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Regards,&nbsp;  
&nbsp;Edgar
