ArcGIS Developers Tip #5: Working with Graphic Coordinates in ArcGIS API for Flex

As an ArcGIS API for Flex developer, knowing the basic differences between Stage, Point and MapPoint will save you a lot of time when you need to use geometry or shapes in your applications. The bottom line is every Flex display object has its own coordinate space which is essentially a graph upon which you can plot locations.

Stage represents the entire area where all Flash content is displayed. Stage coordinates start at the origin (0,0) or top left hand corner of the main drawing area, and are sometimes referred to as global coordinates. Stage coordinates can be used for such things as determining the location of a MouseEvent on a web page, or a map.

Point represents a set of x,y coordinates contained by a display object, with the top left hand corner of the display object being 0,0.  A Point can be represented in either Stage coordinates or  local coordinates. Local coordinates reside within a child display object, such as an instance of the ArcGIS API for Flex Map component.

Also, since both Stage and local use the Point object, be aware when converting between these two Adobe coordinate systems, and use well defined names to help keep things straight. Another item to keep in mind is the ArcGIS API for Flex Reference Doc refers to local Points as “screen points”. 

MapPoint represents an x,y location on a map. The x,y coordinates are in the same units as the ArcGIS Server map service; such as esriDecimalDegrees (lat/lon). 

To help determine the position of locations on a map, you can convert between Stage, local and MapPoint coordinates. Fortunately, there are already built-in methods for doing this:

ArcGIS API for Flex:

Adobe Flex:

The screenshot above shows the differences between Stage, a local Point (or screen point) and MapPoint. As an example, local Point 0,0 could also be translated into Stage Point 30,20 or MapPoint (Lat/Lon) of 64.9, -15.3.

You can also download and try out a sample Flex app that demonstrates these concepts.

Additional References:

ArcGIS API for Flex Resource Center 
Basics of Geometry and ActionScript 
Discussion on Point Objects 

 

Published Friday, August 07, 2009 1:25 PM by andygup
Filed under: ,

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

ehabx2003 said:

That case happened with me..

August 10, 2009 1:54 AM
 

r4 said:

Thanks for this informative article. I think that I have came to know a lot of things after reading this article.
November 9, 2009 12:51 AM

Leave a Comment

(required) 
(optional)
(required) 
Submit