AnsweredAssumed Answered

SnapManager not drawing point at the snap

Question asked by minnag on May 14, 2018
Latest reply on May 18, 2018 by minnag

SnapManager fails to complete snap in Javascript

 

I am having a problem similar to the one Tyler described but the previous post did not solve my problem. I have a custom widget with a click event that uses the snapping manager to guide the user to place a point along a road. The road is in a feature service and I am using the draw toolbar to create the point. Snapping at first seems to be working great to the point of creating the little blue X that is constrained to follow the road, however, when the user actually clicks the point will be created at the actual click point and not where the blue X is showing.

 

How can I make the snapped point graphic actually be created on the line where the blue X seems to indicate it will be?

Right now I am adding the featurelayer to the map every time the user clicks, which is not practical in the long run, but I am just trying to get it to work.

 

Thank you for any help in solving this problem.

 

myfunction: function (evt) {


var parcelsLayer = new FeatureLayer(
"http://myurl/MapServer/0",
{
mode: FeatureLayer.MODE_ONDEMAND,
outFields: ["*"]
});
this.map.addLayer(parcelsLayer);

var snapManager = this.map.enableSnapping({
tolerance: 20,
alwaysSnap: true
});


var layerInfos = [{
layer: parcelsLayer
}];

snapManager.setLayerInfos(layerInfos);

var tb;
tb = new Draw(this.map);
tb.activate(Draw["POINT"]);

var line = new SimpleLineSymbol();
line.setColor(new Color([168, 0, 0, 1]));
line.setWidth(2);
var marker = new SimpleMarkerSymbol();
marker.setOutline(line);
marker.setStyle(SimpleMarkerSymbol.STYLE_X);

var graphic = new Graphic(evt.mapPoint, marker);

this.map.graphics.add(graphic);


}

Outcomes