<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to programmatically rotate map in a map frame on layout? in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-programmatically-rotate-map-in-a-map-frame/m-p/1184662#M8266</link>
    <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;I'm trying to make a rotated map ona layout - i.e. not rotate the map frame itself, but rather the map inside it (since I want it to be on a "landscape" page and some of my data extents are "thin" and long).&lt;/P&gt;&lt;P&gt;I figured out how this can be achieved manually (either by choosing Properties of this map in "Contents" view):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GISTaldor_0-1655820255986.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/43931i2CE4D500667DEF50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GISTaldor_0-1655820255986.png" alt="GISTaldor_0-1655820255986.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;or Map Frame properties on the layout:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GISTaldor_1-1655820358804.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/43932i5F234A99955EE8BA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GISTaldor_1-1655820358804.png" alt="GISTaldor_1-1655820358804.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Both settings are actually the same one (at least it seems so) and when one is changed, another is also updated automatically.&lt;/P&gt;&lt;P&gt;Here's an example of a map rotated 90 degrees, so that its corresponding north arrow points to the left edge of the layout.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GISTaldor_2-1655820751775.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/43934iDC8574FDFF38C85D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GISTaldor_2-1655820751775.png" alt="GISTaldor_2-1655820751775.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, my question is: how can I do this programmatically. I couldn't find any property/method for that.&lt;/P&gt;&lt;P data-unlink="true"&gt;If I use &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/index.html#topic16074.html" target="_self"&gt;this&amp;nbsp;&lt;/A&gt;- the map frame itself (i.e. the layout element) is rotated, which isn't what I want.&lt;/P&gt;&lt;P data-unlink="true"&gt;And I need the map frame to remain as it is and the map inside it to rotate.&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jun 2022 14:13:06 GMT</pubDate>
    <dc:creator>GISTaldor</dc:creator>
    <dc:date>2022-06-21T14:13:06Z</dc:date>
    <item>
      <title>How to programmatically rotate map in a map frame on layout?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-programmatically-rotate-map-in-a-map-frame/m-p/1184662#M8266</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;I'm trying to make a rotated map ona layout - i.e. not rotate the map frame itself, but rather the map inside it (since I want it to be on a "landscape" page and some of my data extents are "thin" and long).&lt;/P&gt;&lt;P&gt;I figured out how this can be achieved manually (either by choosing Properties of this map in "Contents" view):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GISTaldor_0-1655820255986.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/43931i2CE4D500667DEF50/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GISTaldor_0-1655820255986.png" alt="GISTaldor_0-1655820255986.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;or Map Frame properties on the layout:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GISTaldor_1-1655820358804.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/43932i5F234A99955EE8BA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GISTaldor_1-1655820358804.png" alt="GISTaldor_1-1655820358804.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Both settings are actually the same one (at least it seems so) and when one is changed, another is also updated automatically.&lt;/P&gt;&lt;P&gt;Here's an example of a map rotated 90 degrees, so that its corresponding north arrow points to the left edge of the layout.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="GISTaldor_2-1655820751775.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/43934iDC8574FDFF38C85D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="GISTaldor_2-1655820751775.png" alt="GISTaldor_2-1655820751775.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now, my question is: how can I do this programmatically. I couldn't find any property/method for that.&lt;/P&gt;&lt;P data-unlink="true"&gt;If I use &lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/index.html#topic16074.html" target="_self"&gt;this&amp;nbsp;&lt;/A&gt;- the map frame itself (i.e. the layout element) is rotated, which isn't what I want.&lt;/P&gt;&lt;P data-unlink="true"&gt;And I need the map frame to remain as it is and the map inside it to rotate.&lt;/P&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;P data-unlink="true"&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 14:13:06 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-programmatically-rotate-map-in-a-map-frame/m-p/1184662#M8266</guid>
      <dc:creator>GISTaldor</dc:creator>
      <dc:date>2022-06-21T14:13:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to programmatically rotate map in a map frame on layout?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-programmatically-rotate-map-in-a-map-frame/m-p/1184736#M8268</link>
      <description>&lt;P&gt;This will get a lot easier at 3.0 (which will be released on Thurs). Display constraints, at 3.0 can be set using a "GetAutoCamera()/SetAutoCamera(autoCamera)" method pair. Display constraints will be explained here:&amp;nbsp;&lt;A href="https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Layouts#map-frame-display-constraints" target="_self"&gt;https://github.com/esri/arcgis-pro-sdk/wiki/ProConcepts-Layouts#map-frame-display-constraints&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This link will be &lt;STRONG&gt;broken&lt;/STRONG&gt; until Thursday because it has not been released yet.&lt;/P&gt;&lt;P&gt;In the interim, u can use this code. Be advised that not all map frames can be rotated, especially if the map frame is linked or is a map series frame. Generally speaking, if the current display constraint is any of these then it should be fine. I did add a some defensive code to check for the most obvious conditions (such as 3D).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="display_constraint.png" style="width: 161px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/43950i8973C8DFBA69CE86/image-size/large?v=v2&amp;amp;px=999" role="button" title="display_constraint.png" alt="display_constraint.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal class RotateTheMap : Button {

  private static double _angle = 0;

  protected override void OnClick() {

   if (LayoutView.Active == null)
    return;

   var layout = LayoutView.Active.Layout;
   var mapFrame = layout.Elements.OfType&amp;lt;MapFrame&amp;gt;().FirstOrDefault();
   if (mapFrame == null)
    return;

   QueuedTask.Run(() =&amp;gt; {

    var def = mapFrame.GetDefinition() as CIMMapFrame;
    if (def.View.ViewingMode != MapViewingMode.Map)
     return; //2D only

    _angle -= 15;//Counter-clockwise
    if (_angle &amp;lt; -345) _angle = 0;

    var autoCamera = def.AutoCamera;
    if (autoCamera == null)
    {
     //unusual
     def.AutoCamera = new CIMAutoCamera()
     {
      Camera = new CIMViewCamera(),
      AutoCameraType = AutoCameraType.Extent
     };
    }
    else if (autoCamera.Source != AutoCameraSource.None &amp;amp;&amp;amp;
        autoCamera.Source != AutoCameraSource.Fixed)
    {
     return;
    }

    def.View.Camera.Heading = _angle;
    mapFrame.SetDefinition(def);
   });
  }
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2022 16:23:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-programmatically-rotate-map-in-a-map-frame/m-p/1184736#M8268</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2022-06-21T16:23:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to programmatically rotate map in a map frame on layout?</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-programmatically-rotate-map-in-a-map-frame/m-p/1185016#M8278</link>
      <description>&lt;P&gt;Hi.&lt;/P&gt;&lt;P&gt;Thanks for the code sample, it really helped.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2022 11:26:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/how-to-programmatically-rotate-map-in-a-map-frame/m-p/1185016#M8278</guid>
      <dc:creator>GISTaldor</dc:creator>
      <dc:date>2022-06-22T11:26:44Z</dc:date>
    </item>
  </channel>
</rss>

