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
Add a new way for dragging: now supports to drag the whole feature on the map. #2147
Conversation
Mapsui.Nts/Editing/EditManager.cs
Outdated
@@ -159,7 +159,7 @@ public bool AddVertex(Coordinate worldPosition) | |||
return null; | |||
|
|||
return vertices.OrderBy(v => v.Distance(mapInfo.WorldPosition.ToCoordinate())) | |||
.FirstOrDefault(v => v.Distance(mapInfo.WorldPosition.ToCoordinate()) < mapInfo.Resolution * screenDistance); | |||
.FirstOrDefault(v => v.Distance(mapInfo.WorldPosition.ToCoordinate()) < mapInfo.Resolution * screenDistance * 100); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this increased so that the nearest vertex is found when you click inside a polyogn or line? Or is there another reason for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without it the moving of the shapes doesn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, at that time I didn't find a suitable way to make my idea work, so I modified the parameter. Actually I know it's not the best method.
Mapsui.Nts/Editing/EditManager.cs
Outdated
_dragInfo.Vertex.SetXY(worldPosition.ToMPoint() - _dragInfo.StartOffsetToVertex); | ||
// set the boundary value at 10 to decide the way of dragging | ||
// try to modify vertex itself, if the worldPosition of mouse-clicking is close to the _draginfo.Vertex | ||
if (worldPosition.Distance(_dragInfo.Vertex!.ToPoint()) < 10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this 10 should be scaled by the mapinfo.Resolution or else depending on the underlaying Coordinate systems it means ~10m or ~10000km
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested it and it works quite well, except if I move the mouse really fast than I start moving the shape instead of the point. so that's why I think this parameter needs to be adapted to the map resolution (so it depends on the zoom level too).
I fixed the moving of the shape and removed the magic numbers, so the dragging works now when moving fast. I have now a Vertex for moving nodes and VertexFeature for moving Shapes so, the magic numbers aren't needed anymore. |
I'm so sorry! I didn't notice your comments until now so that I couldn't offer you any help! So kind of you to correct my codes! :) |
No, problem can you check if my changes work for you too, if yes I can merge this. |
It's working well now. Certainly you can merge it. |
Hello! Dear maintainers, I have added a new way for dragging, which allows us to drag the whole geometry/feature from the previous position to another place on the map. Please check my codes and then merge them to the master branch, if my advice is useful to this project. Thanks!