Subversion Repositories eFlore/Applications.moissonnage

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
6 delphine 1
L.Icon.Text = L.Icon.extend({
2
	initialize: function (text, options) {
3
		this._text = text;
4
		L.Icon.prototype.initialize.apply(this, [options]);
5
	},
6
 
7
	createIcon: function() {
8
		var el = document.createElement('div');
9
		el.appendChild(document.createTextNode(this._text));
10
		this._setIconStyles(el, 'icon');
11
		el.style.textShadow = "2px 2px 2px #fff";
12
		return el;
13
	},
14
 
15
	createShadow: function() { return null; }
16
 
17
});
18
 
19
L.Marker.Text = L.Marker.extend({
20
	initialize: function (latlng, text, options) {
21
        	L.Marker.prototype.initialize.apply(this, [latlng, options]);
22
		this._fakeicon = new L.Icon.Text(text);
23
	},
24
 
25
	_initIcon: function() {
26
        	L.Marker.prototype._initIcon.apply(this);
27
 
28
		var i = this._icon, s = this._shadow, obj = this.options.icon
29
		this._icon = this._shadow = null;
30
 
31
		this.options.icon = this._fakeicon;
32
        	L.Marker.prototype._initIcon.apply(this);
33
		this.options.icon = obj;
34
 
35
		if (s) {
36
			s.parentNode.removeChild(s);
37
			this._icon.appendChild(s);
38
		}
39
 
40
		i.parentNode.removeChild(i);
41
		this._icon.appendChild(i);
42
 
43
		var w = this._icon.clientWidth, h = this._icon.clientHeight;
44
		this._icon.style.marginLeft = -w / 2 + "px";
45
		//this._icon.style.backgroundColor = "red";
46
		var off = new L.Point(w/2, 0);
47
		if (L.Browser.webkit) off.y = -h;
48
		L.DomUtil.setPosition(i, off);
49
		if (s) L.DomUtil.setPosition(s, off);
50
	}
51
});