Get xy coordinates from a graphics layer or series of map points

4041
1
12-13-2011 05:59 AM
JanicePeal
Occasional Contributor
This is going to be a much more complex question than what the title suggests.  I have a data provider that populates a list of items (that's created based on a query via stored procedure in SQL and returns XML), and each item in the list stores an x coordinate and a y coordinate.  From this resulting data provider for the list I am dynamically generating points on a map in a graphics layer:

for (var i:int = 0; i < xys.length; i++)
{
    _resultsMapPoints = new MapPoint(Number(xys.centroidX),Number(xys.centroidY),new SpatialReference(3424));
    var myGraphic:Graphic;
    myGraphic = new Graphic(_resultsMapPoints,_sms_resultsRed); 
    this._gl_resultsMarkers.add(myGraphic);
}

What I'm trying to do next is based on a mouse click on an item in the list, match the xy of the selected item in the list to the xy of the graphic in _gl_resultsMarkers, and then place a speech bubble over the selected graphic in the correct place on the map.  The speech bubble is a component stored in my map component so it's a map/stage comparison thing.  I know I can use the map.toScreen option to get the bubble properly placed once I get my xy's, but I'm having trouble figuring out how to grab the xy's from the graphics (or do I need to loop through the MapPoints) to do the match to the array values in the first place.  Any pointers would be greatly appreciated.  I've been stuck on this for a day and a half now.  Thanks in advance.
Tags (2)
0 Kudos
1 Reply
YungKaiChin
Occasional Contributor
If I understand your question correct, this may be what you are looking for:

(myGraphic.geometry as MapPoint).x
(myGraphic.geometry as MapPoint).y
0 Kudos