Select to view content in your preferred language

Newbie Polygon Question

748
2
08-16-2012 04:10 PM
GregoryBoratyn
Emerging Contributor
Hi All,
I have a question about Adobe Flex ActionScript and Polygon object.
I have this simple form with 8 text fields that I used to enter 4 point coordinates (x and y values for each) to draw Polygon on the map.
There's an example included with Flex APIs for Polygon object that I was trying to follow but something isn't working for me....
The example shows how to do this in MXML, not Actionscript so I was wondering if you guys know how to make this working in Actionscript.

Here is what I have so far:
The function this code is in takes variable number of arguments so first I'm looping through it to get my array of MapPoints

var rectangle:Polygon = new Polygon();
var sr:SpatialReference = new SpatialReference(4326);//<-- this number comes from example I have no idea what it means
 
rectangle.spatialReference = sr;

// points are :
//1. x="13" y="55.59"
//2. x="18.42" y="-33.92"
//3. x="-43.23" y="-22.90"
//4. x="13" y="55.59"
//they will appear West of Africa and I see them but not the polygon created out of them.

for (var j:uint = 0; j < args.length; j++){
argArray.push(args);
}
 
rectangle.addRing(argArray);
 
//create new graphic to add to graphicsLayer
graphic = new Graphic(polyLine);
graphic.symbol = new SimpleLineSymbol(lineStyle.selectedItem.style, cpLine.selectedColor, numLineAlpha.value, numLineWidth.value);
graphic.attributes = {labeled: isMeasurementExpanded};
graphicsLayer.add(graphic);

Any suggestions?
Thanks
Tags (2)
0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus
Greg,

   Well first what 4326 means is that is the WKID (Well Known ID) number for the WGS 1984 geographic spatial reference find more info here: http://resources.arcgis.com/en/help/flex-api/concepts/017p/017p0000001p000000.htm

It may help to see more of your code for getting the values from your simple for and putting them in the args variable.

But it may be as simple as asking if you have added your first point to the point array at the end to close the polygon?..
0 Kudos
GregoryBoratyn
Emerging Contributor
Thanks rscheitlin,
The code I'm showing in my first post is pretty much what I have.
Anyway, I found my mistake. It's one of those, "copy/paste" mistakes...
The two line of code:
graphic = new Graphic(polyLine);
graphic.symbol = new SimpleLineSymbol(lineStyle.selectedItem.style, cpLine.selectedColor, numLineAlpha.value, numLineWidth.value);

should actually be:
graphic = new Graphic(rectangle);
graphic.symbol = new SimpleFillSymbol(lineStyle.selectedItem.style, cpLine.selectedColor, numLineAlpha.value, numLineWidth.value);

Hopefully someone else will benefit from this thread.
Greg
0 Kudos