forked from SuperMap/iClient-JavaScript
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChartService.js
More file actions
106 lines (99 loc) · 4.18 KB
/
Copy pathChartService.js
File metadata and controls
106 lines (99 loc) · 4.18 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
/* Copyright© 2000 - 2022 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 L from 'leaflet';
import '../core/Base';
import { ChartQueryService } from '@supermap/iclient-common/iServer/ChartQueryService';
import { ChartFeatureInfoSpecsService } from '@supermap/iclient-common/iServer/ChartFeatureInfoSpecsService';
import { DataFormat } from '@supermap/iclient-common/REST';
import { Util as CommonUtil } from '@supermap/iclient-common/commontypes/Util';
import { ServiceBase } from './ServiceBase';
import { CommontypesConversion } from '../core/CommontypesConversion';
/**
* @class ChartService
* @deprecatedclassinstance L.supermap.chartService
* @classdesc 海图服务。
* @category iServer Map Chart
* @extends {ServiceBase}
* @example
* new ChartService(url)
* .queryChart(param,function(result){
* //doSomething
* })
* @param {string} url - 服务地址。
* @param {Object} options - 参数。
* @param {string} [options.proxy] - 服务代理地址。
* @param {boolean} [options.withCredentials=false] - 请求是否携带 cookie。
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
* @param {Object} [options.headers] - 请求头。
* @usage
*/
export var ChartService = ServiceBase.extend({
initialize: function (url, options) {
ServiceBase.prototype.initialize.call(this, url, options);
},
/**
* @function ChartService.prototype.queryChart
* @description 查询海图服务。
* @param {ChartQueryParameters} params - 海图查询参数类。
* @param {RequestCallback} callback - 回调函数。
* @param {DataFormat} [resultFormat=DataFormat.GEOJSON] - 返回结果类型。
*/
queryChart: function (params, callback, resultFormat) {
var me = this,
param = me._processParams(params),
format = me._processFormat(resultFormat);
var chartQueryService = new ChartQueryService(me.url, {
proxy: me.options.proxy,
withCredentials: me.options.withCredentials,
crossOrigin:me.options.crossOrigin,
headers:me.options.headers,
eventListeners: {
scope: me,
processCompleted: callback,
processFailed: callback
},
format: format
});
chartQueryService.processAsync(param);
},
/**
* @function ChartService.prototype.getChartFeatureInfo
* @description 获取海图物标信息。
* @param {RequestCallback} callback - 回调函数。
*/
getChartFeatureInfo: function (callback) {
var me = this, url = me.url.concat();
url = CommonUtil.urlPathAppend(url, 'chartFeatureInfoSpecs');
var chartFeatureInfoSpecsService = new ChartFeatureInfoSpecsService(url, {
proxy: me.options.proxy,
withCredentials: me.options.withCredentials,
crossOrigin:me.options.crossOrigin,
headers:me.options.headers,
eventListeners: {
scope: me,
processCompleted: callback,
processFailed: callback
}
});
chartFeatureInfoSpecsService.processAsync();
},
_processParams: function (params) {
if (!params) {
return {};
}
params.returnContent = (params.returnContent == null) ? true : params.returnContent;
if (params.chartQueryFilterParameters && !L.Util.isArray(params.chartQueryFilterParameters)) {
params.chartQueryFilterParameters = [params.chartQueryFilterParameters];
}
if (params.bounds) {
params.bounds = CommontypesConversion.toSuperMapBounds(params.bounds);
}
},
_processFormat: function (resultFormat) {
return (resultFormat) ? resultFormat : DataFormat.GEOJSON;
}
});
export var chartService = function (url, options) {
return new ChartService(url, options);
};