multi layer
Snapping to features on multiple layers
I am having problems using the OpenLayers snapping functionality. I need to have several layers on my map and use the snap on all. I have tried an option creating a collection but it has not worked. Another option does work but I don't know if it is the most optimal and I would need to confirm if there are any more options.
https://stackoverflow.com/questions/58025791/snapping-to-features-on-multiple-layers
example
Draw and Modify Features
import 'ol/ol.css'; import Map from 'ol/Map'; import View from 'ol/View'; import {Circle as CircleStyle, Fill, Stroke, Style} from 'ol/style'; import {Draw, Modify, Snap} from 'ol/interaction'; import {OSM, Vector as VectorSource} from 'ol/source'; import {Tile as TileLayer, Vector as VectorLayer} from 'ol/layer'; var raster = new TileLayer({ source: new OSM(), });
https://openlayers.org/en/latest/examples/draw-and-modify-features.html

api
Class: Snap
import Snap from 'ol/interaction/Snap'; Handles snapping of vector features while modifying or drawing them. The features can come from a module:ol/source/Vector or module:ol/Collection~Collection Any interaction object that allows the user to interact with the features using the mouse can benefit from the snapping, as long as it is added before.
https://openlayers.org/en/latest/apidoc/module-ol_interaction_Snap-Snap.html

