Skip to content

Commit 438e944

Browse files
committed
openlaeyrs 添加online和iportal安全认证示例
1 parent 35fb3ff commit 438e944

18 files changed

+748
-70
lines changed

dist/iclient-classic.js

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1657,15 +1657,21 @@ var CommonServiceBase = function () {
16571657
timeout: options.async ? 0 : null,
16581658
proxy: options.proxy
16591659
}).then(function (response) {
1660-
return response.text();
1660+
if (response.text) {
1661+
return response.text();
1662+
}
1663+
return response.json();
16611664
}).then(function (text) {
1662-
var result = new _SuperMap2.default.Format.JSON().read(text);
1663-
if (!result) {
1664-
result = { error: text };
1665+
var result = text;
1666+
if (typeof text === "string") {
1667+
result = new _SuperMap2.default.Format.JSON().read(text);
1668+
}
1669+
if (!result || result.error || result.code >= 300 && result.code !== 304) {
1670+
result = { error: result };
16651671
}
16661672
if (result.error) {
16671673
var failure = options.scope ? _SuperMap2.default.Function.bind(options.failure, options.scope) : options.failure;
1668-
failure(result.error);
1674+
failure(result);
16691675
} else {
16701676
result.succeed = result.succeed == undefined ? true : result.succeed;
16711677
var success = options.scope ? _SuperMap2.default.Function.bind(options.success, options.scope) : options.success;

dist/iclient-classic.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/iclient9-leaflet.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,15 +1464,21 @@ var CommonServiceBase = function () {
14641464
timeout: options.async ? 0 : null,
14651465
proxy: options.proxy
14661466
}).then(function (response) {
1467-
return response.text();
1467+
if (response.text) {
1468+
return response.text();
1469+
}
1470+
return response.json();
14681471
}).then(function (text) {
1469-
var result = new _SuperMap2["default"].Format.JSON().read(text);
1470-
if (!result) {
1471-
result = { error: text };
1472+
var result = text;
1473+
if (typeof text === "string") {
1474+
result = new _SuperMap2["default"].Format.JSON().read(text);
1475+
}
1476+
if (!result || result.error || result.code >= 300 && result.code !== 304) {
1477+
result = { error: result };
14721478
}
14731479
if (result.error) {
14741480
var failure = options.scope ? _SuperMap2["default"].Function.bind(options.failure, options.scope) : options.failure;
1475-
failure(result.error);
1481+
failure(result);
14761482
} else {
14771483
result.succeed = result.succeed == undefined ? true : result.succeed;
14781484
var success = options.scope ? _SuperMap2["default"].Function.bind(options.success, options.scope) : options.success;
@@ -43181,14 +43187,14 @@ var EditFeaturesParameters = function () {
4318143187

4318243188
features = { ids: params.IDs };
4318343189
} else {
43184-
if (params.features === null) return;
43185-
43186-
len = params.features.length;
4318743190
features = [];
43188-
for (var i = 0; i < len; i++) {
43189-
feature = params.features[i];
43190-
feature.geometry = _ServerGeometry2["default"].fromGeometry(feature.geometry);
43191-
features.push(feature);
43191+
if (params.features) {
43192+
len = params.features.length;
43193+
for (var i = 0; i < len; i++) {
43194+
feature = params.features[i];
43195+
feature.geometry = _ServerGeometry2["default"].fromGeometry(feature.geometry);
43196+
features.push(feature);
43197+
}
4319243198
}
4319343199
}
4319443200

dist/iclient9-leaflet.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/iclient9-mapboxgl.js

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,15 +1458,21 @@ var CommonServiceBase = function () {
14581458
timeout: options.async ? 0 : null,
14591459
proxy: options.proxy
14601460
}).then(function (response) {
1461-
return response.text();
1461+
if (response.text) {
1462+
return response.text();
1463+
}
1464+
return response.json();
14621465
}).then(function (text) {
1463-
var result = new _SuperMap2.default.Format.JSON().read(text);
1464-
if (!result) {
1465-
result = { error: text };
1466+
var result = text;
1467+
if (typeof text === "string") {
1468+
result = new _SuperMap2.default.Format.JSON().read(text);
1469+
}
1470+
if (!result || result.error || result.code >= 300 && result.code !== 304) {
1471+
result = { error: result };
14661472
}
14671473
if (result.error) {
14681474
var failure = options.scope ? _SuperMap2.default.Function.bind(options.failure, options.scope) : options.failure;
1469-
failure(result.error);
1475+
failure(result);
14701476
} else {
14711477
result.succeed = result.succeed == undefined ? true : result.succeed;
14721478
var success = options.scope ? _SuperMap2.default.Function.bind(options.success, options.scope) : options.success;
@@ -31167,14 +31173,14 @@ var EditFeaturesParameters = function () {
3116731173

3116831174
features = { ids: params.IDs };
3116931175
} else {
31170-
if (params.features === null) return;
31171-
31172-
len = params.features.length;
3117331176
features = [];
31174-
for (var i = 0; i < len; i++) {
31175-
feature = params.features[i];
31176-
feature.geometry = _ServerGeometry2.default.fromGeometry(feature.geometry);
31177-
features.push(feature);
31177+
if (params.features) {
31178+
len = params.features.length;
31179+
for (var i = 0; i < len; i++) {
31180+
feature = params.features[i];
31181+
feature.geometry = _ServerGeometry2.default.fromGeometry(feature.geometry);
31182+
features.push(feature);
31183+
}
3117831184
}
3117931185
}
3118031186

dist/iclient9-mapboxgl.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/iclient9-openlayers.js

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,15 +1464,21 @@ var CommonServiceBase = function () {
14641464
timeout: options.async ? 0 : null,
14651465
proxy: options.proxy
14661466
}).then(function (response) {
1467-
return response.text();
1467+
if (response.text) {
1468+
return response.text();
1469+
}
1470+
return response.json();
14681471
}).then(function (text) {
1469-
var result = new _SuperMap2.default.Format.JSON().read(text);
1470-
if (!result) {
1471-
result = { error: text };
1472+
var result = text;
1473+
if (typeof text === "string") {
1474+
result = new _SuperMap2.default.Format.JSON().read(text);
1475+
}
1476+
if (!result || result.error || result.code >= 300 && result.code !== 304) {
1477+
result = { error: result };
14721478
}
14731479
if (result.error) {
14741480
var failure = options.scope ? _SuperMap2.default.Function.bind(options.failure, options.scope) : options.failure;
1475-
failure(result.error);
1481+
failure(result);
14761482
} else {
14771483
result.succeed = result.succeed == undefined ? true : result.succeed;
14781484
var success = options.scope ? _SuperMap2.default.Function.bind(options.success, options.scope) : options.success;
@@ -25862,8 +25868,6 @@ var TileSuperMapRest = function (_ol$source$TileImage) {
2586225868

2586325869
var layerUrl = options.url + "/tileImage.png?";
2586425870
options.serverType = options.serverType || _SuperMap2.default.ServerType.ISERVER;
25865-
//为url添加安全认证信息片段
25866-
layerUrl = appendCredential(layerUrl, options.serverType);
2586725871

2586825872
var _this = _possibleConstructorReturn(this, (TileSuperMapRest.__proto__ || Object.getPrototypeOf(TileSuperMapRest)).call(this, {
2586925873
attributions: options.attributions,
@@ -25891,6 +25895,7 @@ var TileSuperMapRest = function (_ol$source$TileImage) {
2589125895
//当前切片在切片集中的index
2589225896
_this.tileSetsIndex = -1;
2589325897
_this.tempIndex = -1;
25898+
2589425899
function appendCredential(url, serverType) {
2589525900
var newUrl = url,
2589625901
credential,
@@ -25992,6 +25997,8 @@ var TileSuperMapRest = function (_ol$source$TileImage) {
2599225997
*/
2599325998
function createLayerUrl() {
2599425999
this._layerUrl = layerUrl + getRequestParamString.call(this);
26000+
//为url添加安全认证信息片段
26001+
this._layerUrl = appendCredential(this._layerUrl, options.serverType);
2599526002
return this._layerUrl;
2599626003
}
2599726004

@@ -40052,14 +40059,14 @@ var EditFeaturesParameters = function () {
4005240059

4005340060
features = { ids: params.IDs };
4005440061
} else {
40055-
if (params.features === null) return;
40056-
40057-
len = params.features.length;
4005840062
features = [];
40059-
for (var i = 0; i < len; i++) {
40060-
feature = params.features[i];
40061-
feature.geometry = _ServerGeometry2.default.fromGeometry(feature.geometry);
40062-
features.push(feature);
40063+
if (params.features) {
40064+
len = params.features.length;
40065+
for (var i = 0; i < len; i++) {
40066+
feature = params.features[i];
40067+
feature.geometry = _ServerGeometry2.default.fromGeometry(feature.geometry);
40068+
features.push(feature);
40069+
}
4006340070
}
4006440071
}
4006540072

dist/iclient9-openlayers.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/leaflet/iPortalSecurity.html

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -239,15 +239,18 @@ <h4>iPortal SecurityManager使用示例</h4>
239239
</div>
240240
<script>
241241

242+
//若示例与SuperMap iPortal不在同一域下,欲查看示例效果请打开该句注释
243+
//SuperMap.Support.cors = false;
242244
$(document).ready(function () {
243245
$("#loginUrl_iportal").val("http://localhost:8090/iportal");
244-
$("#tokenServiceUrl_iportal").val("http://support.supermap.com.cn:8092/web/services/32");
246+
$("#tokenServiceUrl_iportal").val("http://support.supermap.com.cn:8092/web/services/748");
245247
$("#token_iportal").val("_Bo_ksR9DC56MvnAXc6liuhAdWmmt1SuoLX758QIeBJUvteLqHqUeeHnQ6OU0i0VBoN5FjNP_SOQ2o1xyudBjA..");
246248

247-
$("#serviceUrl_iportal").val("http://support.supermap.com.cn:8099/s3h4sgb3/iserver/services/map-china400/rest/maps/China");
248-
$('#key_iportal').val("ZlQAFd5VSxSECMuvCToUQ6ja");
249-
$("#serviceUrlMap_iportal").val("http://support.supermap.com.cn:8099/s3h4sgb3/iserver/services/map-china400/rest/maps/China");
250-
$('#mapKey_iportal').val("ZlQAFd5VSxSECMuvCToUQ6ja");
249+
$("#serviceUrl_iportal").val("http://support.supermap.com.cn:8099/ywutslmu/iserver/services/map-china400/rest/maps/China_4326");
250+
$('#key_iportal').val("CBIrkfXEAjydLrfp364qgM3P");
251+
$("#serviceUrlMap_iportal").val("http://support.supermap.com.cn:8099/ywutslmu/iserver/services/map-china400/rest/maps/China_4326");
252+
$('#mapKey_iportal').val("CBIrkfXEAjydLrfp364qgM3P");
253+
251254
});
252255

253256
/*登录*/
@@ -259,10 +262,11 @@ <h4>iPortal SecurityManager使用示例</h4>
259262
return;
260263
}
261264
SuperMap.SecurityManager.loginiPortal(loginUrl, userName, password).then(function (result) {
262-
if(result.succeed)
265+
if (result.succeed)
263266
window.alert("登录成功")
264267
});
265268
}
269+
266270
/*登出*/
267271
function logoutPortal() {
268272
var loginUrl = $("#loginUrl_iportal").val();
@@ -378,6 +382,7 @@ <h4>iPortal SecurityManager使用示例</h4>
378382
SuperMap.SecurityManager.registerKey(mapUrl, key);
379383

380384
var onlineMap = L.map('iportal_map', {
385+
crs: L.CRS.EPSG4326,
381386
center: [30, 104],
382387
maxZoom: 18,
383388
zoom: 2

examples/leaflet/onlineSecurity.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ <h4>Online SecurityManager使用示例</h4>
113113
</div>
114114
</div>
115115
<script>
116-
116+
//若示例与SuperMap Online不在同一域下,欲查看示例效果请打开该句注释
117+
//SuperMap.Support.cors = false;
117118
$(document).ready(function () {
118119
$("#serviceUrl_online").val("http://www.supermapol.com/iserver/services/bsaq89v0/rest/maps/World");
119120
$('#key_online').val("Ie2kriXZZz9GPevFDBQzgLRf");

0 commit comments

Comments
 (0)