Select to view content in your preferred language

Scale Text instead of Scale Bar?

2796
5
Jump to solution
10-31-2012 09:51 AM
ionarawilson1
Deactivated User
Hi,

Is it possible to have in a web app a dynamic scale text (like 1:24,000) instead of a scale bar? If so, where can I find an example or code snippet? Thanks
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
AnthonyGiles
Honored Contributor
Ionara,

You need to use a number formatter, add a declaration

<fx:Declarations>  <mx:NumberFormatter id="numFormatter" precision="0" useThousandsSeparator="true"/> </fx:Declarations>


Then you can use the formatter on your number

<mx:Label text="1:{numFormatter.format(myMap.scale.toFixed(0))}"/>

Regards

Anthony

View solution in original post

0 Kudos
5 Replies
ionarawilson1
Deactivated User
Here is the answer

   <mx:Label text="Current map scale:" fontWeight="bold"/>
   <mx:Label text="1:{myMap.scale.toFixed(0)}"/>

Not sure how I can have the thousands separator on the scale so I will post another thread!
0 Kudos
AnthonyGiles
Honored Contributor
Ionara,

You need to use a number formatter, add a declaration

<fx:Declarations>  <mx:NumberFormatter id="numFormatter" precision="0" useThousandsSeparator="true"/> </fx:Declarations>


Then you can use the formatter on your number

<mx:Label text="1:{numFormatter.format(myMap.scale.toFixed(0))}"/>

Regards

Anthony
0 Kudos
ionarawilson1
Deactivated User
Thank you Anthony!
I created a formatter but instead of creating the label directly I created a function for the extentChange event of the map:

  private function updateScale():void
   {
    scaleText.text = myNumberFormatter.format(myMap.scale).toString();
   }




The scaleText is a label I created. I believe your version is better because it is much simpler!!! Thanks again!
0 Kudos
RhettZufelt
MVP Notable Contributor
I have it with my coordinates as per this thread:

http://forums.arcgis.com/threads/24407-Show-scale-with-coordinates

R_
0 Kudos
ionarawilson1
Deactivated User
Great link for adjusting the scale format Rhett ! Thanks!
0 Kudos