SnappingOptions in JSAPI 4.19 is a great addition. The following enhancements would really increase its usefulness.
Emit events when a snap is about to occur. Properties should include the location of the cursor, the snap point, the target layer, the feature in the target layer, and whether the snap point is an edge, vertex, or point. Make the event cancelable so developers could suppress the snapped UI in certain conditions.
Additional properties of FeatureSnappingLayerSource to control whether to snap to edges and/or vertices and/or points, as in 3.x.
Hi Ethan,
Thanks for the feedback on the snapping enhancements you would like to see in the future. We would like to be able to have the options to control whether to snap to edges, vertices, etc. just like ArcGIS Pro does it. This is currently being discussed on how to port this into the Sketch widget, so thanks for the feedback!
In regards to event emitting, this could be something we discuss as well. Is there a specific use case in which this would be useful to you or to others as well?
Thanks,
Jose
Hi Jose,
We have been asked to develop a "trace" tool in which a user would move the cursor along a line or polygon in streaming mode, creating vertices at each vertex of the target feature. The additional snapping events would help do to things like display an edge within snapping distance without creating a vertex there, and to continue snapping when moving from one edge to another. Here are the issues we encountered when experimenting with snapping while streaming:
Thank you,
Ethan
Hi Ethan,
This is a pretty solid use case. Creating your own tracing logic via the snapping events is pretty interesting, and this would be a good enhancement. At the moment the snapping engine used is under the hood, so we will look into potentially exposing some of these events.
Thank you so much for your feedback,
Jose
Hello Jose,
Has a "snapping" event been implemented yet? An application I'm working on has graphics layer full of points, and the user needs to add a point on the map to do some stuff. They have the option to enable snapping on the existing graphics layer.
When snapping is enabled, they want to be able to see the data of the point that is being snapped to, in real time while the hover around the map, to help them determine where they want to place the new point. Does this functionality exist for the current sketch widget?
Thanks
Agree, look very promising.
One thing that stop me - the definition expression on my Feature service are ignore when it is used as a FeatureSnappingLayerSource: i.e. all the data are retrieved in the FeatureService - and it is just to many records.
Looking into this, this could potentially be a bug. Thanks for bringing this up @GertConradie !
I am seeing the request (where: 1=1) being sent when you add the feature service with a definition expression as a feature snapping layer source. We will be looking into this. Thanks again for bringing up this issue you found.
Thanks,
Jose
Thanks, much appreciated.
For anyone in the meantime that get stuck with it - I found a workaround for the interim. (It only works because I have relative few polygon geometries supplied by the definitionExpression used, that I want to snap against.)
I query/retrieve the client side geometries from my real FeatureLayer, than load them in a temporary client-side-only FeatureLayer, which I use as a snapping data source. The temporary layer does not have to be added to the map first - you can pass it on to the snapping tools directly
The snapping work really great!