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

Apply rotation transformation on marker drag. #10

Merged
merged 1 commit into from
Nov 11, 2016

Conversation

Andrew-SK
Copy link

Potential fix for issue #9

During marker drag events the _setPos method is bypassed in favour of
setting the marker._latlng property directly. In order to account for
this the rotation must be applied after the MarkerDrag._onDrag method.
This is called repeatedly during the movement.

During marker drag events the _setPos method is bypassed in favour of
setting the marker._latlng property directly. In order to account for
this the rotation must be applied after the MarkerDrag._onDrag method.
This is called repeatedly during the movement.
@Andrew-SK
Copy link
Author

I realised it might be simpler to call marker.update() on the drag event, i.e.:

L.Handler.MarkerDrag.include({
    _onDrag: function (e) {
        proto_onDrag.call(this, e);
        this._marker.update();
    }
}

Rather than moving code into the _applyRotation method. I don't know if this would have any adverse effects.

@bbecquet
Copy link
Owner

Hi @Andrew-SK. Thanks for this great fix!
If I'm not mistaken by the Leaflet Marker update workflow, the alternative solution would call _setPos twice, which would result in coordinates being uselessly reprojected. So I'll merge the PR as-is. BTW, it's more explicit about what it does, so I like it 🙂

@bbecquet bbecquet merged commit fabdae0 into bbecquet:master Nov 11, 2016
@Andrew-SK Andrew-SK deleted the fix-draggable-marker-rotation branch November 12, 2016 05:39
@Andrew-SK
Copy link
Author

No worries, happy to help! 🙂

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.

2 participants