# Rotating MapShapeLayers

**URL:** <https://community.thinkgeo.com/t/rotating-mapshapelayers/1529>\
**Category:** WinForms\
**Created:** [December 7, 2010, 11:05am UTC](https://community.thinkgeo.com/t/rotating-mapshapelayers/1529 "2010-12-07T11:05:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Allen](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/bbce88/32.png) [@Allen](https://community.thinkgeo.com/u/Allen)\
**Post date:** [December 7, 2010, 11:05am UTC](https://community.thinkgeo.com/t/rotating-mapshapelayers/1529/1 "2010-12-07T11:05:13Z")

</div>

I've&nbsp;been&nbsp;making&nbsp;great&nbsp;use&nbsp;of&nbsp;MapShapeLayers&nbsp;for&nbsp;some&nbsp;items&nbsp;which&nbsp;are&nbsp;highly&nbsp;dynamic&nbsp;in&nbsp;styling.&nbsp;&nbsp;Now&nbsp;I'm&nbsp;moving&nbsp;on&nbsp;to&nbsp;working&nbsp;with&nbsp;the&nbsp;map&nbsp;rotation,&nbsp;and&nbsp;I've&nbsp;discovered,&nbsp;much&nbsp;to&nbsp;my&nbsp;dismay,&nbsp;that&nbsp;it&nbsp;appears&nbsp;that&nbsp;MapShapeLayers&nbsp;don't&nbsp;seem&nbsp;to&nbsp;support&nbsp;rotation.&nbsp;&nbsp;This&nbsp;is&nbsp;a&nbsp;considerable&nbsp;problem.&nbsp;&nbsp;I&nbsp;suspect&nbsp;most&nbsp;of&nbsp;what&nbsp;I'm&nbsp;doing&nbsp;with&nbsp;MapShapeLayers&nbsp;could&nbsp;be&nbsp;done&nbsp;with&nbsp;InMemoryLayers&nbsp;and&nbsp;lots&nbsp;of&nbsp;dynamic&nbsp;ValueStyles,&nbsp;but&nbsp;that&nbsp;sounds&nbsp;really&nbsp;nasty.&nbsp;&nbsp;In&nbsp;the&nbsp;MapShapeLayer&nbsp;documentation&nbsp;there&nbsp;is&nbsp;a&nbsp;suggestion&nbsp;that&nbsp;it&nbsp;might&nbsp;be&nbsp;improved&nbsp;to&nbsp;the&nbsp;level&nbsp;of&nbsp;functionality&nbsp;of&nbsp;other&nbsp;layers:

"Ideally&nbsp;I&nbsp;would&nbsp;want&nbsp;to&nbsp;make&nbsp;this&nbsp;inherit&nbsp;from&nbsp;the&nbsp;FeatureLayer&nbsp;so&nbsp;you&nbsp;could&nbsp;do&nbsp;spatial&nbsp;queries.&nbsp;In&nbsp;the&nbsp;interests&nbsp;of&nbsp;time&nbsp;I&nbsp;inherited&nbsp;from&nbsp;the&nbsp;Layer&nbsp;to&nbsp;make&nbsp;things&nbsp;simple&nbsp;and&nbsp;show&nbsp;the&nbsp;point&nbsp;of&nbsp;how&nbsp;easy&nbsp;it&nbsp;is&nbsp;to&nbsp;extend&nbsp;Map&nbsp;Suite.&nbsp;When&nbsp;we&nbsp;roll&nbsp;this&nbsp;into&nbsp;the&nbsp;main&nbsp;product&nbsp;we&nbsp;may&nbsp;create&nbsp;a&nbsp;FeatureSource&nbsp;and&nbsp;FeatureLayer.&nbsp;"

Is&nbsp;there&nbsp;any&nbsp;chance&nbsp;of&nbsp;getting&nbsp;a&nbsp;FeatureSource&nbsp;added&nbsp;to&nbsp;MapShapeLayer&nbsp;so&nbsp;it&nbsp;supports&nbsp;rotation?&nbsp;&nbsp;(I&nbsp;realize&nbsp;it&nbsp;may&nbsp;not&nbsp;be&nbsp;that&nbsp;simple.)&nbsp;&nbsp;Any&nbsp;other&nbsp;suggestions&nbsp;of&nbsp;how&nbsp;to&nbsp;do&nbsp;this&nbsp;so&nbsp;that&nbsp;the&nbsp;features&nbsp;can&nbsp;be&nbsp;rotated&nbsp;and&nbsp;have&nbsp;some&nbsp;styling&nbsp;flexibility?

Thanks!

Allen&nbsp;Huber

&nbsp;

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [December 7, 2010, 11:54pm UTC](https://community.thinkgeo.com/t/rotating-mapshapelayers/1529/2 "2010-12-07T23:54:25Z")

</div>

Allen,&nbsp;  
&nbsp;&nbsp;  
&nbsp;I&nbsp;think&nbsp;there&nbsp;is&nbsp;no&nbsp;best&nbsp;way&nbsp;to&nbsp;rotate&nbsp;features,&nbsp;hope&nbsp;I&nbsp;can&nbsp;assist&nbsp;you&nbsp;to&nbsp;accomplish.&nbsp;First&nbsp;I&nbsp;want&nbsp;to&nbsp;answer&nbsp;your&nbsp;questions.&nbsp;  
&nbsp;&nbsp;  
&nbsp;FeatureSource&nbsp;has&nbsp;a&nbsp;method&nbsp;called&nbsp;GetAllFeatures&nbsp;that&nbsp;will&nbsp;return&nbsp;all&nbsp;features&nbsp;belongs&nbsp;to&nbsp;it,&nbsp;and&nbsp;then&nbsp;you&nbsp;can&nbsp;create&nbsp;MapShape&nbsp;by&nbsp;feature&nbsp;and&nbsp;a&nbsp;zoomllevelset&nbsp;with&nbsp;styles.&nbsp;Each&nbsp;feature&nbsp;can&nbsp;convert&nbsp;to&nbsp;a&nbsp;Shape&nbsp;by&nbsp;using&nbsp;GetShape&nbsp;method,&nbsp;and&nbsp;each&nbsp;shape&nbsp;is&nbsp;inherit&nbsp;from&nbsp;BaseShape&nbsp;which&nbsp;has&nbsp;Rotate&nbsp;method.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Let&nbsp;you&nbsp;know&nbsp;when&nbsp;you&nbsp;have&nbsp;more&nbsp;questions.&nbsp;  
&nbsp;&nbsp;  
&nbsp;James&nbsp;

---

<div class="post-metadata">

**Author:** ![Allen](https://community.thinkgeo.com/letter_avatar_proxy/v4/letter/a/bbce88/32.png) [@Allen](https://community.thinkgeo.com/u/Allen)\
**Post date:** [December 8, 2010, 4:36am UTC](https://community.thinkgeo.com/t/rotating-mapshapelayers/1529/3 "2010-12-08T04:36:33Z")

</div>

Hi&nbsp;again&nbsp;James,&nbsp;  
&nbsp;&nbsp;  
&nbsp;Let&nbsp;me&nbsp;clarify&nbsp;my&nbsp;situation:&nbsp;I&nbsp;am&nbsp;NOT&nbsp;trying&nbsp;to&nbsp;rotate&nbsp;the&nbsp;features&nbsp;in&nbsp;a&nbsp;MapShapeLayer&nbsp;(although&nbsp;I&nbsp;may&nbsp;have&nbsp;wanted&nbsp;to&nbsp;do&nbsp;this&nbsp;some&nbsp;day).&nbsp;&nbsp;I&nbsp;have&nbsp;a&nbsp;map&nbsp;with&nbsp;a&nbsp;number&nbsp;of&nbsp;static&nbsp;layers&nbsp;from&nbsp;SQL&nbsp;Server&nbsp;and&nbsp;a&nbsp;number&nbsp;of&nbsp;layers&nbsp;(both&nbsp;MapShapeLayers&nbsp;and&nbsp;InMemoryFeatureLayers)&nbsp;that&nbsp;contain&nbsp;temporary&nbsp;items.&nbsp;&nbsp;Our&nbsp;product&nbsp;has&nbsp;an&nbsp;option&nbsp;where&nbsp;the&nbsp;map&nbsp;rotates&nbsp;in&nbsp;the&nbsp;direction&nbsp;of&nbsp;a&nbsp;vehicle’s&nbsp;travel,&nbsp;so&nbsp;I&nbsp;am&nbsp;rotating&nbsp;the&nbsp;ENTIRE&nbsp;MAP.&nbsp;&nbsp;I&nbsp;do&nbsp;this,&nbsp;of&nbsp;course,&nbsp;by&nbsp;assigning&nbsp;a&nbsp;RotationProjection&nbsp;to&nbsp;the&nbsp;FeatureSource&nbsp;of&nbsp;the&nbsp;layers.&nbsp;&nbsp;However,&nbsp;MapShapeLayer&nbsp;doesn’t&nbsp;have&nbsp;a&nbsp;FeatureSource&nbsp;to&nbsp;apply&nbsp;the&nbsp;RotationProjection&nbsp;to,&nbsp;so&nbsp;my&nbsp;background&nbsp;map&nbsp;layers&nbsp;(SQL&nbsp;Server&nbsp;and&nbsp;InMemory&nbsp;layers)&nbsp;rotate&nbsp;but&nbsp;all&nbsp;the&nbsp;features&nbsp;I&nbsp;put&nbsp;in&nbsp;the&nbsp;MapShapeLayer&nbsp;obviously&nbsp;don’t,&nbsp;which&nbsp;is&nbsp;essentially&nbsp;makes&nbsp;MapShapeLayer&nbsp;of&nbsp;no&nbsp;value&nbsp;to&nbsp;us.&nbsp;  
&nbsp;&nbsp;  
&nbsp;Let&nbsp;me&nbsp;ask&nbsp;my&nbsp;question&nbsp;again:&nbsp;is&nbsp;there&nbsp;any&nbsp;chance&nbsp;the&nbsp;MapShapeLayer&nbsp;can&nbsp;be&nbsp;enhanced&nbsp;to&nbsp;the&nbsp;point&nbsp;of&nbsp;being&nbsp;compatible&nbsp;with&nbsp;the&nbsp;other&nbsp;layer&nbsp;types&nbsp;when&nbsp;rotating&nbsp;the&nbsp;map?&nbsp;&nbsp;If&nbsp;not,&nbsp;I&nbsp;will&nbsp;have&nbsp;to&nbsp;find&nbsp;another&nbsp;way&nbsp;with&nbsp;InMemoryLayers.&nbsp;&nbsp;(I&nbsp;apologize&nbsp;for&nbsp;any&nbsp;confusion&nbsp;I&nbsp;may&nbsp;have&nbsp;caused&nbsp;by&nbsp;stating&nbsp;just&nbsp;“rotation”…I&nbsp;should&nbsp;have&nbsp;been&nbsp;clearer&nbsp;between&nbsp;individual&nbsp;feature&nbsp;rotation&nbsp;and&nbsp;overall&nbsp;map&nbsp;rotation.)&nbsp;  
&nbsp;&nbsp;  
&nbsp;Thanks,&nbsp;  
&nbsp;Allen

---

<div class="post-metadata">

**Author:** ![ThinkGeo](https://community.thinkgeo.com/user_avatar/community.thinkgeo.com/thinkgeo/32/25029_2.png) [@ThinkGeo](https://community.thinkgeo.com/u/ThinkGeo)\
**Post date:** [December 8, 2010, 8:50am UTC](https://community.thinkgeo.com/t/rotating-mapshapelayers/1529/4 "2010-12-08T08:50:17Z")

</div>

Allen,

Thanks&nbsp;for&nbsp;your&nbsp;post&nbsp;and&nbsp;questions.  
&nbsp;  
I&nbsp;think&nbsp;James’&nbsp;idea&nbsp;is&nbsp;possible,&nbsp;I&nbsp;did&nbsp;a&nbsp;simple&nbsp;test&nbsp;against&nbsp;the&nbsp;rotation&nbsp;of&nbsp;MapShapeLayer,&nbsp;following&nbsp;is&nbsp;the&nbsp;code&nbsp;snippet&nbsp;showing&nbsp;a&nbsp;40&nbsp;degree&nbsp;rotation&nbsp;on&nbsp;every&nbsp;map&nbsp;click,&nbsp;hope&nbsp;it&nbsp;helps.  
&nbsp;  
`private void DisplayMap_Load(object sender, EventArgs e)        {            winformsMap1.MapUnit = GeographyUnit.DecimalDegree;            winformsMap1.BackgroundOverlay.BackgroundBrush = new GeoSolidBrush(GeoColor.GeographicColors.ShallowOcean);             // Add the mapShapeLayer to the MapEngine            MapShapeLayer mapShapeLayer = new MapShapeLayer();             MapShape mapShape1 = new MapShape(new Feature(-104, 42));            mapShape1.ZoomLevels.ZoomLevel01.DefaultPointStyle = new PointStyle(new GeoImage(@"..\..\SampleData\Data\China.png"));            mapShape1.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;            mapShapeLayer.MapShapes.Add("1", mapShape1);             MapShape mapShape2 = new MapShape(new Feature(104, 39));            mapShape2.ZoomLevels.ZoomLevel01.DefaultPointStyle = new PointStyle(new GeoImage(@"..\..\SampleData\Data\China.png"));            mapShape2.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;            mapShapeLayer.MapShapes.Add("2", mapShape2);             Feature feature3 = new Feature(new RectangleShape(40, 60, 60, 40));            MapShape mapShape3 = new MapShape(feature3);            mapShape3.ZoomLevels.ZoomLevel01.DefaultAreaStyle = AreaStyles.Forest1;            mapShape3.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;            mapShapeLayer.MapShapes.Add("3", mapShape3);             BaseShape shape = new PointShape(-71, -52).GetShortestLineTo(new PointShape(38, 8), GeographyUnit.DecimalDegree);            MapShape mapShape4 = new MapShape(new Feature(shape));            mapShape4.ZoomLevels.ZoomLevel01.DefaultLineStyle = LineStyles.ContestedBorder2;            mapShape4.ZoomLevels.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;            mapShapeLayer.MapShapes.Add("4", mapShape4);                        LayerOverlay layerOVerlay = new LayerOverlay();            layerOVerlay.Layers.Add("mapShapeLayer", mapShapeLayer);            winformsMap1.Overlays.Add("layerOVerlay", layerOVerlay);             winformsMap1.CurrentExtent = new RectangleShape(65, 30, 95, 15);             winformsMap1.MapClick += new EventHandler<MapClickWinformsMapEventArgs>(winformsMap1_MapClick);            winformsMap1.Refresh();        }         void winformsMap1_MapClick(object sender, MapClickWinformsMapEventArgs e)        {            RotationProjection rotationProjection = new RotationProjection(40);            rotationProjection.Open();             LayerOverlay layerOverlay = (LayerOverlay)winformsMap1.Overlays["layerOVerlay"];            MapShapeLayer mapShapeLayer = (MapShapeLayer) layerOverlay.Layers[0];            foreach (MapShape mapShape in mapShapeLayer.MapShapes.Values)            {               mapShape.Feature = rotationProjection.ConvertToExternalProjection(mapShape.Feature);            }             winformsMap1.Refresh(layerOverlay);        }`  
&nbsp;  
Any&nbsp;more&nbsp;questions&nbsp;or&nbsp;concerns&nbsp;please&nbsp;do&nbsp;not&nbsp;hesitate&nbsp;to&nbsp;let&nbsp;me&nbsp;know.  
&nbsp;  
Thanks.  
&nbsp;  
Yale
