I have a Silverlight application with a Bing Map control that displays a series of editable MapPolygons that the user can resize at will. These MapPolygons are, of course, defined as geographic coordinates. How do I calculate the area of a polygon?
The polygons are stored as geography types in SQL Server and I could go back to the server for the answer, but then the user loses an interactive update of the area as they reshape the polygons. Accuracy to within a few percent is desirable.
If you don't mind going back to a WCF service, you can use the Microsoft.SqlServer.Types library to do the calculation. SqlGeometry has a method called STArea that does this: http://blogs.msdn.com/b/davidlean/archive/2008/10/17/this-site-under-construction.aspx
You wouldn't have to lose the interactivity of the app either necessarily. When the user is finished resizing, you can ask the service for the area and display a spinner or something briefly. I understand this wouldn't be as slick as doing it on the fly as the resize, but you also don't have to calculate the area on the client.
Sorry I wasn't more helpful in answering how to do it on the fly.