I'm trying to set the Snapping options of the sketch widget, to snap only to a specific graphic layer, and not all others. It seems like the results " ignores" my settings, shows all the graphic layers, and do no enable the one io selected.
I used this example: https://developers.arcgis.com/javascript/latest/sample-code/sketch-snapping-magnifier/tommypet
export const createSketchWidget = (view, layer, onSketchUpdated, featureLayer) => { const { Sketch } = getEsriModules(); console.log('createSketchWidget', featureLayer); const sketchWidget = new Sketch({ layer, view, creationMode: 'update', snappingOptions: { enabled: true, featureSources: [{ layer: featureLayer, enabled: true }], }, visibleElements: { createTools: { circle: false, polyline: false, point: false, rectangle: true, polygon: true, }, selectionTools: { 'rectangle-selection': false, 'lasso-selection': false, }, snappingControlsElements: { header: true, layerList: true, }, settingsMenu: true, }, }); view.ui.add(sketchWidget, 'top-right'); sketchWidget.on('create', onSketchUpdated); sketchWidget.on('update', onSketchUpdated); return sketchWidget; };
Hello @AmirKhanInd ,
Have you had an opportunity to test with the latest version of the JSAPI 4.24, and are you using GroupLayers in your map? I ask because we had a similar issue we resolved for GroupLayers only, in version 4.24. I just tested and verified this is working with standalone layers. Here is the codepen I used from the same sample you provided:
https://codepen.io/banuelosj/pen/KKoPGba?editors=1010
Your code looked fine on first glance, but if you still see the issue, feel free to use a similar codepen to the one I provided to provide a repro case.
Thanks,
Jose