Skip to content
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

Merged
merged 6 commits into from Aug 21, 2023

Conversation

cecildelakers
Copy link
Contributor

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!

@CLAassistant
Copy link

CLAassistant commented Aug 18, 2023

CLA assistant check
All committers have signed the CLA.

@@ -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);
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

_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)
Copy link
Contributor

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

Copy link
Contributor

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).

@inforithmics
Copy link
Contributor

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.

@cecildelakers
Copy link
Contributor Author

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! :)

@inforithmics
Copy link
Contributor

No, problem can you check if my changes work for you too, if yes I can merge this.

@cecildelakers
Copy link
Contributor Author

It's working well now. Certainly you can merge it.

@inforithmics inforithmics merged commit fd6f21b into Mapsui:master Aug 21, 2023
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants