Subversion Repositories eFlore/Applications.moissonnage

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 delphine 1
/*
2
 * Based on comments by @runanet and @coomsie
3
 * https://github.com/CloudMade/Leaflet/issues/386
4
 *
5
 * Wrapping function is needed to preserve L.Marker.update function
6
 */
7
(function () {
8
var _old_update = L.Marker.prototype.update;
9
L.Marker.include({
10
	update: function() {
11
		this._icon.style[L.DomUtil.TRANSFORM] = "";
12
		_old_update.apply(this, []);
13
 
14
		if (this.options.iconAngle) {
15
			var a = this.options.icon.options.iconAnchor;
16
			var s = this.options.icon.options.iconSize;
17
			a = L.point(s).divideBy(2)._subtract(L.point(a));
18
			var transform = '';
19
			transform += ' translate(' + -a.x + 'px, ' + -a.y + 'px)';
20
			transform += ' rotate(' + this.options.iconAngle + 'deg)';
21
			transform += ' translate(' + a.x + 'px, ' + a.y + 'px)';
22
			this._icon.style[L.DomUtil.TRANSFORM] += transform;
23
		}
24
	},
25
 
26
	setIconAngle: function (iconAngle) {
27
		this.options.iconAngle = iconAngle;
28
 
29
		if (this._map) this.update();
30
	}
31
});
32
}());