# Fixed text on a layer

**URL:** <https://community.thinkgeo.com/t/fixed-text-on-a-layer/6062>\
**Category:** WebForms\
**Created:** [December 12, 2011, 4:16pm UTC](https://community.thinkgeo.com/t/fixed-text-on-a-layer/6062 "2011-12-12T16:16:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shwe](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/ed8c4c/32.png) [@shwe](https://community.thinkgeo.com/u/shwe)\
**Post date:** [December 12, 2011, 4:16pm UTC](https://community.thinkgeo.com/t/fixed-text-on-a-layer/6062/1 "2011-12-12T16:16:00Z")

</div>

Hello,

I&nbsp;can&nbsp;set&nbsp;the&nbsp;text&nbsp;of&nbsp;the&nbsp;features&nbsp;of&nbsp;a&nbsp;specific&nbsp;layer&nbsp;with&nbsp;the&nbsp;column&nbsp;values&nbsp;of&nbsp;shape&nbsp;file&nbsp;as&nbsp;-

&nbsp;

` saLayer.ZoomLevelSet.ZoomLevel12.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("ZCTA5CE10", "Arial", 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);`

But,&nbsp;I&nbsp;want&nbsp;to&nbsp;set&nbsp;a&nbsp;fixed&nbsp;text&nbsp;for&nbsp;a&nbsp;paricular&nbsp;layer&nbsp;for&nbsp;a&nbsp;particular&nbsp;zoom&nbsp;level.

e.g,&nbsp;saLayer.ZoomLevelSet.ZoomLevel12&nbsp;==\>&nbsp;I&nbsp;want&nbsp;to&nbsp;show&nbsp;the&nbsp;whole&nbsp;layer&nbsp;with&nbsp;a&nbsp;fixed&nbsp;text&nbsp;like&nbsp;"This&nbsp;is&nbsp;my&nbsp;sales&nbsp;area".  
  
Would&nbsp;you&nbsp;please&nbsp;suggest&nbsp;how&nbsp;to&nbsp;do&nbsp;that?

Thank&nbsp;you  
  
shwe

---

<div class="post-metadata">

**Author:** ![Clint](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@Clint](https://community.thinkgeo.com/u/Clint)\
**Post date:** [December 12, 2011, 5:00pm UTC](https://community.thinkgeo.com/t/fixed-text-on-a-layer/6062/2 "2011-12-12T17:00:53Z")

</div>

shwe,

&nbsp;  
Thanks&nbsp;for&nbsp;you&nbsp;post,&nbsp;you&nbsp;have&nbsp;a&nbsp;couple&nbsp;options&nbsp;to&nbsp;accomplish&nbsp;what&nbsp;you&nbsp;want.&nbsp;&nbsp;The&nbsp;approach&nbsp;depends&nbsp;on&nbsp;the&nbsp;answer&nbsp;to&nbsp;the&nbsp;following&nbsp;question.&nbsp;&nbsp;Do&nbsp;you&nbsp;want&nbsp;the&nbsp;label&nbsp;to&nbsp;move&nbsp;when&nbsp;you&nbsp;pan&nbsp;the&nbsp;map&nbsp;or&nbsp;do&nbsp;you&nbsp;want&nbsp;the&nbsp;label&nbsp;placed&nbsp;in&nbsp;a&nbsp;fixed&nbsp;position&nbsp;on&nbsp;the&nbsp;map&nbsp;regardless&nbsp;of&nbsp;the&nbsp;panning?  
&nbsp;  
Judging&nbsp;by&nbsp;your&nbsp;question&nbsp;I'm&nbsp;guessing&nbsp;that&nbsp;you&nbsp;do&nbsp;want&nbsp;the&nbsp;label&nbsp;to&nbsp;be&nbsp;on&nbsp;top&nbsp;of&nbsp;the&nbsp;entire&nbsp;territory&nbsp;and&nbsp;have&nbsp;the&nbsp;label&nbsp;move&nbsp;when&nbsp;the&nbsp;map&nbsp;is&nbsp;panned.&nbsp;&nbsp;To&nbsp;accomplish&nbsp;this&nbsp;I&nbsp;would&nbsp;suggest&nbsp;getting&nbsp;the&nbsp;bounding&nbsp;box&nbsp;of&nbsp;the&nbsp;all&nbsp;the&nbsp;zip&nbsp;codes&nbsp;that&nbsp;make&nbsp;up&nbsp;your&nbsp;territory&nbsp;and&nbsp;then&nbsp;add&nbsp;this&nbsp;as&nbsp;a&nbsp;new&nbsp;feature&nbsp;on&nbsp;an&nbsp;InMemoryLayer&nbsp;which&nbsp;would&nbsp;allow&nbsp;you&nbsp;to&nbsp;label&nbsp;it&nbsp;just&nbsp;like&nbsp;a&nbsp;regular&nbsp;shapefile&nbsp;by&nbsp;setting&nbsp;the&nbsp;style&nbsp;for&nbsp;the&nbsp;zoom&nbsp;level(s).&nbsp;To&nbsp;get&nbsp;the&nbsp;all&nbsp;the&nbsp;zip&nbsp;code&nbsp;features&nbsp;for&nbsp;a&nbsp;given&nbsp;territory&nbsp;you&nbsp;could&nbsp;call&nbsp;the&nbsp;QueryTools.GetFeaturesByColumnValue&nbsp;method&nbsp;and&nbsp;this&nbsp;will&nbsp;return&nbsp;you&nbsp;all&nbsp;of&nbsp;the&nbsp;zip&nbsp;code&nbsp;shapes&nbsp;for&nbsp;that&nbsp;territory.&nbsp;&nbsp;Then&nbsp;once&nbsp;you&nbsp;have&nbsp;this&nbsp;collection&nbsp;of&nbsp;features&nbsp;you&nbsp;would&nbsp;want&nbsp;to&nbsp;use&nbsp;the&nbsp;ExtentHelper.GetBoundingBoxOfItems&nbsp;method&nbsp;to&nbsp;get&nbsp;the&nbsp;BoundingBox&nbsp;shape&nbsp;containing&nbsp;all&nbsp;these&nbsp;features.&nbsp;&nbsp;Finally&nbsp;once&nbsp;you&nbsp;have&nbsp;the&nbsp;bounding&nbsp;box&nbsp;feature&nbsp;you&nbsp;will&nbsp;want&nbsp;to&nbsp;create&nbsp;an&nbsp;InMemoryFeatureLayer&nbsp;to&nbsp;hold&nbsp;it&nbsp;and&nbsp;then&nbsp;add&nbsp;the&nbsp;new&nbsp;layer&nbsp;to&nbsp;the&nbsp;map&nbsp;so&nbsp;it&nbsp;will&nbsp;render&nbsp;your&nbsp;label.&nbsp;&nbsp;Below&nbsp;is&nbsp;what&nbsp;the&nbsp;code&nbsp;would&nbsp;look&nbsp;like&nbsp;to&nbsp;accomplish&nbsp;this:  
&nbsp;  
`            Collection<Feature> myFeatures;             //Get all the zip code features for a given territory            myFeatures = mapShapeLayer.QueryTools.GetFeaturesByColumnValue("Territory", "Territory1");            //Create an InMemoryLaer to store are new feature that we will base our labeling on.            InMemoryFeatureLayer TerritoryLabelLayer = new InMemoryFeatureLayer();            //Add a column to the InMemoryFeatureLayer so we can store the value to base the label on.            TerritoryLabelLayer.Columns.Add(new FeatureSourceColumn("Label"));            //Get the bounding box of all the zip code features in the territory            Feature myTerritoryBoundingBox = new Feature(ExtentHelper.GetBoundingBoxOfItems(myFeatures));            //Set how I want to albel the Territory            myTerritoryBoundingBox.ColumnValues.Add("Label", "My Territory Label");            //Add the new feature to the InMemoryFeature Layer.            TerritoryLabelLayer.EditTools.BeginTransaction();            TerritoryLabelLayer.EditTools.Add(myTerritoryBoundingBox);            TerritoryLabelLayer.EditTools.CommitTransaction();            //Setup the Text Style to do the actual labeling            TerritoryLabelLayer.ZoomLevelSet.ZoomLevel12.DefaultTextStyle = TextStyles.CreateSimpleTextStyle("Label", "Arial", 8, DrawingFontStyles.Italic, GeoColor.StandardColors.Black, 3, 3);            //Add Your Territory Label Layer to the overlay so it will render (Make sure you add it after your zip code layer otherwise it will be covered up).            MyOverlay.Layers.Add(TerritoryLabelLayer);`

If&nbsp;you&nbsp;don't&nbsp;want&nbsp;the&nbsp;label&nbsp;to&nbsp;pan&nbsp;with&nbsp;the&nbsp;map&nbsp;then&nbsp;you&nbsp;would&nbsp;want&nbsp;to&nbsp;look&nbsp;at&nbsp;adding&nbsp;your&nbsp;own&nbsp;AdornmentLayer&nbsp;that&nbsp;would&nbsp;act&nbsp;like&nbsp;a&nbsp;title&nbsp;for&nbsp;the&nbsp;map&nbsp;and&nbsp;always&nbsp;be&nbsp;in&nbsp;a&nbsp;fixed&nbsp;place.  
  
I&nbsp;hope&nbsp;this&nbsp;code&nbsp;helps,&nbsp;but&nbsp;please&nbsp;let&nbsp;us&nbsp;know&nbsp;if&nbsp;you&nbsp;have&nbsp;any&nbsp;questions&nbsp;or&nbsp;run&nbsp;into&nbsp;any&nbsp;problems.  
  
Thanks!

---

<div class="post-metadata">

**Author:** ![shwe](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/s/ed8c4c/32.png) [@shwe](https://community.thinkgeo.com/u/shwe)\
**Post date:** [December 13, 2011, 1:27pm UTC](https://community.thinkgeo.com/t/fixed-text-on-a-layer/6062/3 "2011-12-13T13:27:36Z")

</div>

Thank&nbsp;you&nbsp;Clint.

It&nbsp;works.

shwe

---

<div class="post-metadata">

**Author:** ![Clint](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/c/da6949/32.png) [@Clint](https://community.thinkgeo.com/u/Clint)\
**Post date:** [December 13, 2011, 2:11pm UTC](https://community.thinkgeo.com/t/fixed-text-on-a-layer/6062/4 "2011-12-13T14:11:30Z")

</div>

You&nbsp;are&nbsp;welcome&nbsp;and&nbsp;it&nbsp;worked&nbsp;for&nbsp;you!
