Select to view content in your preferred language

Layer Rotation

1198
4
08-25-2010 10:06 AM
JamesPosnick
New Contributor
We have a customer who wants our flex viewer to shift to different extents (which show buildings) on a certain time interval. This part we have accomplished. They would also like the orientation of the map rotated for certain extents to keep a 90 deg orientation when viewing a building (the map would have to be rotated at different angles depending on the building). We were able to do this by rotating the layers in the map, sample code below:

   tLayer = myMap.layers[0];
   tLayer1.rotation = -54;


The problem now is that the resulting display crops the image at an angle approximately equal to the rotation. Has anyone had experience with rotation map displays in  Flash Builder 4? It appears silverlight might be able to do it, but not Flex.

thanks,

jim
Tags (2)
0 Kudos
4 Replies
ReneRubalcava
Esri Frequent Contributor
That is odd. Tried adding a rotation to this example http://help.arcgis.com/en/webapi/flex/samples/index.html?sample=TiledMap and it just doesn't like it. Can't even zoom to the layer properly.
0 Kudos
JonathanWatson
Emerging Contributor
Yes, we noticed a weird "jump" while panning when working with a rotated .mxd.  Other users are seeing the same:

"leads to a little jump while panning with dynamic layers. "
http://forums.esri.com/Thread.asp?c=158&f=2421&t=303470
0 Kudos
ReneRubalcava
Esri Frequent Contributor
One kind of hacky way to do would probably require that you extend the Map object.
Map has a UIComponent that appears to hold the layers.
You can rotate this object without rotating the nav tool/logo/scalebar. But, you'd need to reset the x/y and width/height of this UIComponent to avoid having it appear as though your map has been "trimmed". That's the part that would probably require you overriding the updateDisplayList method of Map to make those changes stick, at least for width and height.

You can test this out like this.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:esri="http://www.esri.com/2008/ags"
      pageTitle="A tiled map service">

 <fx:Script>
  <![CDATA[
   import mx.events.FlexEvent;

   protected function map_creationCompleteHandler(event:FlexEvent):void
   {
    var i:int = 0;
    var x:int = map.numChildren;
    for (i; i < x; i++) {
     if ( getQualifiedClassName(map.getChildAt(i)) == "mx.core::UIComponent") {
      // if you extent the Map, you could make a mapRotate field to hold this value
      map.getChildAt(i).rotation = -54;
      // positioning could be tricky depending on amout rotated
      map.getChildAt(i).x -= 50;
      map.getChildAt(i).y = map.height/2; 
      map.getChildAt(i).width = map.getChildAt(i).width * 2;
      map.getChildAt(i).height = map.getChildAt(i).height * 10;
     }
    }  
   }

  ]]>
 </fx:Script>

 <s:Group width="800" height="500">
  <esri:Map id="map" creationComplete="map_creationCompleteHandler(event)" >
   <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer"/>
  </esri:Map>
 </s:Group>
 
</s:Application>



I haven't gone any further than this to see if it would work. Maybe someone else has a simpler solution.

Now that I think about, you could hide the Nav/Scalebar/Logo, just rotate the whole map and then place a separate Nav/Scalebar outside the map. With the 2.0 API, we now have a ScaleBar object that you just set the map for and you're good to go. That's probably an easier solution than trying to fuss with extending the Map.

This method is probably easier.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:esri="http://www.esri.com/2008/ags"
      pageTitle="A tiled map service"
      xmlns:mx="library://ns.adobe.com/flex/mx">

 <s:layout>
  <s:VerticalLayout />
 </s:layout>
 <s:BorderContainer borderColor="0x000000">
  <s:Group id="grpMap"
     width="400"
     height="400">
   <esri:Map id="map"
       logoVisible="false"
       scaleBarVisible="false"
       x="-389"
       y="337"
       rotation="-54" width="1000" height="1000">
    <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer" />
   </esri:Map>
  </s:Group>
  <s:Scroller horizontalScrollPolicy="off"
     verticalScrollPolicy="off"
     viewport="{grpMap}" />
 </s:BorderContainer>
 <s:Group>
  <s:layout>
   <s:HorizontalLayout />
  </s:layout>
  <esri:Navigation map="{map}" />
  <esri:ScaleBar map="{map}"
        verticalCenter="0" />
 </s:Group>
</s:Application>


Still, to implement this, you'd probably want to do some math to size and position the map in the container just right. I'm not sure how simply turn Nav off in the Map either.
0 Kudos
DasaPaddock
Esri Regular Contributor
You can use this to turn off the Map's default Navigation component:
http://help.arcgis.com/en/webapi/flex/apiref/com/esri/ags/Map.html#zoomSliderVisible
0 Kudos