Introducing feature snapping in ol3!
OL3 (OpenLayers 3) v3.5.0 is out. With it comes the addition of snapping while editing vector features!
What is feature snapping, exactly?
In OL3, you can draw or modify vector features on the map using the Draw and Modify interactions. The new snapping interaction brings the possibility to ‘snap’ to other existing features while drawing or modifying one. The snapping can be made on a vertice or on an edge of a feature.
This brings the editing of vector features to the level of a Desktop GIS!
How does it works?
Here’s some technical details about how it works.
The Snap interaction listens to map browser events and modify its inner coordinates, which normally points to the position of the mouse cursor, to the location of a corner or edge of an other feature nearby. That’s the secret behind the snapping magic happening here!
Therefore, in order for any Modify or Draw interactions to work with this cool snapping feature, the Snap interaction must be added after them, which allows it to do its magic first.
The original work was started by Fran Peručić, from Promet I Prostor in Zagreb Croatia. Alexandre Dubé from Mapgears Inc. in Saguenay QC Canada joined him in the efforts to push this new feature forward and ready for review by the ol3 core developer team. Andreas Hocevar from Boundless reviewed the code, helped defining what to do and how to do it, and finally applied the patch to the ol3 GitHub repository. Many other developers have also participated in making it better with contributions such as bug fixes, better documentation, etc.
Special thanks to all developers and the companies they work for who joined their efforts in making this pretty sharp feature a great success!
OL3 is awesome! Visit its website to explore its many live examples and how powerful it is: OpenLayers 3.