I have a web application that I now need to use WFSLayer for some of the map layers. The problem is that snapping does not seem to work for WFS layers.

The layer I use for drawing is a FeatureLayer. I need to be able to snap to features in other layers.

I have this code:

var snappingOptions = {
    tolerance: 20,
    alwaysSnap: true

snappingOptions.layerInfos = [];
var layerIds = map.graphicsLayerIds;
layerIds.forEach(function (layerId) {
    var lyr = map.getLayer(layerId);
    if (lyr instanceof FeatureLayer || lyr instanceof WFSLayer) {
        var isLyrSnappable = true;
        if (snappableLayerUrls) {
            isLyrSnappable = snappableLayerUrls.some(function (layerUrl) {
                if (layerId.toLowerCase() === layerUrl.toLowerCase() || (lyr.url && lyr.url.toLowerCase() === layerUrl.toLowerCase())) {
                    return true;
                return false;
        var layerInfo = { layer: lyr };
        if (isLyrSnappable) {
            if (lyr.geometryType === "esriGeometryPolygon") {
                layerInfo.snapToEdge = false;
                layerInfo.snapToVertex = true;
            } else if (lyr.geometryType === "esriGeometryPolyline") {
                layerInfo.snapToVertex = true;
            } else if (lyr.geometryType === "esriGeometryPoint") {
                layerInfo.snapToPoint = true;

console.log('snappingOptions', snappingOptions);

When I look at the snapping options at the end, I se that my WFS layers are present in the snappingOptions.layerInfos array.

When I activate a draw tool, the other FeatureLayer layers are snapped to, but not the WFSLayer layers.

Is not snapping supported for the WFSLayer?

How can I get around this?


I was able to do a workaround with mouseover events that works for the wfs layer. It triggers each time you mouseover a feature in the layer. Then I stored that geometry in a global variable, and made it the point feature for the snapping. I also updated the mouse point geometry in the event itself, so that the draw function that followed in later event cycle actually got the snapped point instead of the initial mouse position.

If you want more details on this, please post a comment here, and I will take the time to extract the most important parts of my code and update this answer.

| improve this answer | |

I think this site is for your problem::::: https://support.esri.com/en/technical-article/000012235

| improve this answer | |
  • That's for ArcMap, OP is talking about the Javascript API. – Juffy May 28 '19 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.