Why doesn't the rectangle option in SketchViewModel work as expected?

922
5
07-11-2019 01:48 PM
JackFairfield
Occasional Contributor II

When using an instance of SketchViewModel, I am having trouble getting the drawn rectangle graphic to work when querying the FeatureLayerView.

If you open this example and try to draw a rectangle that intersects with the point feature class, it doesn't seem to return the correct results.  usually, 0 features are returned after using the queryFeatures function on the FeatureLayerView.

Simple JS Bin example

Here is the relevant code in the sample above that doesn't seem to be working properly:

sketchVM.on("create", function (e) {
if (e.state === "complete") {
flView.queryFeatures({
   geometry: e.graphic.geometry
}).then(function(data){
   if (data.features.length === 0) {
   alert("0 features were selected????");
} else {
   alert(data.features.length + 'points selected');
}
   console.log(data);
})
}
})

UPDATE!!!

I figured out how to replicate the issue!

When drawing the rectangle, if you draw from right to left as shown in the gifs below, it will not work correctly.  If you draw from left to right, it works as expected.

Right to left (NOT WORKING)

Left to right (WORKING)

FYI, this bug seems to be present in the SketchViewModel in all versions that I tested (4.12, 4.11, etc...)

0 Kudos
5 Replies
BenElan
Esri Contributor

I was having trouble accessing your data so I used a sample service:

https://jsbin.com/locogiyoba/1/edit?html,css,output

That is definitely weird behavior, however I got it to work by querying the feature layer and removing the layer view all together. Let me know if this makes sense.

0 Kudos
JackFairfield
Occasional Contributor II

Thanks for the response.

I would greatly prefer to use the FeatureLayerView's QueryFeatures function for my use case to avoid the unnecessary network requests.

Would you please log this as a bug?  Or do you have any suggestions as a workaround?  I am using this function in several production sites.

Thanks.

0 Kudos
BenElan
Esri Contributor

Hi Jack,

Can you create a case with Esri Technical Support for this issue?

https://support.esri.com/en/request-case

Your last bug was an equivalency issue with 4.12, which is why I expedited the process. However, when you encounter bugs we ask that you submit them to Technical Support and an analyst will assist you.

Thanks!

0 Kudos
JackFairfield
Occasional Contributor II

It has now been entered as BUG-000124153 in Esri's ticketing system.

JackFairfield
Occasional Contributor II

This bug has been fixed in the 4.13 version of the API