@sword916/vae-map-plus 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.js +5376 -0
- package/lib/style.css +1 -0
- package/lib/vae-amap/favicon.ico +0 -0
- package/lib/vae-amap/images/game.png +0 -0
- package/lib/vae-amap/images/grid.png +0 -0
- package/lib/vae-amap/images/marker.png +0 -0
- package/lib/vae-amap/index.js +209 -0
- package/lib/vae-amap/style.css +1 -0
- package/lib/vae-cloudmap/favicon.ico +0 -0
- package/lib/vae-cloudmap/images/game.png +0 -0
- package/lib/vae-cloudmap/images/grid.png +0 -0
- package/lib/vae-cloudmap/images/marker.png +0 -0
- package/lib/vae-cloudmap/index.html +30 -0
- package/lib/vae-cloudmap/index.js +4085 -0
- package/lib/vae-cloudmap/style.css +1 -0
- package/lib/vae-map/favicon.ico +0 -0
- package/lib/vae-map/images/game.png +0 -0
- package/lib/vae-map/images/grid.png +0 -0
- package/lib/vae-map/images/marker.png +0 -0
- package/lib/vae-map/index.html +30 -0
- package/lib/vae-map/index.js +4322 -0
- package/lib/vae-map/style.css +1 -0
- package/package.json +1 -1
- package/plugins/L.AnimatedMarker/favicon.ico +0 -0
- package/plugins/L.AnimatedMarker/images/game.png +0 -0
- package/plugins/L.AnimatedMarker/images/grid.png +0 -0
- package/plugins/L.AnimatedMarker/images/marker.png +0 -0
- package/plugins/L.AnimatedMarker/index.html +30 -0
- package/plugins/L.AnimatedMarker/index.js +83 -0
- package/plugins/L.EchartsLayer/favicon.ico +0 -0
- package/plugins/L.EchartsLayer/images/game.png +0 -0
- package/plugins/L.EchartsLayer/images/grid.png +0 -0
- package/plugins/L.EchartsLayer/images/marker.png +0 -0
- package/plugins/L.EchartsLayer/index.html +30 -0
- package/plugins/L.EchartsLayer/index.js +176 -0
- package/plugins/L.FootageCalculator.Area/favicon.ico +0 -0
- package/plugins/L.FootageCalculator.Area/images/game.png +0 -0
- package/plugins/L.FootageCalculator.Area/images/grid.png +0 -0
- package/plugins/L.FootageCalculator.Area/images/marker.png +0 -0
- package/plugins/L.FootageCalculator.Area/index.html +30 -0
- package/plugins/L.FootageCalculator.Area/index.js +418 -0
- package/plugins/L.FootageCalculator.Line/favicon.ico +0 -0
- package/plugins/L.FootageCalculator.Line/images/game.png +0 -0
- package/plugins/L.FootageCalculator.Line/images/grid.png +0 -0
- package/plugins/L.FootageCalculator.Line/images/marker.png +0 -0
- package/plugins/L.FootageCalculator.Line/index.html +30 -0
- package/plugins/L.FootageCalculator.Line/index.js +416 -0
- package/plugins/L.GeoUtil/favicon.ico +0 -0
- package/plugins/L.GeoUtil/images/game.png +0 -0
- package/plugins/L.GeoUtil/images/grid.png +0 -0
- package/plugins/L.GeoUtil/images/marker.png +0 -0
- package/plugins/L.GeoUtil/index.html +30 -0
- package/plugins/L.GeoUtil/index.js +279 -0
- package/plugins/L.Glyphicon/favicon.ico +0 -0
- package/plugins/L.Glyphicon/images/game.png +0 -0
- package/plugins/L.Glyphicon/images/grid.png +0 -0
- package/plugins/L.Glyphicon/images/marker.png +0 -0
- package/plugins/L.Glyphicon/index.html +30 -0
- package/plugins/L.Glyphicon/index.js +57 -0
- package/plugins/L.Glyphicon/style.css +1 -0
- package/plugins/L.MarkerClusterX/favicon.ico +0 -0
- package/plugins/L.MarkerClusterX/images/game.png +0 -0
- package/plugins/L.MarkerClusterX/images/grid.png +0 -0
- package/plugins/L.MarkerClusterX/images/marker.png +0 -0
- package/plugins/L.MarkerClusterX/index.html +30 -0
- package/plugins/L.MarkerClusterX/index.js +33 -0
- package/plugins/L.MarkerClusterX/style.css +1 -0
- package/plugins/L.SafeDivOverlay/favicon.ico +0 -0
- package/plugins/L.SafeDivOverlay/images/game.png +0 -0
- package/plugins/L.SafeDivOverlay/images/grid.png +0 -0
- package/plugins/L.SafeDivOverlay/images/marker.png +0 -0
- package/plugins/L.SafeDivOverlay/index.html +30 -0
- package/plugins/L.SafeDivOverlay/index.js +26 -0
- package/plugins/L.TileLayer.ChinaProvider/favicon.ico +0 -0
- package/plugins/L.TileLayer.ChinaProvider/images/game.png +0 -0
- package/plugins/L.TileLayer.ChinaProvider/images/grid.png +0 -0
- package/plugins/L.TileLayer.ChinaProvider/images/marker.png +0 -0
- package/plugins/L.TileLayer.ChinaProvider/index.html +30 -0
- package/plugins/L.TileLayer.ChinaProvider/index.js +91 -0
- package/plugins/L.VuePopup/favicon.ico +0 -0
- package/plugins/L.VuePopup/images/game.png +0 -0
- package/plugins/L.VuePopup/images/grid.png +0 -0
- package/plugins/L.VuePopup/images/marker.png +0 -0
- package/plugins/L.VuePopup/index.html +30 -0
- package/plugins/L.VuePopup/index.js +68 -0
- package/plugins/L.VueTooltip/favicon.ico +0 -0
- package/plugins/L.VueTooltip/images/game.png +0 -0
- package/plugins/L.VueTooltip/images/grid.png +0 -0
- package/plugins/L.VueTooltip/images/marker.png +0 -0
- package/plugins/L.VueTooltip/index.html +30 -0
- package/plugins/L.VueTooltip/index.js +68 -0
- package/plugins/Mixin.Map.Measure/favicon.ico +0 -0
- package/plugins/Mixin.Map.Measure/images/game.png +0 -0
- package/plugins/Mixin.Map.Measure/images/grid.png +0 -0
- package/plugins/Mixin.Map.Measure/images/marker.png +0 -0
- package/plugins/Mixin.Map.Measure/index.html +30 -0
- package/plugins/Mixin.Map.Measure/index.js +84 -0
- package/plugins/globals/favicon.ico +0 -0
- package/plugins/globals/images/game.png +0 -0
- package/plugins/globals/images/grid.png +0 -0
- package/plugins/globals/images/marker.png +0 -0
- package/plugins/globals/index.html +30 -0
- package/plugins/globals/index.js +4 -0
- package/build/index.mjs +0 -113
- package/examples/App.vue +0 -18
- package/examples/index.js +0 -13
- package/examples/router/index.js +0 -35
- package/examples/views/amap.vue +0 -29
- package/examples/views/amarker.vue +0 -58
- package/examples/views/buffer.vue +0 -66
- package/examples/views/cluster.vue +0 -74
- package/examples/views/cover.vue +0 -85
- package/examples/views/draw-line.vue +0 -49
- package/examples/views/draw.vue +0 -54
- package/examples/views/echarts.vue +0 -142
- package/examples/views/emarker.vue +0 -39
- package/examples/views/image.vue +0 -182
- package/examples/views/index.vue +0 -61
- package/examples/views/lrmap.vue +0 -108
- package/examples/views/map.vue +0 -82
- package/examples/views/measure.vue +0 -86
- package/examples/views/parts/popup.vue +0 -39
- package/examples/views/parts/tooltip.vue +0 -39
- package/examples/views/push-area.vue +0 -52
- package/examples/views/push-line.vue +0 -84
- package/examples/views/trace.vue +0 -49
- package/jsconfig.json +0 -17
- package/src/components/resize-listener/component.jsx +0 -30
- package/src/components/resize-listener/index.js +0 -3
- package/src/composables/useAutoMessage.js +0 -41
- package/src/composables/useContextMenu.js +0 -99
- package/src/composables/useMapMeasure.js +0 -191
- package/src/composables/useResizeObserver.js +0 -81
- package/src/mixins/message.js +0 -1
- package/src/packages/index.js +0 -16
- package/src/packages/vae-amap/index.js +0 -8
- package/src/packages/vae-amap/style.less +0 -9
- package/src/packages/vae-amap/vae-amap.jsx +0 -98
- package/src/packages/vae-cloudmap/ctrl-context-menu/index.vue +0 -74
- package/src/packages/vae-cloudmap/ctrl-draw/index.vue +0 -499
- package/src/packages/vae-cloudmap/ctrl-draw-line/index.vue +0 -161
- package/src/packages/vae-cloudmap/index.js +0 -57
- package/src/packages/vae-cloudmap/scripts/L.MarkerCluster/index.js +0 -2690
- package/src/packages/vae-cloudmap/scripts/L.MarkerCluster/style.css +0 -14
- package/src/packages/vae-cloudmap/scripts/L.Vae.CRS/index.js +0 -212
- package/src/packages/vae-cloudmap/scripts/L.Vae.Client/index.js +0 -780
- package/src/packages/vae-cloudmap/scripts/Mixin.ContextMenu/index.js +0 -101
- package/src/packages/vae-cloudmap/style.less +0 -163
- package/src/packages/vae-cloudmap/vae-cloudmap.jsx +0 -272
- package/src/packages/vae-map/ctrl-context-menu/index.vue +0 -74
- package/src/packages/vae-map/ctrl-draw/index.vue +0 -498
- package/src/packages/vae-map/ctrl-draw-line/index.vue +0 -128
- package/src/packages/vae-map/index.js +0 -59
- package/src/packages/vae-map/scripts/L.MarkerCluster/index.js +0 -2690
- package/src/packages/vae-map/scripts/L.MarkerCluster/style.css +0 -14
- package/src/packages/vae-map/scripts/L.Vae.CRS/index.js +0 -114
- package/src/packages/vae-map/scripts/L.Vae.Client/index.js +0 -548
- package/src/packages/vae-map/scripts/Mixin.ContextMenu/index.js +0 -1
- package/src/packages/vae-map/style.less +0 -161
- package/src/packages/vae-map/vae-lrmap.jsx +0 -237
- package/src/packages/vae-map/vae-map.jsx +0 -135
- package/src/plugins/L.AnimatedMarker/index.js +0 -158
- package/src/plugins/L.EchartsLayer/index.js +0 -339
- package/src/plugins/L.ElasticMarker/index.js +0 -162
- package/src/plugins/L.FootageCalculator.Area/index.js +0 -263
- package/src/plugins/L.FootageCalculator.Line/index.js +0 -273
- package/src/plugins/L.GeoUtil/buffer.js +0 -67
- package/src/plugins/L.GeoUtil/index.js +0 -284
- package/src/plugins/L.Glyphicon/index.js +0 -91
- package/src/plugins/L.Glyphicon/style.less +0 -37
- package/src/plugins/L.MarkerClusterX/index.js +0 -93
- package/src/plugins/L.MarkerClusterX/style.less +0 -162
- package/src/plugins/L.SafeDivOverlay/index.js +0 -55
- package/src/plugins/L.TileLayer.ChinaProvider/index.js +0 -108
- package/src/plugins/L.VuePopup/index.js +0 -67
- package/src/plugins/L.VueTooltip/index.js +0 -63
- package/src/plugins/Mixin.Map.Measure/index.js +0 -248
- package/src/plugins/globals/index.js +0 -7
- package/src/utils/index.js +0 -36
- package/src/utils/resize-event.js +0 -45
- /package/{public → lib}/favicon.ico +0 -0
- /package/{public → lib}/images/game.png +0 -0
- /package/{public → lib}/images/grid.png +0 -0
- /package/{public → lib}/images/marker.png +0 -0
- /package/{public → lib/vae-amap}/index.html +0 -0
|
@@ -1,780 +0,0 @@
|
|
|
1
|
-
import axios from 'axios'
|
|
2
|
-
import {idGen, getTreeNode} from '@/utils'
|
|
3
|
-
|
|
4
|
-
L.Vae = L.Vae || {}
|
|
5
|
-
|
|
6
|
-
// LRMAP客户端
|
|
7
|
-
L.Vae.CloudClient = L.Evented.extend({
|
|
8
|
-
|
|
9
|
-
options: {},
|
|
10
|
-
|
|
11
|
-
requestOptions: {},
|
|
12
|
-
|
|
13
|
-
leafletOptions: {},
|
|
14
|
-
|
|
15
|
-
extent: [],
|
|
16
|
-
|
|
17
|
-
treeLayers: [],
|
|
18
|
-
|
|
19
|
-
visibleKeys: [],
|
|
20
|
-
|
|
21
|
-
token: "",
|
|
22
|
-
|
|
23
|
-
async initialize(options) {
|
|
24
|
-
this.options = options
|
|
25
|
-
this.requestOptions = {url: null, uid: null, dsid: null, mapid: null, dsname: null, customTreeLayers: null}
|
|
26
|
-
this.leafletOptions = {}
|
|
27
|
-
// 获取云GIS的Token
|
|
28
|
-
this.token = await this.requestCouldGisToken()
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 连接地图服务,构建地图参数
|
|
33
|
-
* @param {Boolean} alert 是否提示参数错误
|
|
34
|
-
*/
|
|
35
|
-
async start({alert} = {}) {
|
|
36
|
-
return new Promise(async resolve => {
|
|
37
|
-
for (let v of ['url']) {
|
|
38
|
-
const value = this.options ? this.options[v] : null
|
|
39
|
-
const message = `参数 options.${v} 无效`
|
|
40
|
-
if (!_.isString(value) || value.trim().length == 0) {
|
|
41
|
-
this.fire('fail', {message: message})
|
|
42
|
-
if (alert) {
|
|
43
|
-
this.fire('message', {message, messageType: 'error'})
|
|
44
|
-
}
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
this.requestOptions.uid = this.options?.uid || `vae_client_${idGen()}`
|
|
49
|
-
|
|
50
|
-
try {
|
|
51
|
-
this.fire('openmask', {text: `正在 获取图元信息`})
|
|
52
|
-
const params = new URLSearchParams()
|
|
53
|
-
params.append('packettype', 'map')
|
|
54
|
-
params.append('action', 'getmeta')
|
|
55
|
-
params.append('uid', this.requestOptions.uid)
|
|
56
|
-
if (_.isString(this.options.dsname) && this.options.dsname.trim().length > 0) {
|
|
57
|
-
params.append('dsname', this.options.dsname)
|
|
58
|
-
} else {
|
|
59
|
-
params.append('dsid', this.options.dsid || 'default')
|
|
60
|
-
}
|
|
61
|
-
if (_.isString(this.options.mapname) && this.options.mapname.trim().length > 0) {
|
|
62
|
-
params.append('mapname', this.options.mapname)
|
|
63
|
-
} else {
|
|
64
|
-
params.append('mapid', this.options.mapid || 'default')
|
|
65
|
-
}
|
|
66
|
-
const metaData = (await axios.post(this.options.url + 'map/getmeta?', params)).data
|
|
67
|
-
this.fire('closemask')
|
|
68
|
-
if (metaData.status == 'success') {
|
|
69
|
-
this.buildMapOptions(metaData.result)
|
|
70
|
-
resolve(true)
|
|
71
|
-
} else {
|
|
72
|
-
this.fire('fail', {message: "未获取到正确的图元信息"})
|
|
73
|
-
console.error(metaData.errinfo)
|
|
74
|
-
this.fire('message', {message: "未获取到正确的图元信息", messageType: 'error'})
|
|
75
|
-
resolve(false)
|
|
76
|
-
}
|
|
77
|
-
} catch (error) {
|
|
78
|
-
this.fire('fail', {message: "获取图元失败,请检查地图服务和请求参数"})
|
|
79
|
-
console.error(error)
|
|
80
|
-
this.fire('message', {message: "获取图元失败,请检查地图服务和请求参数", messageType: 'error'})
|
|
81
|
-
this.fire('closemask')
|
|
82
|
-
resolve(false)
|
|
83
|
-
}
|
|
84
|
-
})
|
|
85
|
-
},
|
|
86
|
-
|
|
87
|
-
// 构建地图配置项
|
|
88
|
-
buildMapOptions({dsid, mapid, extent}) {
|
|
89
|
-
try {
|
|
90
|
-
extent = this.options.extent || extent
|
|
91
|
-
if (_.isString(extent)) {
|
|
92
|
-
extent = extent.split(',')
|
|
93
|
-
}
|
|
94
|
-
if (Array.isArray(extent)) {
|
|
95
|
-
extent = extent.map(Number)
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// 参数整理
|
|
99
|
-
if (dsid) {
|
|
100
|
-
this.requestOptions.url = this.options.url
|
|
101
|
-
this.requestOptions.dsid = dsid
|
|
102
|
-
this.requestOptions.mapid = mapid ?? this.options.mapid ?? 'default'
|
|
103
|
-
// this.requestOptions.mapid = mapid || this.options.mapid || 'default'
|
|
104
|
-
this.requestOptions.dsname = this.options.dsname
|
|
105
|
-
} else {
|
|
106
|
-
this.fire('fail', {message: '数据源dsid错误'})
|
|
107
|
-
throw new Error('数据源dsid错误')
|
|
108
|
-
}
|
|
109
|
-
// 构建配置
|
|
110
|
-
if (Array.isArray(extent) && extent.length == 4) {
|
|
111
|
-
// extent
|
|
112
|
-
this.extent = extent // [buildMapOptions] //extent
|
|
113
|
-
let centerX = (extent[0] + extent[2]) * 0.5
|
|
114
|
-
let centerY = (extent[1] + extent[3]) * 0.5
|
|
115
|
-
console.log(this.extent)
|
|
116
|
-
// crs
|
|
117
|
-
let crs = this.options.crs || L.Vae.CRS.SIMPLE()
|
|
118
|
-
if (crs == 'bj54') {
|
|
119
|
-
crs = L.Vae.CRS.BJ54(centerX, this.options)
|
|
120
|
-
} else if (crs == 'xa80') {
|
|
121
|
-
crs = L.Vae.CRS.XA80(centerX)
|
|
122
|
-
} else if (crs == 'simple') {
|
|
123
|
-
crs = L.Vae.CRS.SIMPLE()
|
|
124
|
-
} else if (crs == 'CGCS2000' || crs == 'cgcs2000') {
|
|
125
|
-
crs = L.Vae.CRS.CGCS2000(centerX,this.options)
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// wmscrs
|
|
129
|
-
let wmscrs = this.options.wmscrs || crs
|
|
130
|
-
if (wmscrs == 'bj54') {
|
|
131
|
-
wmscrs = L.Vae.CRS.BJ54(centerX)
|
|
132
|
-
} else if (wmscrs == 'xa80') {
|
|
133
|
-
wmscrs = L.Vae.CRS.XA80(centerX)
|
|
134
|
-
} else if (crs == 'simple') {
|
|
135
|
-
wmscrs = L.Vae.CRS.SIMPLE()
|
|
136
|
-
} else if (crs == 'CGCS2000' || crs == 'cgcs2000') {
|
|
137
|
-
wmscrs = L.Vae.CRS.CGCS2000(centerX,this.options)
|
|
138
|
-
}
|
|
139
|
-
// center
|
|
140
|
-
const center = this.options.center || wmscrs.unproject(L.point(centerX, centerY))
|
|
141
|
-
// maxzoom
|
|
142
|
-
const maxZoom = this.options.maxZoom ? this.options.maxZoom :
|
|
143
|
-
(crs.options && crs.options.resolutions) ? crs.options.resolutions.length - 1 : 25
|
|
144
|
-
// bounds
|
|
145
|
-
const corner1 = wmscrs.unproject(L.point(extent[0], extent[1]))
|
|
146
|
-
const corner2 = wmscrs.unproject(L.point(extent[2], extent[3]))
|
|
147
|
-
const bounds = L.latLngBounds(corner1, corner2)
|
|
148
|
-
this.leafletOptions = {crs, wmscrs, center, maxZoom, bounds}
|
|
149
|
-
} else {
|
|
150
|
-
this.fire('fail', {message: '地图属性extent错误'})
|
|
151
|
-
throw new Error('地图属性extent错误')
|
|
152
|
-
}
|
|
153
|
-
} catch (e) {
|
|
154
|
-
this.fire('fail', {message: "地图参数构建错误"})
|
|
155
|
-
console.error(e)
|
|
156
|
-
this.fire('message', {message: "地图参数构建错误", type: 'error'})
|
|
157
|
-
}
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* 请求地图服务
|
|
162
|
-
* @param {string} api 请求动作
|
|
163
|
-
* @param {string} message 提示消息
|
|
164
|
-
* @param {object} params 额外参数
|
|
165
|
-
* @param {boolean} forceResolve 请求结果无效时,强制resolve而不是reject
|
|
166
|
-
* @param {boolean} checkResult 是否校验结果
|
|
167
|
-
* @param {boolean} loadMask 是否添加遮罩层
|
|
168
|
-
*/
|
|
169
|
-
requestServer({api, message = '加载数据', params = {}, forceResolve, checkResult = true, loadMask = true}) {
|
|
170
|
-
return new Promise((resolve, reject) => {
|
|
171
|
-
if (api) {
|
|
172
|
-
if (loadMask) {
|
|
173
|
-
this.fire('openmask', {text: `正在 ${message}`})
|
|
174
|
-
}
|
|
175
|
-
axios.post(`${this.requestOptions.url}${api}`, L.extend({
|
|
176
|
-
uid: this.requestOptions.uid,
|
|
177
|
-
dsGuid: this.requestOptions.dsid
|
|
178
|
-
}, params)).then(result => {
|
|
179
|
-
if (checkResult) {
|
|
180
|
-
const data = result.data
|
|
181
|
-
if (data && data.status == 'success') {
|
|
182
|
-
resolve(data.result)
|
|
183
|
-
} else {
|
|
184
|
-
this.fire('fail', {message: data.errinfo})
|
|
185
|
-
if (forceResolve) {
|
|
186
|
-
console.error(data.errinfo)
|
|
187
|
-
resolve('')
|
|
188
|
-
} else {
|
|
189
|
-
this.fire('message', {message: `${message}结果无效`, messageType: 'error'})
|
|
190
|
-
console.error(data.errinfo)
|
|
191
|
-
reject(data.errinfo)
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
} else {
|
|
195
|
-
resolve(result.data)
|
|
196
|
-
}
|
|
197
|
-
}).catch(e => {
|
|
198
|
-
this.fire('fail', {message: `${message}失败,请检查地图服务和和请求参数`})
|
|
199
|
-
this.fire('message', {message: `${message}失败,请检查地图服务和和请求参数`, messageType: 'error'})
|
|
200
|
-
console.error(e)
|
|
201
|
-
reject(e)
|
|
202
|
-
}).finally(() => {
|
|
203
|
-
if (loadMask) {
|
|
204
|
-
this.fire('closemask')
|
|
205
|
-
}
|
|
206
|
-
})
|
|
207
|
-
}
|
|
208
|
-
})
|
|
209
|
-
},
|
|
210
|
-
/**
|
|
211
|
-
* 请求云GIS地图服务
|
|
212
|
-
* @param {string} api 请求动作
|
|
213
|
-
* @param {string} message 提示消息
|
|
214
|
-
* @param {object} params 额外参数
|
|
215
|
-
* @param {boolean} forceResolve 请求结果无效时,强制resolve而不是reject
|
|
216
|
-
* @param {boolean} checkResult 是否校验结果
|
|
217
|
-
* @param {boolean} loadMask 是否添加遮罩层
|
|
218
|
-
*/
|
|
219
|
-
requestCloudServer({api, message = '加载数据', params = {}, forceResolve, checkResult = true, loadMask = true}) {
|
|
220
|
-
return new Promise((resolve, reject) => {
|
|
221
|
-
if (api) {
|
|
222
|
-
if (loadMask) {
|
|
223
|
-
this.fire('openmask', {text: `正在 ${message}`})
|
|
224
|
-
}
|
|
225
|
-
axios.get(`${this.options.url}${api}`,
|
|
226
|
-
{
|
|
227
|
-
params: _.merge(params, { token : this.token})
|
|
228
|
-
}
|
|
229
|
-
).then(async result => {
|
|
230
|
-
if (checkResult) {
|
|
231
|
-
const data = result.data
|
|
232
|
-
if (data && data.code == '0') {
|
|
233
|
-
resolve(data.data)
|
|
234
|
-
} else {
|
|
235
|
-
this.fire('fail', {message: data.msg})
|
|
236
|
-
if (forceResolve) {
|
|
237
|
-
console.error(data.msg)
|
|
238
|
-
resolve('')
|
|
239
|
-
} else {
|
|
240
|
-
// 判断Token过期
|
|
241
|
-
if (data && data.code == '40001'){
|
|
242
|
-
console.log("requestCloudServer 登录过期,重新获取token", this.token)
|
|
243
|
-
// 获取云GIS的Token
|
|
244
|
-
this.token = await this.requestCouldGisToken()
|
|
245
|
-
this.requestCloudServer({api, message, params, forceResolve, checkResult, loadMask}).then(res =>{
|
|
246
|
-
resolve(res)
|
|
247
|
-
}).catch(err =>{
|
|
248
|
-
reject(err)
|
|
249
|
-
})
|
|
250
|
-
}else{
|
|
251
|
-
this.fire('message', {message: `${message}结果无效`, messageType: 'error'})
|
|
252
|
-
console.error(data.msg)
|
|
253
|
-
reject(data.msg)
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
} else {
|
|
258
|
-
resolve(result.data)
|
|
259
|
-
}
|
|
260
|
-
}).catch(e => {
|
|
261
|
-
console.log("catch ERROR", e)
|
|
262
|
-
this.fire('fail', {message: `${message}失败,请检查地图服务和和请求参数`})
|
|
263
|
-
this.fire('message', {message: `${message}失败,请检查地图服务和和请求参数`, messageType: 'error'})
|
|
264
|
-
console.error(e)
|
|
265
|
-
reject(e)
|
|
266
|
-
}).finally(() => {
|
|
267
|
-
if (loadMask) {
|
|
268
|
-
this.fire('closemask')
|
|
269
|
-
}
|
|
270
|
-
})
|
|
271
|
-
}
|
|
272
|
-
})
|
|
273
|
-
},
|
|
274
|
-
/**
|
|
275
|
-
* 请求云GIS数据
|
|
276
|
-
* @param {string} api 请求动作
|
|
277
|
-
* @param {string} message 提示消息
|
|
278
|
-
* @param {object} params 额外参数
|
|
279
|
-
* @param {string} method 请求方式
|
|
280
|
-
* @param {object} data POST请求体
|
|
281
|
-
* @param {object} headers 请求头
|
|
282
|
-
* @param {boolean} forceResolve 请求结果无效时,强制resolve而不是reject
|
|
283
|
-
* @param {boolean} checkResult 是否校验结果
|
|
284
|
-
* @param {boolean} loadMask 是否添加遮罩层
|
|
285
|
-
*/
|
|
286
|
-
requestCloudMapData({api, message = '加载数据', params = {}, method = 'get', data = null, headers = {}, forceResolve, checkResult = true, loadMask = true}) {
|
|
287
|
-
return new Promise((resolve, reject) => {
|
|
288
|
-
if (api) {
|
|
289
|
-
if (loadMask) {
|
|
290
|
-
this.fire('openmask', {text: `正在 ${message}`})
|
|
291
|
-
}
|
|
292
|
-
const requestUrl = `${this.options.cloudGisUrl}${api}`
|
|
293
|
-
const requestMethod = String(method).toLowerCase()
|
|
294
|
-
const request = requestMethod === 'post'
|
|
295
|
-
? axios.post(requestUrl, data, {headers})
|
|
296
|
-
: axios.get(requestUrl, {
|
|
297
|
-
params: _.merge(params, { token : this.token})
|
|
298
|
-
})
|
|
299
|
-
request.then(async result => {
|
|
300
|
-
if (checkResult) {
|
|
301
|
-
const response = result.data
|
|
302
|
-
if (response && response.code == '0') {
|
|
303
|
-
resolve(response.data)
|
|
304
|
-
} else {
|
|
305
|
-
this.fire('fail', {message: response.msg})
|
|
306
|
-
if (forceResolve) {
|
|
307
|
-
console.error(response.msg)
|
|
308
|
-
resolve('')
|
|
309
|
-
} else {
|
|
310
|
-
// 判断Token过期
|
|
311
|
-
if (response && response.code == '40001'){
|
|
312
|
-
console.log("requestCloudMapData 登录过期,重新获取token", this.token)
|
|
313
|
-
// 获取云GIS的Token
|
|
314
|
-
this.token = await this.requestCouldGisToken()
|
|
315
|
-
const nextHeaders = headers.Authorization ? _.merge({}, headers, {Authorization: this.token}) : headers
|
|
316
|
-
this.requestCloudMapData({api, message, params, method, data, headers: nextHeaders, forceResolve, checkResult, loadMask}).then(res =>{
|
|
317
|
-
resolve(res)
|
|
318
|
-
}).catch(err =>{
|
|
319
|
-
reject(err)
|
|
320
|
-
})
|
|
321
|
-
}else{
|
|
322
|
-
this.fire('message', {message: `${message}结果无效`, messageType: 'error'})
|
|
323
|
-
console.error(response.msg)
|
|
324
|
-
reject(response.msg)
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
} else {
|
|
329
|
-
resolve(result.data)
|
|
330
|
-
}
|
|
331
|
-
}).catch(e => {
|
|
332
|
-
console.log("catch ERROR", e)
|
|
333
|
-
this.fire('fail', {message: `${message}失败,请检查地图服务和和请求参数`})
|
|
334
|
-
this.fire('message', {message: `${message}失败,请检查地图服务和和请求参数`, messageType: 'error'})
|
|
335
|
-
console.error(e)
|
|
336
|
-
reject(e)
|
|
337
|
-
}).finally(() => {
|
|
338
|
-
if (loadMask) {
|
|
339
|
-
this.fire('closemask')
|
|
340
|
-
}
|
|
341
|
-
})
|
|
342
|
-
}
|
|
343
|
-
})
|
|
344
|
-
},
|
|
345
|
-
/**
|
|
346
|
-
* 请求云GIS的Token
|
|
347
|
-
*/
|
|
348
|
-
requestCouldGisToken() {
|
|
349
|
-
return new Promise((resolve, reject) => {
|
|
350
|
-
axios.post(`${this.options.cloudGisUrl}api/gis/mapserver/rest/auth`,{
|
|
351
|
-
user_name: this.options.username,
|
|
352
|
-
password: this.options.password
|
|
353
|
-
}).then(result => {
|
|
354
|
-
const data = result.data
|
|
355
|
-
if (data && data.code == '0') {
|
|
356
|
-
resolve(data.data.token)
|
|
357
|
-
} else {
|
|
358
|
-
this.fire('fail', {message: data.msg})
|
|
359
|
-
this.fire('message', {message: `请求Token失败,${data.msg}`, messageType: 'error'})
|
|
360
|
-
console.error(data.msg)
|
|
361
|
-
resolve('')
|
|
362
|
-
}
|
|
363
|
-
}).catch(e => {
|
|
364
|
-
console.log('noErrorMsg', this.options);
|
|
365
|
-
|
|
366
|
-
if(!this.options.noErrorMsg){
|
|
367
|
-
this.fire('fail', {message: `请求Token失败,请检查云GIS账号和密码`})
|
|
368
|
-
this.fire('message', {message: `请求Token失败,请检查云GIS账号和密码`, messageType: 'error'})
|
|
369
|
-
}
|
|
370
|
-
console.error(e)
|
|
371
|
-
reject(e)
|
|
372
|
-
})
|
|
373
|
-
})
|
|
374
|
-
},
|
|
375
|
-
|
|
376
|
-
// 设置默认图层
|
|
377
|
-
async setDefaultLayers() {
|
|
378
|
-
this.fire('openmask', {text: `正在 加载默认图层`})
|
|
379
|
-
const {defaultLayers, defaultLayerSets, disabledLayerSets, layerTreeType} = this.options
|
|
380
|
-
await this.formatLayerGroup_CloudGis(layerTreeType, disabledLayerSets)
|
|
381
|
-
if (Array.isArray(defaultLayers)) {
|
|
382
|
-
this.visibleKeys = await this.showLayers(defaultLayers, {loadMask: false, refreshTiles: false})
|
|
383
|
-
} else if (Array.isArray(defaultLayerSets)) {
|
|
384
|
-
this.visibleKeys = await this.showLayerSets(defaultLayerSets, {loadMask: false, refreshTiles: false})
|
|
385
|
-
} else if (Array.isArray(disabledLayerSets)) {
|
|
386
|
-
await this.showLayers(this.visibleKeys, {loadMask: false, refreshTiles: false})
|
|
387
|
-
}
|
|
388
|
-
this.fire('closemask')
|
|
389
|
-
},
|
|
390
|
-
|
|
391
|
-
/**
|
|
392
|
-
* 初始化图层信息
|
|
393
|
-
* 有协同服务时,处理为树结构
|
|
394
|
-
* 无协同服务时,处理为列表结构
|
|
395
|
-
* @param {enum} type 类型,'leaf'(默认):叶子节点为实际图层,'branch':叶子节点为末级图集,图层置于layers属性
|
|
396
|
-
* @param {array<string>} disabledLayerSets 禁用的图集,支持'x>y>z'的选择方式
|
|
397
|
-
* @returns {treeLayers,visibleLayers}
|
|
398
|
-
* @property {array<object>} treeLayers 树结构:{id,label,children}
|
|
399
|
-
* @property {array<string>} visibleKeys 可见图层keys
|
|
400
|
-
*/
|
|
401
|
-
async formatLayerGroup_CloudGis(type = 'leaf', disabledLayerSets = []) {
|
|
402
|
-
// 处理结果:树结构和IDS
|
|
403
|
-
let treeLayers = [], visibleKeys = []
|
|
404
|
-
|
|
405
|
-
// 请求数据
|
|
406
|
-
let layersGroupRes = await this.requestCloudMapData({
|
|
407
|
-
api: 'api/sys/layerauth/getGroupLayer',
|
|
408
|
-
message: '获取图层',
|
|
409
|
-
loadMask: false,
|
|
410
|
-
params:{
|
|
411
|
-
dsGuid: this.options.dsGuid
|
|
412
|
-
}
|
|
413
|
-
})
|
|
414
|
-
if(!layersGroupRes){
|
|
415
|
-
this.fire('fail', {message: `请求图层信息失败`})
|
|
416
|
-
this.fire('message', {message: `请求图层信息失败`, messageType: 'error'})
|
|
417
|
-
return
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
treeLayers = layersGroupRes
|
|
421
|
-
treeLayers.forEach(group =>{
|
|
422
|
-
this.handleLayerNode(group, 0)
|
|
423
|
-
})
|
|
424
|
-
|
|
425
|
-
// 处理禁用的图集
|
|
426
|
-
if (Array.isArray(disabledLayerSets) && disabledLayerSets.length > 0) {
|
|
427
|
-
let disabledKeys = []
|
|
428
|
-
let disabledAllKeys = []
|
|
429
|
-
disabledLayerSets.forEach(set => {
|
|
430
|
-
let node
|
|
431
|
-
set.split('>').forEach(v => {
|
|
432
|
-
if (v) {
|
|
433
|
-
node = getTreeNode(node ? [node] : treeLayers, {label: v})
|
|
434
|
-
}
|
|
435
|
-
})
|
|
436
|
-
if (node) {
|
|
437
|
-
disabledKeys.push(node.id)
|
|
438
|
-
}
|
|
439
|
-
})
|
|
440
|
-
if (disabledKeys.length > 0) {
|
|
441
|
-
// 获取节点下的图层
|
|
442
|
-
const collectLayers = node => {
|
|
443
|
-
let result = []
|
|
444
|
-
if (Array.isArray(node.children) && node.children.length > 0) {
|
|
445
|
-
node.children.forEach(v => {
|
|
446
|
-
result = _.concat(result, collectLayers(v))
|
|
447
|
-
})
|
|
448
|
-
} else {
|
|
449
|
-
result = _.concat(result, node.layers || node)
|
|
450
|
-
}
|
|
451
|
-
return result
|
|
452
|
-
}
|
|
453
|
-
// 去除禁用的节点集
|
|
454
|
-
const collectNodes = node => {
|
|
455
|
-
let result = node
|
|
456
|
-
if (_.includes(disabledKeys, node.id)) {
|
|
457
|
-
result = null
|
|
458
|
-
disabledAllKeys.push(node.id)
|
|
459
|
-
collectLayers(node).forEach(v => {
|
|
460
|
-
disabledAllKeys.push(v.id)
|
|
461
|
-
})
|
|
462
|
-
} else {
|
|
463
|
-
let children = result.children
|
|
464
|
-
if (children && children.length > 0) {
|
|
465
|
-
result.children = _.compact(children.map(v => collectNodes(v)))
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
return result
|
|
469
|
-
}
|
|
470
|
-
// 更新图层树和全量keys
|
|
471
|
-
treeLayers = _.compact(treeLayers.map(v => collectNodes(v)))
|
|
472
|
-
this.visibleKeys = _.pull(this.visibleKeys, ..._.uniq(disabledAllKeys))
|
|
473
|
-
}
|
|
474
|
-
}
|
|
475
|
-
this.treeLayers = treeLayers
|
|
476
|
-
},
|
|
477
|
-
handleLayerNode(node, level = 0, parentId = '') {
|
|
478
|
-
// 为当前节点添加level属性
|
|
479
|
-
let tempNode;
|
|
480
|
-
node.level = level
|
|
481
|
-
if(node.type == 'layergroup'){
|
|
482
|
-
delete node.type
|
|
483
|
-
delete node.isLoad
|
|
484
|
-
delete node.mapInfo
|
|
485
|
-
delete node.isReadOnly
|
|
486
|
-
node.id = `NODE_${level}_${node.id}`
|
|
487
|
-
}
|
|
488
|
-
if(node.type == 'layeritem'){
|
|
489
|
-
delete node.type
|
|
490
|
-
delete node.isLoad
|
|
491
|
-
delete node.mapInfo
|
|
492
|
-
delete node.isReadOnly
|
|
493
|
-
node.id = `LEAF_${level}_${node.guid}_${parentId}`
|
|
494
|
-
this.visibleKeys.push(node.id)
|
|
495
|
-
}
|
|
496
|
-
// 如果当前节点有children属性,则对每个子节点递归调用addLevelToNodes
|
|
497
|
-
if (node.children && Array.isArray(node.children)) {
|
|
498
|
-
node.children.forEach(child => this.handleLayerNode(child, level + 1, node.id));
|
|
499
|
-
}
|
|
500
|
-
},
|
|
501
|
-
|
|
502
|
-
/**
|
|
503
|
-
* 显示指定图层
|
|
504
|
-
* @param {array} nodes 图层节点集,兼容keys/leaf节点/branch节点
|
|
505
|
-
* @param {boolean} args.loadMask 是否添加遮罩层
|
|
506
|
-
* @param {boolean} args.refreshTiles 是否刷新瓦片
|
|
507
|
-
* @returns {array} 对应的图层keys
|
|
508
|
-
*/
|
|
509
|
-
async showLayers(nodes = [], args = {loadMask: true, refreshTiles: true}) {
|
|
510
|
-
// 参数对象转义
|
|
511
|
-
const loadMask = _.isUndefined(args.loadMask) ? true : !!args.loadMask
|
|
512
|
-
const refreshTiles = _.isUndefined(args.refreshTiles) ? true : !!args.refreshTiles
|
|
513
|
-
// 关闭全部图层
|
|
514
|
-
await this.requestServer({
|
|
515
|
-
api: 'layer/hidelayers',
|
|
516
|
-
params: {type: 'all'},
|
|
517
|
-
message: '关闭全部图层',
|
|
518
|
-
loadMask
|
|
519
|
-
})
|
|
520
|
-
const nodesToLabels = ns => {
|
|
521
|
-
let ls = [], ks = []
|
|
522
|
-
if (Array.isArray(ns)) {
|
|
523
|
-
const getLabelByKey = (tree, key) => {
|
|
524
|
-
let labels = []
|
|
525
|
-
|
|
526
|
-
function doRecursion(array) {
|
|
527
|
-
for (let node of array) {
|
|
528
|
-
if (node.id == key) {
|
|
529
|
-
if (Array.isArray(node.layers)) {
|
|
530
|
-
labels = node.layers.map(v => v.label)
|
|
531
|
-
} else {
|
|
532
|
-
labels = [node.label]
|
|
533
|
-
}
|
|
534
|
-
break
|
|
535
|
-
} else if (Array.isArray(node.children) && node.children.length > 0) {
|
|
536
|
-
doRecursion(node.children)
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
doRecursion(tree)
|
|
542
|
-
return labels
|
|
543
|
-
}
|
|
544
|
-
ns.forEach(n => {
|
|
545
|
-
if (typeof (n) == 'string') {
|
|
546
|
-
ls = _.concat(ls, getLabelByKey(this.treeLayers, n))
|
|
547
|
-
ks.push(n)
|
|
548
|
-
} else if (typeof (n) == 'object') {
|
|
549
|
-
if (Array.isArray(n.layers)) {
|
|
550
|
-
ls = _.concat(ls, n.layers.map(v => v.label))
|
|
551
|
-
ks = _.concat(ls, n.layers.map(v => v.id))
|
|
552
|
-
} else {
|
|
553
|
-
ls.push(n.label)
|
|
554
|
-
ks.push(n.id)
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
})
|
|
558
|
-
}
|
|
559
|
-
return [ls, ks]
|
|
560
|
-
}
|
|
561
|
-
|
|
562
|
-
const [labels, keys] = nodesToLabels(nodes)
|
|
563
|
-
await this.requestServer({
|
|
564
|
-
api: 'layer/showlayers',
|
|
565
|
-
params: {
|
|
566
|
-
layers: _.join(labels),
|
|
567
|
-
packettype: 'layer',
|
|
568
|
-
action:'showlayers',
|
|
569
|
-
mapid: this.requestOptions.mapid},
|
|
570
|
-
message: '打开指定图层',
|
|
571
|
-
loadMask
|
|
572
|
-
})
|
|
573
|
-
if (refreshTiles) {
|
|
574
|
-
this.fire('refreshtilelayer')
|
|
575
|
-
}
|
|
576
|
-
this.visibleKeys = keys
|
|
577
|
-
|
|
578
|
-
return this.visibleKeys
|
|
579
|
-
},
|
|
580
|
-
|
|
581
|
-
/**
|
|
582
|
-
* 显示指定图组,支持'xx>yy>zz'形式的精确选择
|
|
583
|
-
* @param {array} sets 图组名称
|
|
584
|
-
* @param {boolean} args.loadMask 是否添加遮罩层
|
|
585
|
-
* @param {boolean} args.refreshTiles 是否刷新瓦片
|
|
586
|
-
* @returns {array} 对应的图层keys
|
|
587
|
-
*/
|
|
588
|
-
async showLayerSets(sets = [], args = {loadMask: true, refreshTiles: true}) {
|
|
589
|
-
// 参数对象转义
|
|
590
|
-
const loadMask = _.isUndefined(args.loadMask) ? true : !!args.loadMask
|
|
591
|
-
const refreshTiles = _.isUndefined(args.refreshTiles) ? true : !!args.refreshTiles
|
|
592
|
-
if (_.isString(sets) && sets.length > 0) {
|
|
593
|
-
sets = [sets]
|
|
594
|
-
}
|
|
595
|
-
if (this.treeLayers.length > 0) {
|
|
596
|
-
// 获取目标节点的图层集
|
|
597
|
-
const collectLayers = node => {
|
|
598
|
-
let result = []
|
|
599
|
-
if (Array.isArray(node.children) && node.children.length > 0) {
|
|
600
|
-
node.children.forEach(v => {
|
|
601
|
-
result = _.concat(result, collectLayers(v))
|
|
602
|
-
})
|
|
603
|
-
} else {
|
|
604
|
-
result = _.concat(result, node.layers || node)
|
|
605
|
-
}
|
|
606
|
-
return result
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
// 组织并定位图集
|
|
610
|
-
let keys = []
|
|
611
|
-
sets.forEach(set => {
|
|
612
|
-
let node
|
|
613
|
-
set.split('>').forEach(v => {
|
|
614
|
-
if (v) {
|
|
615
|
-
node = getTreeNode(node ? [node] : this.treeLayers, {label: v})
|
|
616
|
-
}
|
|
617
|
-
})
|
|
618
|
-
if (node) {
|
|
619
|
-
keys.push(node.id)
|
|
620
|
-
collectLayers(node).forEach(v => {
|
|
621
|
-
keys.push(v.id)
|
|
622
|
-
})
|
|
623
|
-
}
|
|
624
|
-
})
|
|
625
|
-
await this.showLayers(keys, {loadMask, refreshTiles})
|
|
626
|
-
return keys
|
|
627
|
-
}
|
|
628
|
-
},
|
|
629
|
-
|
|
630
|
-
/**
|
|
631
|
-
* 获取指定图组的所有key,支持'xx>yy>zz'形式的精确选择
|
|
632
|
-
* @param {array} sets 图组名称
|
|
633
|
-
* @param {array} except 被排除的图层名称
|
|
634
|
-
* @returns {array} 对应的图层keys
|
|
635
|
-
*/
|
|
636
|
-
async getLayerSetsKeys(sets = [], except = []){
|
|
637
|
-
if (_.isString(sets) && sets.length > 0) {
|
|
638
|
-
sets = [sets]
|
|
639
|
-
}
|
|
640
|
-
if (this.treeLayers.length > 0) {
|
|
641
|
-
// 获取目标节点的图层集
|
|
642
|
-
const collectLayers = node => {
|
|
643
|
-
let result = []
|
|
644
|
-
if (Array.isArray(node.children) && node.children.length > 0) {
|
|
645
|
-
node.children.forEach(v => {
|
|
646
|
-
result = _.concat(result, collectLayers(v))
|
|
647
|
-
})
|
|
648
|
-
} else {
|
|
649
|
-
result = _.concat(result, node.layers || node)
|
|
650
|
-
}
|
|
651
|
-
return result
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
// 组织并定位图集
|
|
655
|
-
let keys = []
|
|
656
|
-
sets.forEach(set => {
|
|
657
|
-
let node
|
|
658
|
-
set.split('>').forEach(v => {
|
|
659
|
-
if (v) {
|
|
660
|
-
node = getTreeNode(node ? [node] : this.treeLayers, {label: v})
|
|
661
|
-
}
|
|
662
|
-
})
|
|
663
|
-
if (node) {
|
|
664
|
-
keys.push(node.id)
|
|
665
|
-
collectLayers(node).forEach(v => {
|
|
666
|
-
let flag = false
|
|
667
|
-
except.forEach(item =>{
|
|
668
|
-
if(v.label.indexOf(item) > -1){
|
|
669
|
-
flag = true
|
|
670
|
-
}
|
|
671
|
-
})
|
|
672
|
-
if(!flag){
|
|
673
|
-
keys.push(v.id)
|
|
674
|
-
}
|
|
675
|
-
})
|
|
676
|
-
}
|
|
677
|
-
})
|
|
678
|
-
return keys
|
|
679
|
-
}
|
|
680
|
-
},
|
|
681
|
-
|
|
682
|
-
/**
|
|
683
|
-
* 查询实体信息
|
|
684
|
-
* @param {object} params 查询参数
|
|
685
|
-
* @param {boolean} loadMask 是否添加遮罩层
|
|
686
|
-
*/
|
|
687
|
-
queryEntity(params = {}, loadMask) {
|
|
688
|
-
const data = L.extend({
|
|
689
|
-
stamp: Date.now(),
|
|
690
|
-
dsGuid: this.options.dsGuid, //this.requestOptions.dsid || '',
|
|
691
|
-
returnAttribute: true,
|
|
692
|
-
geometryTypes: 'point,line,polyline,polygon,compound',
|
|
693
|
-
layerNames: '',
|
|
694
|
-
returnFeatureInfo: 'all',
|
|
695
|
-
returnGroupByLayer: true
|
|
696
|
-
}, params)
|
|
697
|
-
|
|
698
|
-
return this.requestCloudMapData({
|
|
699
|
-
api: 'api/gis/mapserver/rest/feature/query',
|
|
700
|
-
method: 'post',
|
|
701
|
-
data,
|
|
702
|
-
headers: {
|
|
703
|
-
Authorization: this.token
|
|
704
|
-
},
|
|
705
|
-
message: '查询实体',
|
|
706
|
-
loadMask
|
|
707
|
-
})
|
|
708
|
-
},
|
|
709
|
-
|
|
710
|
-
/**
|
|
711
|
-
* 查询要素字典
|
|
712
|
-
* @param {string} targetDsGuid 数据源唯一标识
|
|
713
|
-
* @param {boolean} loadMask 是否添加遮罩层
|
|
714
|
-
*/
|
|
715
|
-
getFeatureDict(loadMask) {
|
|
716
|
-
return this.requestCloudMapData({
|
|
717
|
-
api: 'api/cfg/features/get',
|
|
718
|
-
message: '查询字典',
|
|
719
|
-
loadMask,
|
|
720
|
-
params: {
|
|
721
|
-
stamp: Date.now(),
|
|
722
|
-
dsGuid: this.options.dsGuid,
|
|
723
|
-
}
|
|
724
|
-
})
|
|
725
|
-
},
|
|
726
|
-
|
|
727
|
-
// 获取缩略图
|
|
728
|
-
getThumbnail() {
|
|
729
|
-
return new Promise(resolve => {
|
|
730
|
-
if (this.extent.length == 4) {
|
|
731
|
-
const {url, dsid, mapid, uid} = this.requestOptions
|
|
732
|
-
axios.get(`${url}wmsmap/getmap`, {
|
|
733
|
-
params: {
|
|
734
|
-
dsid,
|
|
735
|
-
mapid,
|
|
736
|
-
uid,
|
|
737
|
-
request: 'GetMap',
|
|
738
|
-
service: 'WMS',
|
|
739
|
-
width: 256,
|
|
740
|
-
height: 256,
|
|
741
|
-
format: 'image/png',
|
|
742
|
-
transparent: true,
|
|
743
|
-
version: '1.1.1',
|
|
744
|
-
bbox: _.join(this.extent, ','),
|
|
745
|
-
},
|
|
746
|
-
responseType: 'arraybuffer'
|
|
747
|
-
}).then(result => {
|
|
748
|
-
const base64Data = btoa(new Uint8Array(result.data).reduce((data, byte) => data + String.fromCharCode(byte), ''))
|
|
749
|
-
resolve(`data:image/png;base64,${base64Data}`)
|
|
750
|
-
})
|
|
751
|
-
}
|
|
752
|
-
})
|
|
753
|
-
},
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
// 获取切片图层对象
|
|
757
|
-
// 适用于requestOptions、leafletOptions以及图层状态已经准备的场景
|
|
758
|
-
currentTileLayer() {
|
|
759
|
-
const {url, dsid, mapid, uid} = this.requestOptions
|
|
760
|
-
const {wmscrs, maxZoom} = this.leafletOptions
|
|
761
|
-
const wmsUrl = `${url}wmsmap/getmap?dsid=${dsid}&mapid=${mapid}&uid=${uid}&tid=${idGen()}`
|
|
762
|
-
return L.tileLayer.wms(wmsUrl, {
|
|
763
|
-
format: 'image/png',
|
|
764
|
-
transparent: true,
|
|
765
|
-
crs: wmscrs,
|
|
766
|
-
maxZoom: maxZoom
|
|
767
|
-
})
|
|
768
|
-
},
|
|
769
|
-
|
|
770
|
-
// 生成切片图层对象
|
|
771
|
-
async createTileLayer({beforeCreate} = {}) {
|
|
772
|
-
await this.start()
|
|
773
|
-
if (_.isFunction(beforeCreate)) {
|
|
774
|
-
await beforeCreate(this)
|
|
775
|
-
}
|
|
776
|
-
await this.setDefaultLayers()
|
|
777
|
-
return this.currentTileLayer()
|
|
778
|
-
}
|
|
779
|
-
|
|
780
|
-
})
|