# polygon area in local live

• ### Question

• As we can see in local live , each shape in a collection had area property.  Where is this property in VE6 control?
Thursday, August 21, 2008 7:43 AM

• There is an area property in the shape object, however it is undocumented and unsupported. You can access this property like so:

var polygon = new VEShape(VEShapeType.Polygon,points);
var area = polygon.Primitives[0].area;

Note that this property does not get filled by Virtual Earth. You could however calculate the are of the polygon and then store the value here. Depending on how complex your polygon is calculating the area can be either really easy or near impossible. If you know the type of polygon you are working with then it might be possible to generate an algorithm for that case. Different types of polygons to consider, ordered from easist to hardest to calculate:

circular polygons: pretty straight forward calculation
radial polygons: standard polygons that have evenly spaced points and equal edge lengths (ie. triangle, pentagon)
regular polygons: polygon where no edges cross eachother
complex polygons: polygons where edges cross eachother

The first three types can be calculated client side fairly fast. The fourth case can sometimes take a lot of work to calculate. I'm in the process of writting a series of articles on how to do a bunch of advance mapping mathematics. They should be available by the end of the year.
Thursday, August 21, 2008 7:16 PM

### All replies

• There is an area property in the shape object, however it is undocumented and unsupported. You can access this property like so:

var polygon = new VEShape(VEShapeType.Polygon,points);
var area = polygon.Primitives[0].area;

Note that this property does not get filled by Virtual Earth. You could however calculate the are of the polygon and then store the value here. Depending on how complex your polygon is calculating the area can be either really easy or near impossible. If you know the type of polygon you are working with then it might be possible to generate an algorithm for that case. Different types of polygons to consider, ordered from easist to hardest to calculate:

circular polygons: pretty straight forward calculation
radial polygons: standard polygons that have evenly spaced points and equal edge lengths (ie. triangle, pentagon)
regular polygons: polygon where no edges cross eachother
complex polygons: polygons where edges cross eachother

The first three types can be calculated client side fairly fast. The fourth case can sometimes take a lot of work to calculate. I'm in the process of writting a series of articles on how to do a bunch of advance mapping mathematics. They should be available by the end of the year.
Thursday, August 21, 2008 7:16 PM
• I tried your solution, but

var area=myShape.Primitives[0].area;
return (area);

area = -1

this is an uncatchable error...
Do you have a sample , how to use this ?
Looking in Firebug DOM-properties object myShape is a valid shape, having "Primitives[0]" properties, but area is equals to -1
Friday, August 22, 2008 8:50 AM
• As I mentioned before the area property does not get filled by Virtual Earth. It will always have a value of -1 unless you
calcualte the area of the polygon and assign it to this variable.
Friday, August 22, 2008 2:47 PM
• Thanks Richard
But i'm little confused. There is a property , but we can't use it.  So  ....
I come back to my first post .. is there any method to retrieve polygon area, as  the same way of Local Live do it ?

Someone knows how to do that?
Friday, August 22, 2008 3:54 PM