How to add the ???scale text??? on the map?

2323
6
Jump to solution
12-27-2012 10:20 PM
JamalNUMAN
Legendary Contributor
How to add the ???scale text??? on the map?

I???m wondering if there is a way to add the ???scale text??? on the map such that the scale of the map is shown at each zoom.

[ATTACH=CONFIG]20238[/ATTACH], [ATTACH=CONFIG]20239[/ATTACH]


In particular cases, the ???scale bar??? is not sufficient to identify all the required issue and thus the ???scale text??? is needed all the time. It is very basic element for any map.



Thank you


Best

Jamal
----------------------------------------
Jamal Numan
Geomolg Geoportal for Spatial Information
Ramallah, West Bank, Palestine
0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable
Original User: ericv

Jamal,
I've added this to our app, but we are not using the Application Builder (we use Flash Builder)

In the mxml file (CoordinateWidget.mxml), there is a map_mouseMoveHandler function.

In the "original" file, there is a line in this function that reads:

                coords.text = m_func(mapPoint);

This needs to be changed to:

                coords.text = m_func(mapPoint)+"          Scale 1:" + map.scale.toString();

Not sure this will help you much unless you have FB.
Eric V
Gurnee, IL

View solution in original post

0 Kudos
6 Replies
by Anonymous User
Not applicable
Original User: ericv

Jamal,
I've added this to our app, but we are not using the Application Builder (we use Flash Builder)

In the mxml file (CoordinateWidget.mxml), there is a map_mouseMoveHandler function.

In the "original" file, there is a line in this function that reads:

                coords.text = m_func(mapPoint);

This needs to be changed to:

                coords.text = m_func(mapPoint)+"          Scale 1:" + map.scale.toString();

Not sure this will help you much unless you have FB.
Eric V
Gurnee, IL
0 Kudos
ronaldmcfarlane
Occasional Contributor
As EricV stated, you will need FashBuilder to modify the CoordinateWidget.mxml file to add the scale value.  I use a bit more code than EricV does, because I want the scale to be an integer value and to change as the various mouse actions change.  Below are three code fragments that may help.  (I use comments to help me track changes and give me a place to start when the next version of a widget or Flex is released.)  Hopefully this helps.  (Note: the code below is for flex viewer 3.1 and FlashBuilder 4.7.

// - Start modification - //
[Bindable]
private var mapScale:int;
// - End modification - //



map.addEventListener(MouseEvent.MOUSE_MOVE, map_mouseMoveHandler);
// - Start modification - //
map.addEventListener(MouseEvent.MOUSE_WHEEL, map_mouseMoveHandler);
map.addEventListener(MouseEvent.DOUBLE_CLICK, map_mouseMoveHandler);
// - end modification - //



private function map_mouseMoveHandler(event:MouseEvent):void
{
// - Start modification - //
var nf:spark.formatters.NumberFormatter = new spark.formatters.NumberFormatter
const mapPoint:MapPoint = map.toMapFromStage(event.stageX, event.stageY);
mapScale = Number(map.scale);
coords.text = m_func(mapPoint) + "     Scale 1:" + mapScale;
// - end modification - //
}
0 Kudos
by Anonymous User
Not applicable
Original User: Jamal432@gmail.com

As EricV stated, you will need FashBuilder to modify the CoordinateWidget.mxml file to add the scale value.  I use a bit more code than EricV does, because I want the scale to be an integer value and to change as the various mouse actions change.  Below are three code fragments that may help.  (I use comments to help me track changes and give me a place to start when the next version of a widget or Flex is released.)  Hopefully this helps.  (Note: the code below is for flex viewer 3.1 and FlashBuilder 4.7.

// - Start modification - //
[Bindable]
private var mapScale:int;
// - End modification - //



map.addEventListener(MouseEvent.MOUSE_MOVE, map_mouseMoveHandler);
// - Start modification - //
map.addEventListener(MouseEvent.MOUSE_WHEEL, map_mouseMoveHandler);
map.addEventListener(MouseEvent.DOUBLE_CLICK, map_mouseMoveHandler);
// - end modification - //



private function map_mouseMoveHandler(event:MouseEvent):void
{
// - Start modification - //
var nf:spark.formatters.NumberFormatter = new spark.formatters.NumberFormatter
const mapPoint:MapPoint = map.toMapFromStage(event.stageX, event.stageY);
mapScale = Number(map.scale);
coords.text = m_func(mapPoint) + "     Scale 1:" + mapScale;
// - end modification - //
}
[ATTACH=CONFIG]20271[/ATTACH]

Thank you Eric and Ronald for the help.

�?� I searched all my C drive but couldn�??t find the �??CoordinateWidget.mxml�?�


�?� I�??ve Adobe Flash Builder 4 installed
�?� I�??ve the ArcGIS Viewer for Flex 3.1 installed

Could you please indicate how can I proceed now?
0 Kudos
ronaldmcfarlane
Occasional Contributor
You will need to download the source code and API for Flex.  The following link will walk you through the process: http://resources.arcgis.com/en/help/flex-viewer/concepts/index.html#/Getting_started_for_developers/...
0 Kudos
by Anonymous User
Not applicable
Original User: Jamal432@gmail.com

You will need to download the source code and API for Flex.  The following link will walk you through the process: http://resources.arcgis.com/en/help/flex-viewer/concepts/index.html#/Getting_started_for_developers/...


Many thanks Ronald.

I�??ll see if I can manage this issue knowing that I�??m not a developer! Should I be?

Best

Jamal
0 Kudos
EricVenden
Occasional Contributor II
If you can follow directions, you can do it Jamal.
0 Kudos