-
Notifications
You must be signed in to change notification settings - Fork 288
Expand file tree
/
Copy pathMapService.js
More file actions
85 lines (82 loc) · 3.3 KB
/
MapService.js
File metadata and controls
85 lines (82 loc) · 3.3 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
/* Copyright© 2000 - 2025 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 { ServiceBase } from './ServiceBase';
import { Util } from '@supermapgis/iclient-common/commontypes/Util';
import { MapService as CommonMapService } from '@supermapgis/iclient-common/iServer/MapService';
import { TilesetsService } from '@supermapgis/iclient-common/iServer/TilesetsService';
/**
* @class MapService
* @category iServer Map
* @classdesc 地图信息服务类。通过该类可以获得地图的基本信息、投影信息、切片列表信息等等。
* @modulecategory Services
* @extends {ServiceBase}
* @param {string} url - 服务地址。
* @param {Object} options - 参数。
* @param {string} [options.proxy] - 服务代理地址。
* @param {boolean} [options.withCredentials] - 请求是否携带凭据。默认情况下,仅同源请求包含凭据。
* @param {boolean} [options.crossOrigin] - 是否允许跨域请求。
* @param {Object} [options.headers] - 请求头。
* @example
* new MapService(url).getMapInfo(function(result){
* //doSomething
* })
* @usage
*/
export class MapService extends ServiceBase {
constructor(url, options) {
super(url, options);
}
/**
* @function MapService.prototype.getMapInfo
* @description 地图信息查询服务。
* @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
* @returns {Promise} Promise 对象。
*/
getMapInfo(callback) {
var me = this;
var getMapStatusService = new CommonMapService(me.url, {
proxy: me.options.proxy,
withCredentials: me.options.withCredentials,
crossOrigin: me.options.crossOrigin,
headers: me.options.headers,
projection: me.options.projection
});
return getMapStatusService.processAsync(callback);
}
/**
* @function MapService.prototype.getWKT
* @description 获取WKT。
* @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
* @returns {Promise} Promise 对象。
*/
getWKT(callback) {
var me = this;
var getMapStatusService = new CommonMapService(Util.urlPathAppend(me.url,'prjCoordSys.wkt'), {
proxy: me.options.proxy,
withCredentials: me.options.withCredentials,
withoutFormatSuffix: true,
crossOrigin: me.options.crossOrigin,
headers: me.options.headers,
projection: me.options.projection
});
return getMapStatusService.processAsync(callback);
}
/**
* @function MapService.prototype.getTilesets
* @description 切片列表信息查询服务。
* @param {RequestCallback} [callback] 回调函数,该参数未传时可通过返回的 promise 获取结果。
* @returns {MapService} 获取服务信息。
* @returns {Promise} Promise 对象。
*/
getTilesets(callback) {
var me = this;
var tilesetsService = new TilesetsService(me.url, {
proxy: me.options.proxy,
withCredentials: me.options.withCredentials,
crossOrigin: me.options.crossOrigin,
headers: me.options.headers
});
return tilesetsService.processAsync(callback);
}
}