-
-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Snapping Control #1164
Comments
Modify interaction supports snapping, what did you have in mind? |
AFAIK the current snapping functionality is limited to preserve existing overlapping vertices on selected features. What I have in mind is more generic snapping, i.e to be able to move a vertex and snap it to another vertex (of another selected feature). This kind of snapping would be useful for both Draw and Modify interactions and would provide similar functionality as in OL2: http://dev.openlayers.org/releases/OpenLayers-2.13.1/examples/snapping.html |
Seconded - this is a vital part of the way drawInteraction needs to work (snapping to e.g. neighbouring feature vertexes so that a polygon you draw "snaps" to the neighbour, leaving no shim behind). If one were to implement this on his own, were would he start? e.g. in handlePointerDown, find the closest vertex within some tolerance and if there is one, change the event.x and .y coordinates? |
I covered my own snapping needs, using internal APIs from within OpenLayers 3 code and writing horrible (i.e. stateful) - but working - code. I describe what I did below, in case it proves useful to fellow OL3-coders. In my case, I needed the OL3 core coders will probably hate me for pasting this (full of accesses to internal APIs and variables), but I'll just copy it here anyway, with the added caveats, grains of salt, etc - any suggestions for improving it are most welcome. Here's the executive summary:
Below, the relevant pieces of my TypeScript code (drumroll): The hover logic:
... and the mouse click logic:
|
That's a valiant attempt at implementing this. I've added a bounty on this issue to see if that helps get this functionality added to the core library. |
ttsiodras, I would like use and test your code in javascript. Thanks |
I need snap functionalty for a project I'm on, so I'm currenty working on solving this problem.
Each interaction sholud expose it's current coordinate via snap event. And if var event = new ol.SnapEvent(
ol.SnapEventType.SNAPME,
event.coordinates
);
this.dispatchEvent(event);
var possiblySnappedCoordinates = event.snappedCoordinate;
/* event.snappedCoordinate is used as current coordinate insead of event.coordinate */ Place to fire a SNAPME event in This is my idea of solving this problem, any feedback is appreciated. |
@lenoil Yes, isVoid just checks for undefined and null, and no, I wrote the code in TypeScript - but it's very easily translatable, the TypeScript concepts are pretty straightforward to map. If you have any problems with some parts of the syntax, just ask - here, or better yet, directly at my gmail account (since this doesn't really relate to the ticket). |
Fixed with #3109. |
Want to back this issue? Place a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: