Calculate distance in meters of polyline

Discussion created by alessandroferrucci on Sep 17, 2012
Latest reply on Jun 12, 2013 by TruthOf42
Hello I have a simple question,
I'm creating a polyline on a map and when I'm done creating it I would like to display the distance in meters.

I have this code:

distanceSeg=new Polyline();
double  len1=distanceSeg.calculateLength2D();

I would like to convert len1 to meter units.. I tried this:

double m_len=Unit.convertUnits(len1, Unit.create(AngularUnit.Code.DEGREE) ,Unit.create(LinearUnit.Code.METER));

but I get an exception with GeometryException: invalid_call

Any help would be appreciated.