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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222 | 1×
1×
1×
1×
96×
96×
96×
1×
3742×
3742×
3742×
3742×
3742×
3742×
3742×
3742×
3742×
1016×
2726×
2726×
2726×
2726×
2726×
2726×
2726×
2726×
2726×
2726×
2726×
234292×
234292×
234292×
234292×
234292×
234292×
44278×
27571×
27571×
27571×
3373×
3373×
16707×
16707×
170093×
170093×
170093×
6752×
6752×
2726×
2726×
2726×
2726×
2726×
2726×
2726×
2718×
2718×
8×
8×
8×
2718×
2718×
13×
2705×
2705×
2705×
2646×
2646×
59×
59×
59×
59×
59×
2705×
2705×
2705×
2705×
2705×
4×
2701×
2705×
2705×
2705×
2705×
2705×
2705×
2705×
59×
59×
2646×
2705×
2042×
1×
197664×
197664×
27141683×
197664×
1×
1×
60×
60×
60×
60×
19×
19×
19×
19×
19×
19×
41×
1×
66×
66×
6×
60×
60×
41×
19×
19×
1×
3430×
1×
95×
95×
1×
1×
| define(["require", "exports", "../index", "../index", "@syncfusion/ej2-base", "../utils/helper", "../utils/helper"], function (require, exports, index_1, index_2, ej2_base_1, helper_1, helper_2) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var Bubble = (function () {
function Bubble(maps) {
this.id = '';
this.maps = maps;
this.bubbleCollection = [];
}
Bubble.prototype.renderBubble = function (bubbleSettings, shapeData, color, range, bubbleIndex, dataIndex, layerIndex, layer, group, bubbleID) {
var _this = this;
var layerData = layer.layerData;
var colorValuePath = bubbleSettings.colorValuePath;
var equalValue = (!ej2_base_1.isNullOrUndefined(colorValuePath)) ? ((colorValuePath.indexOf('.') > -1) ?
(helper_2.getValueFromObject(shapeData, bubbleSettings.colorValuePath)) : shapeData[colorValuePath]) :
shapeData[colorValuePath];
var colorValue = (!ej2_base_1.isNullOrUndefined(colorValuePath)) ? ((colorValuePath.indexOf('.') > -1) ?
Number(helper_2.getValueFromObject(shapeData, bubbleSettings.colorValuePath)) : Number(shapeData[colorValuePath])) :
Number(shapeData[colorValuePath]);
var bubbleValue = (!ej2_base_1.isNullOrUndefined(bubbleSettings.valuePath)) ? ((bubbleSettings.valuePath.indexOf('.') > -1) ?
Number(helper_2.getValueFromObject(shapeData, bubbleSettings.valuePath)) : Number(shapeData[bubbleSettings.valuePath])) :
Number(shapeData[bubbleSettings.valuePath]);
var opacity;
var bubbleColor;
if (isNaN(bubbleValue) && isNaN(colorValue) && ej2_base_1.isNullOrUndefined(equalValue)) {
return null;
}
var radius = helper_2.getRatioOfBubble(bubbleSettings.minRadius, bubbleSettings.maxRadius, bubbleValue, range.min, range.max);
var colorMapping = new index_1.ColorMapping(this.maps);
var shapeColor = colorMapping.getColorByValue(bubbleSettings.colorMapping, colorValue, equalValue);
bubbleColor = (Object.prototype.toString.call(shapeColor) === '[object Object]' &&
!ej2_base_1.isNullOrUndefined(shapeColor['fill'])) ? shapeColor['fill'] : color;
opacity = (Object.prototype.toString.call(shapeColor) === '[object Object]' &&
!ej2_base_1.isNullOrUndefined(shapeColor['opacity'])) ? shapeColor['opacity'] : bubbleSettings.opacity;
var shapePoints = [[]];
this.maps.translateType = 'bubble';
var midIndex = 0;
var pointsLength = 0;
var currentLength = 0;
for (var i = 0, len = layerData.length; i < len; i++) {
var shape = layerData[i];
shape = shape['property'];
var shapePath = helper_2.checkPropertyPath(shapeData[layer.shapeDataPath], layer.shapePropertyPath, shape);
var shapeDataLayerPathValue = !ej2_base_1.isNullOrUndefined(shapeData[layer.shapeDataPath]) &&
isNaN(shapeData[layer.shapeDataPath]) ? shapeData[layer.shapeDataPath].toLowerCase() : shapeData[layer.shapeDataPath];
var shapePathValue = !ej2_base_1.isNullOrUndefined(shape[shapePath]) && isNaN(shape[shapePath])
? shape[shapePath].toLowerCase() : shape[shapePath];
if (shapeDataLayerPathValue === shapePathValue && (layerData[i].type !== 'LineString' && layerData[i].type !== 'MultiLineString' && layerData[i]['type'] !== 'Point' && layerData[i]['type'] !== 'MultiPoint')) {
if (!layerData[i]['_isMultiPolygon']) {
shapePoints.push(this.getPoints(layerData[i], []));
currentLength = shapePoints[shapePoints.length - 1].length;
if (pointsLength < currentLength) {
pointsLength = currentLength;
midIndex = shapePoints.length - 1;
}
}
else {
var layer_1 = layerData[i];
for (var j = 0; j < layer_1.length; j++) {
shapePoints.push(this.getPoints(layer_1[j], []));
currentLength = shapePoints[shapePoints.length - 1].length;
if (pointsLength < currentLength) {
pointsLength = currentLength;
midIndex = shapePoints.length - 1;
}
}
}
}
}
var projectionType = this.maps.projectionType;
var centerY;
var eventArgs;
var bubbleBorder = {
color: bubbleSettings.border.color, opacity: bubbleSettings.border.opacity,
width: bubbleSettings.border.width
};
var center = helper_1.findMidPointOfPolygon(shapePoints[midIndex], projectionType, layer.geometryType);
Eif (bubbleSettings.visible) {
if (!ej2_base_1.isNullOrUndefined(center)) {
centerY = this.maps.projectionType === 'Mercator' ? center['y'] : (-center['y']);
eventArgs = {
cancel: false, name: index_1.bubbleRendering, border: bubbleBorder,
cx: center['x'], cy: centerY, data: shapeData, fill: bubbleColor,
maps: this.maps, radius: radius
};
}
else {
var shapePointsLength = shapePoints.length - 1;
Iif (shapePoints[shapePointsLength]['x'] && shapePoints[shapePointsLength]['y']) {
eventArgs = {
cancel: false, name: index_1.bubbleRendering, border: bubbleBorder,
cx: shapePoints[shapePointsLength]['x'], cy: shapePoints[shapePointsLength]['y'],
data: shapeData, fill: bubbleColor, maps: this.maps,
radius: radius
};
}
else {
return;
}
}
this.maps.trigger('bubbleRendering', eventArgs, function (bubbleArgs) {
if (eventArgs.cancel) {
return;
}
var bubbleElement;
eventArgs.border.opacity = ej2_base_1.isNullOrUndefined(eventArgs.border.opacity) ? opacity : eventArgs.border.opacity;
if (bubbleSettings.bubbleType === 'Circle') {
var circle = new helper_1.CircleOption(bubbleID, eventArgs.fill, eventArgs.border, opacity, 0, 0, eventArgs.radius, null);
bubbleElement = helper_1.drawCircle(_this.maps, circle, group);
}
else {
var y = _this.maps.projectionType === 'Mercator' ? (eventArgs.cy - radius) : (eventArgs.cy + radius);
var rectangle = new helper_2.RectOption(bubbleID, eventArgs.fill, eventArgs.border, opacity, new helper_2.Rect(0, 0, radius * 2, radius * 2), 2, 2);
eventArgs.cx -= radius;
eventArgs.cy = y;
bubbleElement = helper_2.drawRectangle(_this.maps, rectangle, group);
}
helper_2.maintainSelection(_this.maps.selectedBubbleElementId, _this.maps.bubbleSelectionClass, bubbleElement, 'BubbleselectionMapStyle');
_this.bubbleCollection.push({
LayerIndex: layerIndex,
BubbleIndex: bubbleIndex,
DataIndex: dataIndex,
element: bubbleElement,
center: { x: eventArgs.cx, y: eventArgs.cy }
});
var translate;
var animate = (layer.animationDuration !== 0 || ej2_base_1.animationMode === 'Enable') || ej2_base_1.isNullOrUndefined(_this.maps.zoomModule);
if (_this.maps.zoomSettings.zoomFactor > 1 && !ej2_base_1.isNullOrUndefined(_this.maps.zoomModule) && !_this.maps.isTileMap) {
translate = helper_2.getZoomTranslate(_this.maps, layer, animate);
}
else {
translate = helper_1.getTranslate(_this.maps, layer, animate);
}
var bubbleDataSource = bubbleSettings.dataSource;
var scale = translate['scale'];
var transPoint = translate['location'];
var position = new helper_1.MapLocation((_this.maps.isTileMap ? ((eventArgs.cx + _this.maps.translatePoint.x) * _this.maps.tileZoomLevel)
: ((eventArgs.cx + transPoint.x) * scale)), (_this.maps.isTileMap ? ((eventArgs.cy + _this.maps.translatePoint.y) * _this.maps.tileZoomLevel)
: ((eventArgs.cy + transPoint.y) * scale)));
bubbleElement.setAttribute('transform', 'translate( ' + (position.x) + ' ' + (position.y) + ' )');
var bubble = (bubbleDataSource.length - 1) === dataIndex ? 'bubble' : null;
if (bubbleSettings.bubbleType === 'Square') {
position.x += radius;
position.y += radius * (_this.maps.projectionType === 'Mercator' ? 1 : -1);
}
else {
radius = 0;
}
if (bubbleSettings.animationDuration > 0 || ej2_base_1.animationMode === 'Enable') {
helper_1.elementAnimate(bubbleElement, bubbleSettings.animationDelay, bubbleSettings.animationDuration, position, _this.maps, bubble, radius);
}
});
}
};
Bubble.prototype.getPoints = function (shape, points) {
Iif (ej2_base_1.isNullOrUndefined(shape.map)) {
points = shape['point'];
}
else {
shape.map(function (current) {
points.push(new helper_1.Point(current['point']['x'], current['point']['y']));
});
}
return points;
};
Bubble.prototype.bubbleClick = function (e) {
var target = e.target.id;
if (target.indexOf('_LayerIndex_') === -1) {
return;
}
var data = this.getbubble(target);
if (ej2_base_1.isNullOrUndefined(data)) {
return;
}
var eventArgs = {
cancel: false, name: index_2.bubbleClick, data: data, maps: this.maps,
target: target, x: e.clientX, y: e.clientY
};
this.maps.trigger(index_2.bubbleClick, eventArgs);
};
Bubble.prototype.getbubble = function (target) {
var id = target.split('_LayerIndex_');
var index = parseInt(id[1].split('_')[0], 10);
var data;
if (target.indexOf('_BubbleIndex_') > -1) {
var layer = this.maps.layers[index];
var bubbleIndex = parseInt(id[1].split('_BubbleIndex_')[1], 10);
var dataIndex = parseInt(id[1].split('_BubbleIndex_')[1].split('_dataIndex_')[1], 10);
Eif (!isNaN(bubbleIndex)) {
data = layer.bubbleSettings[bubbleIndex].dataSource[dataIndex];
return data;
}
}
return null;
};
Bubble.prototype.bubbleMove = function (e) {
var target = e.target.id;
if (target.indexOf('_LayerIndex_') === -1) {
return;
}
var data = this.getbubble(target);
if (ej2_base_1.isNullOrUndefined(data)) {
return;
}
var eventArgs = {
cancel: false, name: index_2.bubbleMouseMove, data: data, maps: this.maps,
target: target, x: e.clientX, y: e.clientY
};
this.maps.trigger(index_2.bubbleMouseMove, eventArgs);
};
Bubble.prototype.getModuleName = function () {
return 'Bubble';
};
Bubble.prototype.destroy = function () {
this.bubbleCollection = [];
this.maps = null;
};
return Bubble;
}());
exports.Bubble = Bubble;
});
|