Skip to content

Commit 59c812e

Browse files
committed
【fix】 修复SecurityManage API问题 修复openlayers mapv webgl绘制时的偏移问题 review by qiwei
1 parent f4beee5 commit 59c812e

File tree

8 files changed

+892
-673
lines changed

8 files changed

+892
-673
lines changed

dist/openlayers/iclient9-openlayers-es6.js

Lines changed: 685 additions & 605 deletions
Large diffs are not rendered by default.

dist/openlayers/iclient9-openlayers-es6.min.js

Lines changed: 10 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/openlayers/iclient9-openlayers.js

Lines changed: 116 additions & 32 deletions
Large diffs are not rendered by default.

dist/openlayers/iclient9-openlayers.min.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/common/security/SecurityManager.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export class SecurityManager {
2020

2121
/**
2222
* @description 从服务器获取一个token,在此之前要注册服务器信息。
23+
* @function SuperMap.SecurityManager.generateToken
2324
* @param {string} url - 服务器域名+端口,如:http://localhost:8092。
2425
* @param {SuperMap.TokenServiceParameter} tokenParam - token 申请参数。
2526
* @returns {Promise} 返回包含 token 信息的 Promise 对象。
@@ -37,6 +38,7 @@ export class SecurityManager {
3738

3839
/**
3940
* @description 注册安全服务器相关信息。
41+
* @function SuperMap.SecurityManager.registerServers
4042
* @param {SuperMap.ServerInfo} serverInfos - 服务器信息。
4143
*/
4244
static registerServers(serverInfos) {
@@ -52,6 +54,7 @@ export class SecurityManager {
5254

5355
/**
5456
* @description 服务请求都会自动带上这个 token。
57+
* @function SuperMap.SecurityManager.registerToken
5558
* @param {string} url -服务器域名+端口:如http://localhost:8090。
5659
* @param {string} token - token
5760
*/
@@ -66,6 +69,7 @@ export class SecurityManager {
6669

6770
/**
6871
* @description 注册 key,ids 为数组(存在一个 key 对应多个服务)。
72+
* @function SuperMap.SecurityManager.registerKey
6973
* @param {Array} ids - 可以是服务 id 数组或者 url 地址数组或者 webAPI 类型数组。
7074
* @param {string} key - key
7175
*/
@@ -84,6 +88,7 @@ export class SecurityManager {
8488

8589
/**
8690
* @description 获取服务器信息。
91+
* @function SuperMap.SecurityManager.getServerInfo
8792
* @param {string} url - 服务器域名+端口,如:http://localhost:8092。
8893
* @returns {SuperMap.ServerInfo} 服务器信息。
8994
*/
@@ -94,6 +99,7 @@ export class SecurityManager {
9499

95100
/**
96101
* @description 根据 Url 获取token。
102+
* @function SuperMap.SecurityManager.getToken
97103
* @param {string} url - 服务器域名+端口,如:http://localhost:8092。
98104
* @returns {string} token
99105
*/
@@ -108,6 +114,7 @@ export class SecurityManager {
108114

109115
/**
110116
* @description 根据 Url 获取 key。
117+
* @function SuperMap.SecurityManager.getKey
111118
* @param {string} id - id
112119
* @returns {string} key
113120
*/
@@ -119,6 +126,7 @@ export class SecurityManager {
119126

120127
/**
121128
* @description iServer 登录验证。
129+
* @function SuperMap.SecurityManager.loginiServer
122130
* @param {string} url - iServer 首页地址,如:http://localhost:8090/iserver。
123131
* @param {string} username - 用户名。
124132
* @param {string} password - 密码。
@@ -147,6 +155,7 @@ export class SecurityManager {
147155

148156
/**
149157
* @description iServer登出。
158+
* @function SuperMap.SecurityManager.logoutiServer
150159
* @param {string} url - iServer 首页地址,如:http://localhost:8090/iserver。
151160
* @returns {Promise} 是否登出成功。
152161
*/
@@ -170,6 +179,7 @@ export class SecurityManager {
170179

171180
/**
172181
* @description Online 登录验证。
182+
* @function SuperMap.SecurityManager.loginOnline
173183
* @param {string} callbackLocation - 跳转位置。
174184
* @param {boolean} [newTab=true] - 是否新窗口打开。
175185
*/
@@ -180,7 +190,8 @@ export class SecurityManager {
180190

181191
/**
182192
* @description iPortal登录验证。
183-
* @param {string} url - iportal 首页地址。
193+
* @function SuperMap.SecurityManager.loginiPortal
194+
* @param {string} url - iportal 首页地址,如:http://localhost:8092/iportal.
184195
* @param {string} username - 用户名。
185196
* @param {string} password - 密码。
186197
* @returns {Promise} 返回包含 iPortal 登录请求结果的 Promise 对象。
@@ -207,7 +218,8 @@ export class SecurityManager {
207218

208219
/**
209220
* @description iPortal 登出。
210-
* @param {string} url - iportal 首页地址。
221+
* @function SuperMap.SecurityManager.logoutiPortal
222+
* @param {string} url - iportal 首页地址,如:http://localhost:8092/iportal.
211223
* @returns {Promise} 如果登出成功,返回 true;否则返回 false。
212224
*/
213225
static logoutiPortal(url) {
@@ -231,6 +243,7 @@ export class SecurityManager {
231243

232244
/**
233245
* @description iManager 登录验证。
246+
* @function SuperMap.SecurityManager.loginManager
234247
* @param {string} url - iManager 地址。地址参数为 iManager 首页地址,如: http://localhost:8390/imanager。
235248
* @param {Object} [loginInfoParams] - iManager 登录参数。
236249
* @param {string} loginInfoParams.userName - 用户名。
@@ -270,6 +283,7 @@ export class SecurityManager {
270283

271284
/**
272285
* @description 清空全部验证信息。
286+
* @function SuperMap.SecurityManager.destroyAllCredentials
273287
*/
274288
static destroyAllCredentials() {
275289
this.keys = null;
@@ -279,6 +293,8 @@ export class SecurityManager {
279293

280294
/**
281295
* @description 清空令牌信息。
296+
* @function SuperMap.SecurityManager.destroyToken
297+
* @param {string} url - iportal 首页地址,如:http://localhost:8092/iportal.
282298
*/
283299
static destroyToken(url) {
284300
if (!url) {
@@ -293,13 +309,15 @@ export class SecurityManager {
293309

294310
/**
295311
* @description 清空服务授权码。
312+
* @function SuperMap.SecurityManager.destroyKey
313+
* @param {string} url - iServer 首页地址,如:http://localhost:8090/iserver。
296314
*/
297-
static destroyKey(id) {
298-
if (!id) {
315+
static destroyKey(url) {
316+
if (!url) {
299317
return;
300318
}
301319
this.keys = this.keys || {};
302-
var key = this._getUrlRestString(id) || id;
320+
var key = this._getUrlRestString(url) || url;
303321
if (this.keys[key]) {
304322
delete this.keys[key];
305323
}

src/common/util/ArrayStatistic.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {
22
SuperMap
33
} from '../SuperMap';
4+
45
export class ArrayStatistic {
56

67
// geostatsInstance: null,

src/openlayers/overlay/mapv/MapvCanvasLayer.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,17 @@ export class MapvCanvasLayer {
3636
canvas.className = "mapvClass";
3737
var global$2 = typeof window === 'undefined' ? {} : window;
3838
var devicePixelRatio = me.devicePixelRatio = global$2.devicePixelRatio;
39+
this.devicePixelRatio = devicePixelRatio;
3940
canvas.width = parseInt(me.width) * devicePixelRatio;
4041
canvas.height = parseInt(me.height) * devicePixelRatio;
4142
if (me.context == '2d') {
4243
canvas.getContext(me.context).scale(devicePixelRatio, devicePixelRatio);
4344
}
4445
canvas.style.width = me.width + "px";
4546
canvas.style.height = me.height + "px";
47+
if (this.context == 'webgl') {
48+
this.canvas.getContext(this.context).viewport(0, 0, canvas.width, canvas.height)
49+
}
4650
}
4751

4852
/**
@@ -60,15 +64,19 @@ export class MapvCanvasLayer {
6064
* @description 调整地图大小。
6165
*/
6266
resize(mapWidth, mapHeight) {
67+
console.log("resize");
6368
var global$2 = typeof window === 'undefined' ? {} : window;
6469
var devicePixelRatio = this.devicePixelRatio = global$2.devicePixelRatio;
65-
this.canvas.width = mapWidth * devicePixelRatio;
66-
this.canvas.height = mapHeight * devicePixelRatio;
70+
this.canvas.width = mapWidth * devicePixelRatio;
71+
this.canvas.height = mapHeight * devicePixelRatio;
6772
if (this.context == '2d') {
6873
this.canvas.getContext('2d').scale(devicePixelRatio, devicePixelRatio);
6974
}
7075
this.canvas.style.width = mapWidth + "px";
7176
this.canvas.style.height = mapHeight + "px";
77+
if (this.context == 'webgl') {
78+
this.canvas.getContext(this.context).viewport(0, 0, this.canvas.width, this.canvas.height)
79+
}
7280
}
7381

7482
/**

src/openlayers/overlay/mapv/MapvLayer.js

Lines changed: 39 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22
* This program are made available under the terms of the Apache License, Version 2.0
33
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
44
import ol from 'openlayers';
5-
import {MapvCanvasLayer} from './MapvCanvasLayer';
6-
import {baiduMapLayer} from "mapv";
5+
import {
6+
MapvCanvasLayer
7+
} from './MapvCanvasLayer';
8+
import {
9+
baiduMapLayer
10+
} from "mapv";
711

812
var BaiduMapLayer = baiduMapLayer ? baiduMapLayer.__proto__ : Function;
913

@@ -86,7 +90,10 @@ export class MapvLayer extends BaiduMapLayer {
8690
*/
8791
clickEvent(e) {
8892
var pixel = e.pixel;
89-
super.clickEvent({x: pixel[0] + this.offset[0], y: pixel[1] + this.offset[1]}, e);
93+
super.clickEvent({
94+
x: pixel[0] + this.offset[0],
95+
y: pixel[1] + this.offset[1]
96+
}, e);
9097
}
9198

9299
/**
@@ -96,7 +103,10 @@ export class MapvLayer extends BaiduMapLayer {
96103
*/
97104
mousemoveEvent(e) {
98105
var pixel = e.pixel;
99-
super.mousemoveEvent({x: pixel[0], y: pixel[1]}, e);
106+
super.mousemoveEvent({
107+
x: pixel[0],
108+
y: pixel[1]
109+
}, e);
100110
}
101111

102112
/**
@@ -191,7 +201,9 @@ export class MapvLayer extends BaiduMapLayer {
191201
_data = data.get();
192202
}
193203
this.dataSet.add(_data);
194-
this.update({options: options});
204+
this.update({
205+
options: options
206+
});
195207
}
196208

197209
/**
@@ -209,7 +221,9 @@ export class MapvLayer extends BaiduMapLayer {
209221
if (_data != undefined) {
210222
this.dataSet.set(_data);
211223
}
212-
super.update({options: update.options});
224+
super.update({
225+
options: update.options
226+
});
213227
}
214228

215229
draw() {
@@ -239,7 +253,9 @@ export class MapvLayer extends BaiduMapLayer {
239253
}
240254
});
241255
this.dataSet.set(newData);
242-
this.update({options: null});
256+
this.update({
257+
options: null
258+
});
243259
}
244260

245261
/**
@@ -248,7 +264,9 @@ export class MapvLayer extends BaiduMapLayer {
248264
*/
249265
clearData() {
250266
this.dataSet && this.dataSet.clear();
251-
this.update({options: null});
267+
this.update({
268+
options: null
269+
});
252270
}
253271

254272
_canvasUpdate(time) {
@@ -288,20 +306,26 @@ export class MapvLayer extends BaiduMapLayer {
288306
self._mapCenterPx = map.getPixelFromCoordinate(self._mapCenter);
289307
self._reselutions = map.getView().getResolution();
290308
self._rotation = -map.getView().getRotation();
291-
309+
var scaleRatio = 1;
310+
if (this.context != '2d') {
311+
var global$2 = typeof window === 'undefined' ? {} : window;
312+
var devicePixelRatio = global$2.devicePixelRatio;
313+
scaleRatio = devicePixelRatio;
314+
315+
}
292316
var dataGetOptions = {
293317
transferCoordinate: function (coordinate) {
294318
var x = (coordinate[0] - self._mapCenter[0]) / self._reselutions,
295319
y = (self._mapCenter[1] - coordinate[1]) / self._reselutions;
296320
var scaledP = [x + self._mapCenterPx[0], y + self._mapCenterPx[1]];
297-
scaledP = scale(scaledP, self._mapCenterPx,1);
321+
scaledP = scale(scaledP, self._mapCenterPx, 1);
298322
/*//有旋转量的时候处理旋转
299323
if (self._rotation !== 0) {
300324
var rotatedP = rotate(scaledP, self._rotation, self._mapCenterPx);
301325
return [rotatedP[0] + self.offset[0], rotatedP[1] + self.offset[1]];
302326
}
303327
//处理放大或缩小级别*/
304-
return [scaledP[0] + self.offset[0], scaledP[1] + self.offset[1]];
328+
return [(scaledP[0] + self.offset[0]) * scaleRatio, (scaledP[1] + self.offset[1]) * scaleRatio];
305329
}
306330
};
307331

@@ -334,7 +358,10 @@ export class MapvLayer extends BaiduMapLayer {
334358
self.options._size = self.options.size;
335359
var pixel = map.getPixelFromCoordinate([0, 0]);
336360
pixel = [pixel[0] - topLeftPx[0], pixel[1] - topLeftPx[1]];
337-
this.drawContext(context, data, self.options, {x: pixel[0], y: pixel[1]});
361+
this.drawContext(context, data, self.options, {
362+
x: pixel[0],
363+
y: pixel[1]
364+
});
338365
if (self.isEnabledTime()) {
339366
this.source.changed();
340367
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy