Solved! Go to Solution.
hi,
please, I have similar problem and I would need help to straighten my point of view.
I'm not sure there's an init or load event for the SnappingManager but you could probably just make sure the SnappingManager is accessable/exists before continuing on in your code.
Is it really recommended approach? In documentation is stated that after calling the function enableSnapping(), snappingManager is accessible through snappingManager property.
require([
"esri/map", ...
], function(Map, ... ) {
var map = new Map( ... );
var snappingManager = map.snappingManager();
...
});
So I would expect it to just be there. But unfortunately in reality it works or doesn't work that way. Snapping manager is returned inconsistently. Sometimes yes, sometimes no. Depending on the underlying structures and layers to be ready / loaded I guess.
Or, on the other hand, if it ought to be async, the function enableSnapping() should require some callback function as an argument to be called in the moment the snapping manager is created and ready.
Or there should be an event on the map object to be listend and handled when snapping manager is ready and accessible.
Honestly, I can't imagine any other clean way of making sure the SnappingManager is accessable/exists. Do you? Any setInterval or setTimeout hacks? no...
please can somebody suggest the right approach?
Thank you very much in advance.