AnsweredAssumed Answered

Snappingmanager does not work. is map._getFrameWidth() the problem?

Question asked by joelhempenius on Sep 3, 2014
Latest reply on Jun 8, 2015 by mehmetunluu

I'm working on a webapplication which requires snapping on some layers. I've enabled snapping using these lines of code:

 

var map = this.app.map;

this.snappingManager = map.enableSnapping({

                alwaysSnap: true,

                snapPointSymbol: esri.symbol.SimpleMarkerSymbol(),

                tolerance: t,//t is a parameter in the complete function

                snapKey: dojo.keys.copyKey

      });

But when I try to snap to my layers, it does not work. I tried to debug my code and saw some behaviour which seems strange in the SnappingManager.js code from the javascript api

When the Snappingmanager is in the _getSnappingPoint function, the following code is executed:

n = this.map._getFrameWidth(); variable n is used in this function in various places

In my case n has the value undefined and I think therefore the other parts of the function fail.

I had a closer look at the _getFrameWidth function which gives an undefined

_getFrameWidth: function() {

                        var a = -1, b = this.spatialReference._getInfo();

                        this.__LOD ? (b = this.__LOD._frameInfo) && (a = b[3]) : b && (a = Math.round(2 * b.valid[1] / (this.extent.getWidth() / this.width)));

                        return a

In the first line of code I get a null  for this.spatialReference._getInfo(); because my map is in WKID 28992

However the map has  a .__LOD, so the function will try to use this in the tenary operaion and assign the _frameInfo from the LOD to b and then tries to get a  value from this array. However my array is empty, because my __LOD looks like this: "{"scale":1216.7116413886708,"_frameInfo":[]}"

 

I compared my map to one of the examples from Esri and in this map the __LOD  looks like this:

{"level":17,"resolution":1.1943285668550503,"scale":4513.988705,"startTileRow":214,"startTileCol":0,"endTileRow":130857,"endTileCol":131071,"_frameInfo":[131072,0,131071,33554432]}

And snapping works fine when I added a snapping manager from the Chrome Console into the example

Outcomes