Skip to content

Commit f584ed2

Browse files
committed
实现对接iPortal获取所有地图列表和单个地图资源。
1 parent cd2c2f6 commit f584ed2

File tree

3 files changed

+126
-1
lines changed

3 files changed

+126
-1
lines changed

src/common/iPortal/iPortal.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
require('./iPortalServicesQueryParam');
2+
require('./iPortalMapsQueryParam');
23
var SuperMap = require('../SuperMap');
34
var Request = require('../util/Request');
45
var iPortalService = require('./iPortalService');
6+
var iPortalMap = require('./iPortalMap');
57
SuperMap.iPortal = SuperMap.Class(SuperMap.iPortalServiceBase, {
68

79
initialize: function (iportalUrl, token) {
@@ -32,7 +34,24 @@ SuperMap.iPortal = SuperMap.Class(SuperMap.iPortalServiceBase, {
3234
deleteServices: function (ids) {
3335
var serviceUrl = this.iportalUrl + "/web/services";
3436
return this.request("DELETE", serviceUrl, {ids: ids});
35-
}
37+
},
38+
39+
queryMaps: function (queryParams) {
40+
var mapsUrl = this.iportalUrl + "/web/maps";
41+
return this.request("GET", mapsUrl, queryParams).then(function (result) {
42+
var mapRetult = {};
43+
var maps = [];
44+
result.content.map(function (mapJsonObj) {
45+
maps.push(new iPortalMap(mapsUrl+"/"+mapJsonObj.id, mapJsonObj));
46+
});
47+
mapRetult.content = maps;
48+
mapRetult.currentPage = result.currentPage;
49+
mapRetult.pageSize = result.pageSize;
50+
mapRetult.total = result.total;
51+
mapRetult.totalPage = result.totalPage;
52+
return mapRetult;
53+
});
54+
},
3655

3756
});
3857

src/common/iPortal/iPortalMap.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
require('./iPortalServiceBase');
2+
var SuperMap = require('../SuperMap');
3+
SuperMap.iPortalMap = SuperMap.Class(SuperMap.iPortalServiceBase, {
4+
5+
authorizeSetting: [],
6+
center: '',
7+
controls: null,
8+
checkStatus: '',
9+
createTime: 0,
10+
description: '',
11+
epsgCode: 0,
12+
extent: '',
13+
id: 0,
14+
isDefaultBottomMap: false,
15+
layers: [],
16+
level: null,
17+
nickname: '',
18+
sourceType: '',
19+
status: null,
20+
tags: [],
21+
thumbnail: '',
22+
title: '',
23+
units: null,
24+
updateTime: 0,
25+
userName: '',
26+
visitCount: 0,
27+
28+
initialize: function (mapUrl, params) {
29+
params = params || {};
30+
SuperMap.Util.extend(this, params);
31+
this.mapUrl = mapUrl;
32+
// if (this.id) {
33+
// this.mapUrl = mapUrl + "/" + this.id;
34+
// }
35+
SuperMap.iPortalServiceBase.prototype.initialize.call(this.mapUrl);
36+
},
37+
38+
load: function () {
39+
var me = this;
40+
return me.request("GET", me.mapUrl + ".json")
41+
.then(function (mapInfo) {
42+
if (mapInfo.error) {
43+
return mapInfo;
44+
}
45+
for (var key in mapInfo) {
46+
me[key] = mapInfo[key];
47+
}
48+
});
49+
},
50+
51+
update: function () {
52+
var mapUpdateParam = {
53+
units: this.units,
54+
level:this.level,
55+
center:this.center,
56+
controls:this.controls,
57+
description:this.description,
58+
epsgCode:this.epsgCode,
59+
extent:this.extent,
60+
status:this.status,
61+
tags:this.tags,
62+
layers:this.layers,
63+
title:this.title,
64+
thumbnail:this.thumbnail,
65+
sourceType:this.sourceType,
66+
authorizeSetting: this.authorizeSetting
67+
};
68+
var options = {
69+
headers: {'Content-Type': 'application/x-www-form-urlencoded'}
70+
};
71+
return me.request("PUT", this.mapUrl, JSON.stringify(mapUpdateParam), options);
72+
}
73+
74+
});
75+
76+
module.exports = SuperMap.iPortalMap;
77+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
var SuperMap = require('../SuperMap');
2+
SuperMap.iPortalMapsQueryParam = SuperMap.Class({
3+
4+
userNames: '',
5+
tags: [],
6+
suggest:false,
7+
sourceTypes: [],
8+
keywords: [],
9+
epsgCode: '',
10+
orderBy: '',
11+
currentPage:'',
12+
pageSize: 0,
13+
dirIds: [],
14+
isNotInDir: false,
15+
updateStart:0,
16+
updateEnd:0,
17+
visitStart:0,
18+
visitEnd:0,
19+
filterFields: [],
20+
21+
initialize: function (params) {
22+
params = params || {};
23+
SuperMap.Util.extend(this, params);
24+
}
25+
26+
});
27+
28+
module.exports = SuperMap.iPortalMapsQueryParam;
29+

0 commit comments

Comments
 (0)