2 * Based on comments by @runanet and @coomsie
3 * https://github.com/CloudMade/Leaflet/issues/386
5 * Wrapping function is needed to preserve L.Marker.update function
8 var _old__setPos
= L
.Marker
.prototype._setPos
;
10 _updateImg: function(i
, a
, s
) {
11 a
= L
.point(s
).divideBy(2)._subtract(L
.point(a
));
13 transform
+= ' translate(' + -a
.x
+ 'px, ' + -a
.y
+ 'px)';
14 transform
+= ' rotate(' + this.options
.iconAngle
+ 'deg)';
15 transform
+= ' translate(' + a
.x
+ 'px, ' + a
.y
+ 'px)';
16 i
.style
[L
.DomUtil
.TRANSFORM
] += transform
;
19 setIconAngle: function (iconAngle
) {
20 this.options
.iconAngle
= iconAngle
;
25 _setPos: function (pos
) {
27 this._icon
.style
[L
.DomUtil
.TRANSFORM
] = '';
29 this._shadow
.style
[L
.DomUtil
.TRANSFORM
] = '';
31 _old__setPos
.apply(this,[pos
]);
33 if (this.options
.iconAngle
) {
34 var a
= this.options
.icon
.options
.iconAnchor
;
35 var s
= this.options
.icon
.options
.iconSize
;
39 this._updateImg(i
, a
, s
);
42 if (this.options
.icon
.options
.shadowAnchor
)
43 a
= this.options
.icon
.options
.shadowAnchor
;
44 s
= this.options
.icon
.options
.shadowSize
;
46 this._updateImg(i
, a
, s
);