How can I get the click on a polygon that was drawn using Sketch Widget? I tried hitTest, but it brings several results (points and polygons)
Currently my code looks like this:
view.on("click", function (event) { view.hitTest(event.screenPoint).then(function (response) { console.log(response.results); //results an array of geometrys }); });
Solved! Go to Solution.
Thafny,
Just loop through the hit test results and look at the response.results array (which is an array of graphics) Each graphic has a layer property. You check if the layer is the same layer id as your polygon layer that you are interested in.
Thafny,
Just loop through the hit test results and look at the response.results array (which is an array of graphics) Each graphic has a layer property. You check if the layer is the same layer id as your polygon layer that you are interested in.
Thanks!!!