Hello,
I am trying to get the area of a drawn and saved shape with the google overlay.
I read about the Google Mercator conversion and came up with the following code, but it isn't working.
LayerOverlay dynamicOverlay = (LayerOverlay)Map1.CustomOverlays["DynamicOverlay"];
InMemoryFeatureLayer shapeLayer = (InMemoryFeatureLayer)dynamicOverlay.Layers["shapeLayer"];
foreach (Feature feature in Map1.EditOverlay.Features)
{
AreaBaseShape abs = (AreaBaseShape)feature.GetShape();
ManagedProj4Projection proj4 = new ManagedProj4Projection();
proj4.InternalProjectionParametersString = ManagedProj4Projection.GetWgs84ParametersString();
proj4.ExternalProjectionParametersString = ManagedProj4Projection.GetGoogleMapParametersString();
proj4.Open();
AreaBaseShape abs2 = (AreaBaseShape)proj4.ConvertToExternalProjection(abs);
proj4.Close();
double area = abs2.GetArea(Map1.MapUnit, AreaUnit.Acres);
if (!shapeLayer.InternalFeatures.Contains(feature.Id))
{
shapeLayer.InternalFeatures.Add(feature.Id, feature);
}
}
Of course if I am using the World Map overlay then getting the area works without the conversion in the above code.
Thanks for your time.
Chad