A new bug in the 4.23 MapView.hitTest operation does not take into account the offsets a PictureMarkerSymbol (and perhaps other symbols) might have, particularly when these symbols are used to render features in a FeatureLayer.
The image below, although admittedly rough, illustrates the issue:
As can be seen, the hitTest region is the same size as the image, but has not been offset properly. This leads to unexpected and confusing behavior in some of our applications.
I’ve investigated the issue as best I can, but it’s getting to the point where further progress is going to take too much time from more important things. I’ve gotten as far as the draw method of esri.views.2d.engine.webgl.effects.HittestEffect, but I can’t tell if the problem is within the logic of that function, or the graphics context it’s querying. I can see it’s been substantially changed from the 4.22 version though.
In looking for other solutions, I’ve found that PopupViewModel.fetchFeatures works properly in this regard, but it doesn’t appear to be suitable for the same kinds of use cases that hitTest is designed for.
Because I can’t produce a suitable workaround for this issue, which I believe would be too detrimental to our users’ experience, I’m going to be forced to reject 4.23 altogether. Can we get a fix for this, or will we have to wait until 4.24 is released (plus 3 additional weeks to download)?
Hi there,
We overhauled the MapView.hittest implementation at 4.23 to return all features at a given hit point, not just the topmost ones, and changed the implementation to perform on GPU. The issue you are describing is a known issue and we addressed this issue at 4.24. You can check the fix using our next version. This simple codepen app shows the fix: https://codepen.io/U_B_U/pen/abEMrzq?editors=1000.
We cannot do a patch for 4.23 at this time.
Undral
Thank you for the reply. I'm not sure what the codepen is supposed to show though; the symbols aren't offset, and I don't think hitTest even comes into play.
If a fix has already been applied in the "next" version, can you please tell me what modules have been affected? I see the aforementioned "draw" function has been updated, but simply applying those changes does not resolve the issue.
The codepen app uses picture marker symbols with 40px x and y offset for point features. Layer has popuptemplate which uses hitTest. The hittest precision is already way better. Is this what you not see? Can you please provide me a reproducible code if you do not see it fixed in the next version.
My bad, you are correct; this upcoming version looks like it's working properly in this regard. We'll stick with 4.22 for now, and look forward to 4.24.
Like @UndralBatsukh said, hitTest for 4.24 will act on the actual symbol marker, with a slight tolerance. We don't have a list of updated modules these updates are in, as it could span multiple modules. As stated, if you have a repro showing what the expected behavior should be versus what it is that could help narrow down the issue during this release cycle.