Select to view content in your preferred language

Snapping doen't work in Measure tool

1112
1
Jump to solution
04-24-2014 05:08 AM
KirtikaChauhan
New Contributor II
Hi,

I am trying to give my own feature layer in layerinfo of Measure tool. But it doesn't snap to points. I have point features in my map service, and I want to snap to features. Snapping works but it wouldn't snap to points rather it would snap to basemap.

Sample code:
esriConfig.defaults.geometryService = new GeometryService("MyGeometryServiceURL");

        map = new Map("map", {
            basemap: "topo",
            center: [-0.114, 51.8],
            zoom: 11
        });
        var dynlayer1 = new esri.layers.ArcGISDynamicMapServiceLayer("MyServiceURL");
        map.addLayer(dynlayer1);
        var sfs = new SimpleFillSymbol(SimpleFillSymbol.STYLE_SOLID,
         new SimpleLineSymbol(SimpleLineSymbol.STYLE_SOLID,
         new Color([195, 176, 23]), 2), null);

        var parcelsLayer = new FeatureLayer("MyServiceURL", {
            mode: FeatureLayer.MODE_ONDEMAND,
            outFields: ["*"]
        });
        parcelsLayer.setRenderer(new SimpleRenderer(sfs));
        map.addLayers([parcelsLayer]);

        //dojo.keys.copyKey maps to CTRL on windows and Cmd on Mac., but has wrong code for Chrome on Mac
        var snapManager = map.enableSnapping({
        tolerance:0,
            snapKey: has("mac") ? keys.META : keys.CTRL
        });
        var layerInfos = [{ layer: parcelsLayer, snapToPoint: true}];
        snapManager.setLayerInfos(layerInfos);

        var measurement = new Measurement({
            map: map
        }, dom.byId("measurementDiv"));
        measurement.startup();

I am just wondering is there any limitation on snapping that it does only for grid's and not for point.

Any help would be really appreciated.
0 Kudos
1 Solution

Accepted Solutions
KirtikaChauhan
New Contributor II
Works with Feature layer, wasn't working because I had forgotten to give the id of feature layers and was adding a group layer.

View solution in original post

0 Kudos
1 Reply
KirtikaChauhan
New Contributor II
Works with Feature layer, wasn't working because I had forgotten to give the id of feature layers and was adding a group layer.
0 Kudos