Geographic Information Systems Asked by awe on December 2, 2020
I have a web application that I now need to use WFSLayer for some of the map layers. The problem is that snapping does not seem to work for WFS layers.
The layer I use for drawing is a FeatureLayer. I need to be able to snap to features in other layers.
I have this code:
var snappingOptions = {
tolerance: 20,
alwaysSnap: true
};
snappingOptions.layerInfos = [];
var layerIds = map.graphicsLayerIds;
layerIds.forEach(function (layerId) {
var lyr = map.getLayer(layerId);
if (lyr instanceof FeatureLayer || lyr instanceof WFSLayer) {
var isLyrSnappable = true;
if (snappableLayerUrls) {
isLyrSnappable = snappableLayerUrls.some(function (layerUrl) {
if (layerId.toLowerCase() === layerUrl.toLowerCase() || (lyr.url && lyr.url.toLowerCase() === layerUrl.toLowerCase())) {
return true;
}
return false;
});
}
var layerInfo = { layer: lyr };
if (isLyrSnappable) {
if (lyr.geometryType === "esriGeometryPolygon") {
layerInfo.snapToEdge = false;
layerInfo.snapToVertex = true;
} else if (lyr.geometryType === "esriGeometryPolyline") {
layerInfo.snapToVertex = true;
} else if (lyr.geometryType === "esriGeometryPoint") {
layerInfo.snapToPoint = true;
}
snappingOptions.layerInfos.push(layerInfo);
}
}
});
console.log('snappingOptions', snappingOptions);
map.enableSnapping(snappingOptions);
When I look at the snapping options at the end, I se that my WFS layers are present in the snappingOptions.layerInfos
array.
When I activate a draw tool, the other FeatureLayer
layers are snapped to, but not the WFSLayer
layers.
Is not snapping supported for the WFSLayer?
How can I get around this?
I think this site is for your problem::::: https://support.esri.com/en/technical-article/000012235
Answered by GIS_Esri on December 2, 2020
I was able to do a workaround with mouseover events that works for the wfs layer. It triggers each time you mouseover a feature in the layer. Then I stored that geometry in a global variable, and made it the point feature for the snapping. I also updated the mouse point geometry in the event itself, so that the draw function that followed in later event cycle actually got the snapped point instead of the initial mouse position.
If you want more details on this, please post a comment here, and I will take the time to extract the most important parts of my code and update this answer.
Answered by awe on December 2, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP