measurement.watch("viewModel.state", function (state) {
console.log("Current state: ", state);
if (state == "measured") {
//here i want to get the geometry off added graphics by active measurement tool.please help.
}
});
Solved! Go to Solution.
There is no documented way to get a reference to the geometry. However, if you're working in 2D (i.e. with a MapView), this presently works:
measurement.watch("viewModel.state", function (newValue, oldValue, propertyName, target) {
if (newValue == "measured") {
var geometry = target.viewModel.activeViewModel.tool._measurementLayer.graphics.getItemAt(0).geometry;
}
});
There is no documented way to get a reference to the geometry. However, if you're working in 2D (i.e. with a MapView), this presently works:
measurement.watch("viewModel.state", function (newValue, oldValue, propertyName, target) {
if (newValue == "measured") {
var geometry = target.viewModel.activeViewModel.tool._measurementLayer.graphics.getItemAt(0).geometry;
}
});