Hi
I am confused to calculate total length of line feature with arcgis API for java script.
any one can help me...???
I found following code but it's not working.
let geometryService = new GeometryService({
url:url
})
geometryService.simplify([line]).then(function (line) {
var areasAndLengthParams = new LengthsParameters({
lengthUnit: "kilometers",
polylines: line
});
console.log(areasAndLengthParams)
/* geometryService.Length(areasAndLengthParams).then(function (results) {
console.log("area: ", results.areas[0]);
console.log("length: ", results.lengths[0]);
}); */
});
You can use the geometryEngine for this:
var length = geometryEngine.geodesicLength(polyline, "meters");
sample
https://codepen.io/noash/pen/BaaPqNv?editors=1000#0
Or, you could also use the measurement widget to make this measurement in the app itself: