move the scalebar

3291
7
04-13-2011 05:01 AM
philippschnetzer
Occasional Contributor III
I have done this before but for the life of me cannot find where/how I can reposition the scalebar.

I am using viewer 2.2.

Thanks!
Tags (2)
0 Kudos
7 Replies
RobertScheitlin__GISP
MVP Emeritus
Phillip,

The scale bar is now part of the navigation control if you are using that.

<widget right="10"  top="50"    config="widgets/Navigation/NavigationWidget.xml" url="widgets/Navigation/NavigationWidget.swf"/>
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Phillip,

   All you need to do is add this to the default.css
The important part is setting NaN for the values that are not used

esri|ScaleBar
{
 right: 10;
 bottom: 20;
 left: NaN;
 top: NaN;
}
0 Kudos
AndrewNiederhauser1
New Contributor III

Hi Robert,

I am looking to move the scale bar to the right as well so that it doesn't interfere with the Advanced Search Results tab in the lower-left corner. However, in the main application folder, I don't see a default.css file - only a default.htm file.

In the default.htm file there are the following lines of code that reference css....

        <style type="text/css" media="screen">

            html, body  { height:100%; }

            body { margin:0; padding:0; overflow:auto; text-align:center;

                   background-color: #ffffff; }

            object:focus { outline:none; }

            #flashContent { display:none; }

        </style>

Is this where I would insert the syntax you mentioned above to Phillip or am I looking in the wrong spot? 

  1. esri|ScaleBar 
  2. right: 10; 
  3. bottom: 20; 
  4. left: NaN; 
  5. top: NaN; 

Thanks,

Andrew

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Andrew,

   This fix is for those that are using the Viewers source code. It sounds like you are using a compiled version of the viewer and thus this change is not available to you.

0 Kudos
AndrewNiederhauser1
New Contributor III

Good to know. Do you have any suggestions, using the compiled Viewer, so that the scale bar and the Search Results tab from your Advanced Search data grid don't both show up in the lower-left corner on top of each other?

Thanks again,

Andrew

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Andrew,

   No, no suggestions for the compiled viewer.

0 Kudos
EstherColero
New Contributor III
Hi,

You can try something like this to get the scalebar, but when I try to change the position it disappears 😞

public static function getScaleBar(map:Map):ScaleBar
        {
            var pDisplayObject:DisplayObjectContainer = null;
            var pScaleBar:ScaleBar = null;
            for (var i:int = 0; pScaleBar == null && i < map.numChildren; i++)
            {
                pScaleBar = getScaleBarRecursive(map.getChildAt(i) as DisplayObjectContainer);
            }
            
            return pScaleBar;
        }
        
        private static function getScaleBarRecursive(pDisplayObject:DisplayObjectContainer):ScaleBar
        {
            var pScaleBar:ScaleBar = null;
            
            if (pDisplayObject == null)
            {
                return null;
            }
                
            if (pDisplayObject is ScaleBar)
            {
                pScaleBar = pDisplayObject as ScaleBar;
            }
            
            for (var i:int = 0; pScaleBar == null && i < pDisplayObject.numChildren; i++)
            {
                pScaleBar = getScaleBarRecursive(pDisplayObject.getChildAt(i) as DisplayObjectContainer);
            }
            return pScaleBar; 
        }


I hope at least be a starting point.

Regards
Esther
0 Kudos