Dynamically Move Scalebar

2287
4
Jump to solution
07-20-2013 06:02 PM
GlenReid
New Contributor II
Is there a way to dynamically move the scalebar to another location?

Thanks,
Glen
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DasaPaddock
Esri Regular Contributor
Here's a sample that shows how to get the style and change it at runtime:

<?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">      <fx:Script>         <![CDATA[             private function updateScaleBarPostion(leftValue:Number):void             {                 var style:CSSStyleDeclaration = styleManager.getStyleDeclaration("com.esri.ags.components.ScaleBar");                 style.setStyle("left", leftValue);             }         ]]>     </fx:Script>      <s:controlBarContent>         <s:Button click="updateScaleBarPostion(200)" label="Move ScaleBar"/>         <s:Button click="updateScaleBarPostion(5)" label="Reset ScaleBar"/>     </s:controlBarContent>      <esri:Map level="3">         <esri:ArcGISTiledMapServiceLayer/>     </esri:Map>  </s:Application>

View solution in original post

0 Kudos
4 Replies
RhettZufelt
MVP Frequent Contributor
Not sure what you mean by dynamically, but this thread shows how to move the scale bar.

http://forums.arcgis.com/threads/59984-how-change-scalebar-position

R_
0 Kudos
GlenReid
New Contributor II
Thanks for the info Rhett.  I have seen that for positioning.

By dynamically -- I have the scalebar in the bottom left of the map.  A sliding panel moves over it and obscures it.  I'd like to be able to move the scalebar x pixels to the right when the panel is open, and put it back when the panel is closed.

Thanks,
Glen
0 Kudos
DasaPaddock
Esri Regular Contributor
Here's a sample that shows how to get the style and change it at runtime:

<?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">      <fx:Script>         <![CDATA[             private function updateScaleBarPostion(leftValue:Number):void             {                 var style:CSSStyleDeclaration = styleManager.getStyleDeclaration("com.esri.ags.components.ScaleBar");                 style.setStyle("left", leftValue);             }         ]]>     </fx:Script>      <s:controlBarContent>         <s:Button click="updateScaleBarPostion(200)" label="Move ScaleBar"/>         <s:Button click="updateScaleBarPostion(5)" label="Reset ScaleBar"/>     </s:controlBarContent>      <esri:Map level="3">         <esri:ArcGISTiledMapServiceLayer/>     </esri:Map>  </s:Application>
0 Kudos
GlenReid
New Contributor II
Thanks Dasa -- that was what I was looking for.
0 Kudos