summaryrefslogtreecommitdiff
path: root/js/dojo-1.7.2/dojox/geo/charting/_Marker.js
blob: 28bf227308f9d10b3a6f12e5f9e37e5097f68761 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//>>built

define("dojox/geo/charting/_Marker", ["dojo/_base/lang","dojo/_base/array", "dojo/_base/declare","dojo/_base/sniff","./_base"], 
	function(lang, arr, declare, has) {
return declare("dojox.geo.charting._Marker", null, {
	
	_needTooltipRefresh: null,
	_map: null,
	
	constructor: function(markerData, map){
		this._map = map;
		var mapObj = map.mapObj;
		this.features = mapObj.features;
		this.markerData = markerData;
		_needTooltipRefresh = false;
	},

	show: function(featureId,evt){
		this.currentFeature = this.features[featureId];
		if (this._map.showTooltips && this.currentFeature) {
			this.markerText = this.currentFeature.markerText || this.markerData[featureId] || featureId;
			dojox.geo.charting.showTooltip(this.markerText, this.currentFeature.shape, ["before"]);
		}
		this._needTooltipRefresh = false;
	},

	hide: function(){
		if (this._map.showTooltips && this.currentFeature)
			dojox.geo.charting.hideTooltip(this.currentFeature.shape);
		this._needTooltipRefresh = false;
	},

	_getGroupBoundingBox: function(group){
		var shapes = group.children;
		var feature = shapes[0];
		var bbox = feature.getBoundingBox();
		this._arround = lang.clone(bbox);
		arr.forEach(shapes, function(item){
			var _bbox = item.getBoundingBox();
			this._arround.x = Math.min(this._arround.x, _bbox.x);
			this._arround.y = Math.min(this._arround.y, _bbox.y);
		},this);
	},

	_toWindowCoords: function(arround, coords, containerSize){
		var toLeft = (arround.x - this.topLeft[0]) * this.scale;
		var toTop = (arround.y - this.topLeft[1]) * this.scale
		if (has("ff") == 3.5) {
			arround.x = coords.x;
			arround.y = coords.y;
		}
		else if (has("chrome")) {
			arround.x = containerSize.x + toLeft;
			arround.y = containerSize.y + toTop;
		}
		else {
			arround.x = coords.x + toLeft;
			arround.y = coords.y + toTop;
		}
		arround.width = (this.currentFeature._bbox[2]) * this.scale;
		arround.height = (this.currentFeature._bbox[3]) * this.scale;
		arround.x += arround.width / 6;
		arround.y += arround.height / 4;
	}
});
});