I am trying to query features from the feature layer view and add these features to a graphics layer to enable snapping on the features using the sketch view model I already have, but on a large scale, i start to see this error: " Uncaught TypeError: Cannot read properties of null (reading '0') ".
NOTE: when I comment : " gfxLayer.add(g) " or " new FeatureSnappingLayerSource({ layer: gfxLayer as __esri.GraphicsLayer,
enabled: true,
}), " or " visible: false," I don't see the error anymore, but snapping does not work.
sketchVmRef.current = new SketchViewModel({
view: mapView,
layer: new GraphicsLayer({}),
snappingOptions: {
enabled: true,
featureSources: [
new FeatureSnappingLayerSource({
layer: gfxLayer as __esri.GraphicsLayer,
enabled: true,
}),
],
},
})
const queriedFeatures = await featureLayerView.queryFeatures({
where: `1=1`,
outFields: ['*'],
returnGeometry: true,
})
for (const feature of queriedFeatures.features) {
const g = new Graphic({
geometry: feature.geometry,
attributes: feature.attributes,
layer: gfxLayer,
// visible: false,
})
gfxLayer.add(g)
}