AnsweredAssumed Answered

SsnappingManager only snaps to map graphics

Question asked by amarsden on Apr 17, 2013
Latest reply on Apr 18, 2013 by amarsden

I have a internal project about to go live, I really want to have snapping for measurements and user added graphics.

At the moment a simple

    map.enableSnapping({ snapKey: dojo.keys.copyKey });

gets it on. However snapping only appears to work against already drawn graphics, not on any of my vector layers on my map.  My map is made up of four ArcGISDynamicMapServiceLayer - added like this

    var background = new esri.layers.ArcGISDynamicMapServiceLayer(mapservice1, { "id": "mainbasemaps" });   // map.addLayer(background);       background.setDPI(150);     var altmaps = new esri.layers.ArcGISDynamicMapServiceLayer(altbasemaps, { "id": "altbasemaps" });    // map.addLayer(altmaps);     var aerials = new esri.layers.ArcGISDynamicMapServiceLayer(aerialservice, { "id": "aerialmaps" });       //map.addLayer(aerials);     dynamicMapServiceLayer = new esri.layers.ArcGISDynamicMapServiceLayer(mapservice2, { "id": "mainmap" });     dynamicMapServiceLayer.setOpacity(0.9);     dynamicMapServiceLayer.setDPI(96)     map.addLayers([background],[altmaps],[aerials],[dynamicMapServiceLayer]);

from the API documentation

Reference to a feature or graphics layer that will be a target snapping layer. The default option is to set all feature and graphics layers in the map to be target snapping layers.

So I would have thought it would snap to everything?

I've tried defining a specific layer like

var snappinglayer = new esri.layers.FeatureLayer(mapservice2 + "/4", {        mode: esri.layers.FeatureLayer.MODE_ONDEMAND,         outFields: ["*"]     }); ... var layerInfos = [{ layer: snappinglayer }];     snapManager.setLayerInfos(layerInfos);

But that fails.

Any ideas what I've missed?