egovamap 0.12.0 → 0.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/egovamap/egovaBI.js +128 -73
- package/egovamap/egovagisviewer.js +2 -2
- package/egovamap/egovamap.js +2 -2
- package/package.json +1 -1
package/egovamap/egovaBI.js
CHANGED
|
@@ -7,6 +7,21 @@ var egovaBI = function(globeMap, gisMap, mapType){
|
|
|
7
7
|
return b;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
+
function getImgSize(url) {
|
|
11
|
+
return new Promise((resolve, reject) => {
|
|
12
|
+
let img = new Image();
|
|
13
|
+
img.onload = function() {
|
|
14
|
+
resolve({ width: img.width, height: img.height });
|
|
15
|
+
img = null;
|
|
16
|
+
};
|
|
17
|
+
img.onerror = function() {
|
|
18
|
+
resolve({ width: 0, height: 0 });
|
|
19
|
+
img = null;
|
|
20
|
+
};
|
|
21
|
+
img.src = url;
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
10
25
|
function interpolateColor(start, end, count) {
|
|
11
26
|
if (count < 2) return [start, end];
|
|
12
27
|
var r = end[0] - start[0];
|
|
@@ -54,52 +69,19 @@ var egovaBI = function(globeMap, gisMap, mapType){
|
|
|
54
69
|
})
|
|
55
70
|
}
|
|
56
71
|
|
|
57
|
-
function deal2DPoints(layerName, positions, options){
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
style: options.clusterStyle.symbolUrl ? {
|
|
71
|
-
type: "picture-marker",
|
|
72
|
-
url: options.clusterStyle.symbolUrl,
|
|
73
|
-
width: options.clusterStyle.clusterSymbolWidth + "px",
|
|
74
|
-
height: options.clusterStyle.clusterSymbolHeight + "px"
|
|
75
|
-
} : {
|
|
76
|
-
"type": "simple-marker",
|
|
77
|
-
"style": "circle",
|
|
78
|
-
"color": [255, 168, 0, 200],
|
|
79
|
-
"size": 25,
|
|
80
|
-
"outline": { //if outline has been specified
|
|
81
|
-
"color": [255, 168, 0, 200],
|
|
82
|
-
"width": 2
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
labelStyle:{
|
|
86
|
-
type:"text",
|
|
87
|
-
color: options.clusterStyle.fillColor,
|
|
88
|
-
text:"",
|
|
89
|
-
xoffset:options.clusterStyle.textStartX + "px",
|
|
90
|
-
yoffset:options.clusterStyle.textStartY + "px",
|
|
91
|
-
font:{
|
|
92
|
-
size: options.clusterStyle.fontSize + "px",
|
|
93
|
-
weight: options.clusterStyle.fontWeight || "normal",
|
|
94
|
-
family: options.clusterStyle.family || "microsoft-yahei"
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
var hasHover = null;
|
|
101
|
-
var callback = null;
|
|
102
|
-
datalist = positions.map(function(p){
|
|
72
|
+
function deal2DPoints(layerName, positions, options) {
|
|
73
|
+
let datalist = [];
|
|
74
|
+
let zoom = options.common.zoom;
|
|
75
|
+
let clear = options.common.clear;
|
|
76
|
+
let highLightType = -1;
|
|
77
|
+
let infoStyle = null;
|
|
78
|
+
let renderCanvas = null;
|
|
79
|
+
let tagName = layerName;
|
|
80
|
+
let clusterOption = null;
|
|
81
|
+
|
|
82
|
+
let hasHover = null;
|
|
83
|
+
let callback = null;
|
|
84
|
+
datalist = positions.map(function(p) {
|
|
103
85
|
p.minZoom = options.common.beginLevel;
|
|
104
86
|
p.maxZoom = options.common.endLevel;
|
|
105
87
|
p.symbolType = -1;
|
|
@@ -107,41 +89,98 @@ var egovaBI = function(globeMap, gisMap, mapType){
|
|
|
107
89
|
p.scale = options.textStyle.scale;
|
|
108
90
|
p.angle = options.textStyle.angle;
|
|
109
91
|
//textValue
|
|
110
|
-
if(options.textStyle.enableText){
|
|
92
|
+
if (options.textStyle.enableText) {
|
|
111
93
|
p.labelStyle = {
|
|
112
|
-
type:"text",
|
|
113
|
-
xoffset:options.textStyle.xoffset + "px",
|
|
114
|
-
yoffset:options.textStyle.yoffset + "px",
|
|
115
|
-
text:p.textValue,
|
|
116
|
-
color:options.textStyle.fillColor,
|
|
117
|
-
font:{
|
|
94
|
+
type: "text",
|
|
95
|
+
xoffset: options.textStyle.xoffset + "px",
|
|
96
|
+
yoffset: options.textStyle.yoffset + "px",
|
|
97
|
+
text: p.textValue,
|
|
98
|
+
color: options.textStyle.fillColor,
|
|
99
|
+
font: {
|
|
118
100
|
size: options.textStyle.fontSize + "px",
|
|
119
101
|
weight: options.textStyle.fontWeight,
|
|
120
102
|
family: options.textStyle.family || "microsoft-yahei"
|
|
121
103
|
}
|
|
122
|
-
}
|
|
104
|
+
};
|
|
123
105
|
}
|
|
124
106
|
p.useLabelBg = options.textStyle.textBackground;
|
|
125
|
-
if(p.useLabelBg){
|
|
107
|
+
if (p.useLabelBg) {
|
|
126
108
|
p.labelBgStyle = {
|
|
127
|
-
type:
|
|
128
|
-
url:
|
|
129
|
-
}
|
|
109
|
+
type: "picture-marker",
|
|
110
|
+
url: options.textStyle.textBackgroundUrl
|
|
111
|
+
};
|
|
130
112
|
}
|
|
131
113
|
return p;
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return new Promise((resolve, reject) => {
|
|
117
|
+
try {
|
|
118
|
+
let args = {
|
|
119
|
+
datalist: datalist,
|
|
120
|
+
zoom: zoom,
|
|
121
|
+
clear: clear,
|
|
122
|
+
highLightType: highLightType,
|
|
123
|
+
infoStyle: infoStyle,
|
|
124
|
+
renderCanvas: renderCanvas,
|
|
125
|
+
tagName: tagName,
|
|
126
|
+
clusterOption: null,
|
|
127
|
+
hasHover: hasHover,
|
|
128
|
+
callback: callback
|
|
129
|
+
};
|
|
130
|
+
if (options.clusterStyle.clusterEnabled) {
|
|
131
|
+
clusterOption = {
|
|
132
|
+
clusterType: 1,
|
|
133
|
+
distance: options.clusterStyle.clusterDistance,
|
|
134
|
+
style: null,
|
|
135
|
+
labelStyle: {
|
|
136
|
+
type: "text",
|
|
137
|
+
color: options.clusterStyle.fillColor,
|
|
138
|
+
text: "",
|
|
139
|
+
xoffset: options.clusterStyle.textStartX + "px",
|
|
140
|
+
yoffset: options.clusterStyle.textStartY + "px",
|
|
141
|
+
font: {
|
|
142
|
+
size: options.clusterStyle.fontSize + "px",
|
|
143
|
+
weight: options.clusterStyle.fontWeight || "normal",
|
|
144
|
+
family: options.clusterStyle.family || "microsoft-yahei"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
let useCustomClusterStyle = options.clusterStyle.symbolUrl && options.clusterStyle.useCustomStyle;
|
|
150
|
+
let clusterStyle = {
|
|
151
|
+
type: "simple-marker",
|
|
152
|
+
style: "circle",
|
|
153
|
+
color: [255, 168, 0, 200],
|
|
154
|
+
size: 25 * options.clusterStyle.scale + "px",
|
|
155
|
+
outline: {
|
|
156
|
+
color: [255, 168, 0, 200],
|
|
157
|
+
width: 2
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
clusterOption.style = clusterStyle;
|
|
161
|
+
if (useCustomClusterStyle) {
|
|
162
|
+
getImgSize(options.clusterStyle.symbolUrl).then(szie => {
|
|
163
|
+
clusterStyle = {
|
|
164
|
+
type: "picture-marker",
|
|
165
|
+
url: options.clusterStyle.symbolUrl,
|
|
166
|
+
width: szie.width * options.clusterStyle.scale + "px",
|
|
167
|
+
height: szie.height * options.clusterStyle.scale + "px"
|
|
168
|
+
};
|
|
169
|
+
clusterOption.style = clusterStyle;
|
|
170
|
+
args.clusterOption = clusterOption;
|
|
171
|
+
resolve(args);
|
|
172
|
+
});
|
|
173
|
+
} else {
|
|
174
|
+
args.clusterOption = clusterOption;
|
|
175
|
+
resolve(args);
|
|
176
|
+
}
|
|
177
|
+
} else {
|
|
178
|
+
resolve(args);
|
|
179
|
+
}
|
|
180
|
+
} catch (err) {
|
|
181
|
+
reject(err);
|
|
182
|
+
}
|
|
183
|
+
});
|
|
145
184
|
}
|
|
146
185
|
|
|
147
186
|
/*
|
|
@@ -231,8 +270,24 @@ var egovaBI = function(globeMap, gisMap, mapType){
|
|
|
231
270
|
globeMap.drawPoints(layerName, positions, options);
|
|
232
271
|
}
|
|
233
272
|
if(gisMap && mapType == "map"){
|
|
234
|
-
|
|
235
|
-
|
|
273
|
+
deal2DPoints(layerName, positions, options).then(args => {
|
|
274
|
+
gisMap.showMultiObjectCurrentPosition(
|
|
275
|
+
args.datalist,
|
|
276
|
+
args.zoom,
|
|
277
|
+
args.clear,
|
|
278
|
+
args.highLightType,
|
|
279
|
+
args.infoStyle,
|
|
280
|
+
args.renderCanvas,
|
|
281
|
+
options.clickCallback,
|
|
282
|
+
args.tagName,
|
|
283
|
+
args.clusterOption,
|
|
284
|
+
args.hasHover,
|
|
285
|
+
options.mouseOverCallback,
|
|
286
|
+
options.mouseOutCallback,
|
|
287
|
+
layerName,
|
|
288
|
+
options.option
|
|
289
|
+
);
|
|
290
|
+
});
|
|
236
291
|
}
|
|
237
292
|
}
|
|
238
293
|
/*
|
|
@@ -856,7 +856,7 @@ var EGovaGISMap = function ($container, pScene, prefix, gisParams, mapConfig, co
|
|
|
856
856
|
}
|
|
857
857
|
|
|
858
858
|
/* 显示多个自定义图标 */
|
|
859
|
-
that.showMultiObjectCurrentPosition = function (jsonInfo, zoom, bClear, hStyleID, infoStyle, bCanvas, clickCallback, tagName, clusterOption, hasHover, mouseOverCallback, mouseOutCallback) {
|
|
859
|
+
that.showMultiObjectCurrentPosition = function (jsonInfo, zoom, bClear, hStyleID, infoStyle, bCanvas, clickCallback, tagName, clusterOption, hasHover, mouseOverCallback, mouseOutCallback, layerName, options) {
|
|
860
860
|
if (scene == null)
|
|
861
861
|
return;
|
|
862
862
|
|
|
@@ -871,7 +871,7 @@ var EGovaGISMap = function ($container, pScene, prefix, gisParams, mapConfig, co
|
|
|
871
871
|
that.fireCallback(type, data);
|
|
872
872
|
}
|
|
873
873
|
};
|
|
874
|
-
that.callMap('showMultiObjectCurrentPosition', jsonInfo, zoom, bClear, hStyleID, infoStyle, bCanvas, tagName, clusterOption, hasHover, cb);
|
|
874
|
+
that.callMap('showMultiObjectCurrentPosition', jsonInfo, zoom, bClear, hStyleID, infoStyle, bCanvas, tagName, clusterOption, hasHover, cb, layerName, options);
|
|
875
875
|
}
|
|
876
876
|
|
|
877
877
|
/* 高亮显示自定义图标 */
|
package/egovamap/egovamap.js
CHANGED
|
@@ -671,7 +671,7 @@ var EGovaMap = function (containerID, callback, mapConfig, mapType, mapParam, co
|
|
|
671
671
|
if (globeMap != null) {
|
|
672
672
|
globeMap.showLayer(name);
|
|
673
673
|
}
|
|
674
|
-
if (gisMap != null) {
|
|
674
|
+
if (gisMap != null && gisMap.setLayerVisible) {
|
|
675
675
|
var args = [arguments[0], true];
|
|
676
676
|
gisMap.setLayerVisible.apply(this, args);
|
|
677
677
|
}
|
|
@@ -686,7 +686,7 @@ var EGovaMap = function (containerID, callback, mapConfig, mapType, mapParam, co
|
|
|
686
686
|
if (globeMap != null) {
|
|
687
687
|
globeMap.hideLayer(name);
|
|
688
688
|
}
|
|
689
|
-
if (gisMap != null) {
|
|
689
|
+
if (gisMap != null && gisMap.setLayerVisible) {
|
|
690
690
|
var args = [arguments[0], false];
|
|
691
691
|
gisMap.setLayerVisible.apply(this, args);
|
|
692
692
|
}
|