forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLayerInfoService.js
More file actions
139 lines (133 loc) · 5.51 KB
/
LayerInfoService.js
File metadata and controls
139 lines (133 loc) · 5.51 KB
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
/* Copyright© 2000 - 2019 SuperMap Software Co.Ltd. All rights reserved.
* This program are made available under the terms of the Apache License, Version 2.0
* which accompanies this distribution and is available at http://www.apache.org/licenses/LICENSE-2.0.html.*/
import ol from 'openlayers';
import {ServiceBase} from './ServiceBase';
import {
GetLayersInfoService,
SetLayerInfoService,
SetLayersInfoService,
SetLayerStatusService
} from '@supermap/iclient-common';
/**
* @class ol.supermap.LayerInfoService
* @category iServer Map Layer
* @classdesc 图层信息服务类。
* @extends {ol.supermap.ServiceBase}
* @example
* new ol.supermap.LayerInfoService(url).getLayersInfo(function(result){
* //doSomething
* })
* @param {string} url - 与客户端交互的地图服务地址。请求地图服务,URL 应为:
* http://{服务器地址}:{服务端口号}/iserver/services/{地图服务名}/rest/maps/{地图名}/tempLayersSet/{tempLayerID}/Rivers@World@@World"。
* @param {Object} options - 参数。
* @param {string} [options.proxy] - 服务代理地址。
* @param {SuperMap.ServerType} [options.serverType=SuperMap.ServerType.ISERVER] - 服务来源 iServer|iPortal|online。
* @param {boolean} [options.withCredentials=false] - 请求是否携带cookie。
*/
export class LayerInfoService extends ServiceBase {
constructor(url, options) {
super(url, options);
}
/**
* @function ol.supermap.LayerInfoService.prototype.getLayersInfo
* @description 获取图层信息服务。
* @param {RequestCallback} callback - 回调函数。
*/
getLayersInfo(callback) {
var me = this;
var getLayersInfoService = new GetLayersInfoService(me.url, {
proxy: me.options.proxy,
withCredentials: me.options.withCredentials,
serverType: me.options.serverType,
eventListeners: {
processCompleted: callback,
processFailed: callback
}
});
getLayersInfoService.processAsync();
}
/**
* @function ol.supermap.LayerInfoService.prototype.setLayerInfo
* @description 设置图层信息服务。可以实现临时图层中子图层的修改。
* @param {SuperMap.SetLayerInfoParameters} params - 设置图层信息参数类。
* @param {RequestCallback} callback - 回调函数。
*/
setLayerInfo(params, callback) {
if (!params) {
return;
}
var me = this,
resourceID = params.resourceID,
tempLayerName = params.tempLayerName,
layerInfoParams = params.layerInfo;
if (!resourceID || !tempLayerName) {
return;
}
var url = me.url.concat();
url += "/tempLayersSet/" + resourceID + "/" + tempLayerName;
var setLayerInfoService = new SetLayerInfoService(url, {
proxy: me.options.proxy,
withCredentials: me.options.withCredentials,
serverType: me.options.serverType,
eventListeners: {
processCompleted: callback,
processFailed: callback
}
});
setLayerInfoService.processAsync(layerInfoParams);
}
/**
* @function ol.supermap.LayerInfoService.prototype.setLayersInfo
* @description 设置图层信息服务。可以实现创建新的临时图层和对现有临时图层的修改。
* @param {SuperMap.SetLayersInfoParameters} params - 设置图层信息参数类,包括临时图层。
* @param {RequestCallback} callback - 回调函数。
*/
setLayersInfo(params, callback) {
if (!params) {
return;
}
var me = this,
resourceID = params.resourceID,
isTempLayers = params.isTempLayers ? params.isTempLayers : false,
layersInfo = params.layersInfo;
if ((isTempLayers && !resourceID) || !layersInfo) {
return;
}
var setLayersInfoService = new SetLayersInfoService(me.url, {
proxy: me.options.proxy,
withCredentials: me.options.withCredentials,
serverType: me.options.serverType,
eventListeners: {
processCompleted: callback,
processFailed: callback
},
resourceID: resourceID,
isTempLayers: isTempLayers
});
setLayersInfoService.processAsync(layersInfo);
}
/**
* @function ol.supermap.LayerInfoService.prototype.setLayerStatus
* @description 子图层显示控制服务。负责将子图层显示控制参数传递到服务端,并获取服务端返回的图层显示状态。
* @param {SuperMap.SetLayerStatusParameters} params - 子图层显示控制参数类。
* @param {RequestCallback} callback - 回调函数。
*/
setLayerStatus(params, callback) {
if (!params) {
return;
}
var me = this;
var setLayerStatusService = new SetLayerStatusService(me.url, {
proxy: me.options.proxy,
withCredentials: me.options.withCredentials,
serverType: me.options.serverType,
eventListeners: {
processCompleted: callback,
processFailed: callback
}
});
setLayerStatusService.processAsync(params);
}
}
ol.supermap.LayerInfoService = LayerInfoService;