Hit Test Graphic Returned Has Geometry Issue

472
6
02-14-2019 12:00 AM
bobongubza
New Contributor II

I am trying to use the view.hitTest function for points, lines and polygons. The selected features look correct at the scale level when a feature was selected, but once I zoom there are visible geometric discrepancies. I had this issue with arcgis javascript 3.27 but someone on geonet suggested I set the autogeneralize as false for the feature layer and it worked. I am now coding with arcgis javascript 4.10  and the method for setting autogeneralize as false is not there (i am assuming it is the same issue) for feature layers. How can I solve this issue.

0 Kudos
6 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Bobo,

   If it is a FeatureLayer then construct it like this:

quantize:false
var layer = new FeatureLayer(url, {id:"myLayer",visible:true,quantize:false});
0 Kudos
bobongubza
New Contributor II

I tried putting the quantize option as false. It works really well with points, but with a polygon there is still a visible geometric error. 

One other thing, I checked the properties of a feature layer for arcgis javascript 4.10 but quantize is not there. I just wanted to know what is the reason for that.

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Bobo,

   It is an undocumented property.

0 Kudos
KevinTientcheu3
New Contributor II

Hello Bobo,

Robert's solution works very well if you have a feature layer! I thought I should also mention this in case it could be of use to you: GeometryService | API Reference | ArcGIS API for JavaScript 4.10 

There is a 'generalize' method that might get you what you are looking for. 

I hope it helps!

0 Kudos
bobongubza
New Contributor II

I tried the generalize method but it did not fix the problem I had. The parameters I gave were:

generalize = new GeneralizeParameters()
generalize.geometries = [pointGraphicSelected.geometry]
generalize.deviationUnit = "meters"
generalize.maxDeviation = 0.000001

0 Kudos
JohnGrayson
Esri Regular Contributor

Do you have a simple codepen of jsbin showing the issue?

0 Kudos