diff --git a/leaflet.rotatedMarker.js b/leaflet.rotatedMarker.js index d187645..77d0bdb 100644 --- a/leaflet.rotatedMarker.js +++ b/leaflet.rotatedMarker.js @@ -2,6 +2,7 @@ // save these original methods before they are overwritten var proto_initIcon = L.Marker.prototype._initIcon; var proto_setPos = L.Marker.prototype._setPos; + var proto_onDrag = L.Handler.MarkerDrag.prototype._onDrag; var oldIE = (L.DomUtil.TRANSFORM === 'msTransform'); @@ -22,7 +23,10 @@ _setPos: function (pos) { proto_setPos.call(this, pos); + this._applyRotation(); + }, + _applyRotation: function () { if(this.options.rotationAngle) { this._icon.style[L.DomUtil.TRANSFORM+'Origin'] = this.options.rotationOrigin; @@ -48,4 +52,11 @@ return this; } }); + + L.Handler.MarkerDrag.include({ + _onDrag: function (e) { + proto_onDrag.call(this, e); + this._marker._applyRotation(); + } + }) })();