Select to view content in your preferred language

Show scale with coordinates

3805
21
02-23-2011 03:19 PM
DanielOchoa
Regular Contributor
The coordinate widget shows lat/long mouseover coordinates in the map, but can anyone advise on how to display map scale alongside the coordinates? Take a look here:

http://top100projects.ca/map/

or see the screen shot, attached.

Simple adjustment to the coordinate widget? Thanks!
Tags (2)
0 Kudos
21 Replies
Stefanobruscoli
Emerging Contributor
Hello
how I can fix the coodinates values to two decimal?
0 Kudos
RobertScheitlin__GISP
MVP Emeritus
Stefano,

   Look three posts above yours.
0 Kudos
EricAnderson
Emerging Contributor
To specifically address the coordinate display issue (not scale). Replace your substitute function with this:

 
private


function substitute(mapPoint:MapPoint):String


 
[LEFT]{

var nf2:NumberFormatter = new NumberFormatter(); 

nf2.precision = 2; 
return StringUtil.substitute(m_template, 
nf2.format(mapPoint.x), 
nf2.format(mapPoint.y)); 
}

[/LEFT]

 
 
0 Kudos
KennethLyons
Emerging Contributor
Is there anyway to display MGRS (Military Grid Reference System) at the bottom instead of DMS/mercator?
0 Kudos
MLowry
by
Frequent Contributor
Is there anyway to display MGRS (Military Grid Reference System) at the bottom instead of DMS/mercator?

Sure, the scale will be whatever the map's spatial reference is set to.
0 Kudos
ShaneCarey
Deactivated User
Is it possible to force the scale on the Coordinates widget to the same scale on the LODs on the Navigation widget?
Thanks
0 Kudos
RhettZufelt
MVP Notable Contributor
include this code:
map.addEventListener(MouseEvent.MOUSE_WHEEL, map_mouseMoveHandler);

directly under this line:
map.addEventListener(MouseEvent.MOUSE_MOVE, map_mouseMoveHandler);

and the scale will refresh when you zoom in and out.   Otherwise it is possible to zoom in and out and not have the scale refresh until you actually move the mouse pointer....


Works great, however also added this line under that
map.addEventListener(MouseEvent.DOUBLE_CLICK, map_mouseMoveHandler);
so that it gets updated on double-click to zoom in also.

R_
0 Kudos
RhettZufelt
MVP Notable Contributor
Is it possible to force the scale on the Coordinates widget to the same scale on the LODs on the Navigation widget?
Thanks


My LODs are set by loading in a tiled service as a basemap.

the Scale displays exactly the LOD for the cached zoom level I am currently viewing.

R_
0 Kudos
ronaldmcfarlane
Regular Contributor
Daniel,

   Sure something like this:

            private function map_mouseMoveHandler(event:MouseEvent):void
            {
                const mapPoint:MapPoint = map.toMapFromStage(event.stageX, event.stageY);
                coords.text = m_func(mapPoint) + " Scale 1:" + String(map.scale * 3.2808398950131235);
            }

I can never remember if the right calculation is multiple or divide though.:o


While this is a great example of incorporating code to modify output, you don't want to do this.  The scale shown is "Representative Fraction" scale  which is not based upon a specific unit of measure.  By this I mean an RF scale of 1:100 is the same regardless of how you care to measure it; 1 in represents 100 inches or 1 meter represents 100 meters.  To convert the result displayed means you would need to add additional text so it would read "1 meter represents xx yards".
0 Kudos
JamalNUMAN
Legendary Contributor
Daniel, 

Try this in the CoordinateWidget.mxml 

            private function map_mouseMoveHandler(event:MouseEvent):void
            {
                const mapPoint:MapPoint = map.toMapFromStage(event.stageX, event.stageY);
                coords.text = m_func(mapPoint) + " Scale 1:" + map.scale.toString();
            }


Hi Robert,

Could you please indicate where should I stick this code? I have no idea!

[ATTACH=CONFIG]20348[/ATTACH]

Thanks

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