Select to view content in your preferred language

Enable all layers for snapping

370
2
10-28-2024 11:27 PM
Vakhtang_Zubiashvili
Frequent Contributor

Hi all,

In edit widget i want to enable all layers snapping, i used this code:

 

snappingOptions: { // autocasts to SnappingOptions()
    enabled: true, // global snapping is turned on
    // assigns a collection of FeatureSnappingLayerSource() and enables feature snapping on this layer
    featureSources: [{ layer: myFlLayer1, myflLayer2, enabled: true }]
  }

but, it des not work.

How can i pass several layers in featureSources?

 

Thanks

0 Kudos
2 Replies
Sage_Wall
Esri Regular Contributor

Hi @Vakhtang_Zubiashvili ,

You need to have a collection of FeatureSnappingLayerSource . So with three layers (the second one is not enabled) it might look something like this

 

featureSources: [{ layer: myFlLayer0, enabled: true }, { layer: myFlLayer1, enabled: false}, { layer: myFlLayer2, enabled: true }]

 

 If you really want to enable snapping on all layers in your map you could probably do something like this but I haven't checked to see if this actually works.  I think it should, but you might have to filter the allLayers collection first to just the layer types supported in featureSources

 

  snappingOptions: { 
    enabled: true, 
    featureSources: map.allLayers
  }

 

 

Vakhtang_Zubiashvili
Frequent Contributor

Thank you @Sage_Wall , i see, i did not try to add FLs as objects and map.allLayers i couldn't think about it.

Thanks again

0 Kudos