Select to view content in your preferred language

How to get the geometry of measurement Widget 4.26

398
1
Jump to solution
05-30-2023 05:01 AM
Nadir_Hussain
Occasional Contributor

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.
}

});

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JoelBennett
MVP Regular Contributor

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;
	}
});

 

View solution in original post

1 Reply
JoelBennett
MVP Regular Contributor

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;
	}
});