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

Improve polyline/polygon drawing by accepting some motion on click #249

Merged
merged 1 commit into from
Jan 13, 2014

Conversation

atombender
Copy link
Contributor

This change improves polyline/polygon drawing by accepting clicks that involve a little bit of mouse motion.

The problem is that Leaflet.draw will miss most of the points if one quickly (or even not terribly quickly) tries to draw a shape such as a polygon. This is because clicking using a physical mounse typically introduces a little bit of motion to the on-screen mouse cursor. Such clicks will be perceived as a map move event, not a draw click.

The solution is to hook mousedown rather than click, and track the distance of the motion when mouseup is received.

@jacobtoye
Copy link
Member

Oh this looks pretty cool! Could you pull in the latest changes to get this merge lined up :)

…ittle bit of mouse motion.

The problem is that Leaflet.draw will miss most of the points if one quickly (or even not terribly quickly) tries to draw a shape such as a polygon. This is because clicking using a physical mounse typically introduces a little bit of motion to the on-screen mouse cursor. Such clicks will be perceived as a map move event, not a draw click.

The solution is to hook `mousedown` rather than `click`, and track the distance of the motion when `mouseup` is received.
@atombender
Copy link
Contributor Author

Done — sorry, forgot to fetch before I did the PR.

@Zverik
Copy link
Contributor

Zverik commented Dec 28, 2013

There is a chance this PR will allow drawing on mobile devices (namely on Nokia Browser).

jacobtoye added a commit that referenced this pull request Jan 13, 2014
Improve polyline/polygon drawing by accepting some motion on click
@jacobtoye jacobtoye merged commit fd30a0a into Leaflet:master Jan 13, 2014
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.

3 participants