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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
| import * as mars3d from "mars3d"
|
| export let map // mars3d.Map三维地图对象
| let queryMapserver
| let drawGraphic
| let geoJsonLayer
|
| // 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并)
| export const mapOptions = {
| scene: {
| center: { lat: 31.837532, lng: 117.202653, alt: 10586, heading: 0, pitch: -90 }
| },
| control: {
| infoBox: false
| }
| }
|
| export const eventTarget = new mars3d.BaseClass() // 事件对象,用于抛出事件到面板中
|
| /**
| * 初始化地图业务,生命周期钩子函数(必须)
| * 框架在地图初始化完成后自动调用该函数
| * @param {mars3d.Map} mapInstance 地图对象
| * @returns {void} 无
| */
| export function onMounted(mapInstance) {
| map = mapInstance // 记录map
|
| // 用于参考
| const arcGisLayer = new mars3d.layer.ArcGisLayer({
| url: "//server.mars3d.cn/arcgis/rest/services/mars/guihua/MapServer",
| opacity: 0.2
| })
| map.addLayer(arcGisLayer)
|
| // 查询服务
| queryMapserver = new mars3d.query.QueryArcServer({
| url: "http://server.mars3d.cn/arcgis/rest/services/mars/guihua/MapServer/0"
| })
|
| // 用于显示查询结果(geojson)的图层
| geoJsonLayer = new mars3d.layer.GeoJsonLayer({
| name: "规划用地",
| symbol: {
| type: "polygonP",
| styleOptions: {
| color: "rgba(205, 233, 247, 0.7)", // 填充颜色
| clampToGround: true
| },
| styleField: "用地编号",
| styleFieldOptions: styleFieldOptions
| },
| // popup: "all",
| popup: "名称:{用地名称}<br />编号:{用地编号}<br />类型:{规划用地}<br />面积:{muArea}亩"
| })
| map.addLayer(geoJsonLayer)
| }
|
| /**
| * 释放当前地图业务的生命周期函数
| * @returns {void} 无
| */
| export function onUnmounted() {
| map = null
| }
|
| // 框选查询 矩形
| export function drawRectangle() {
| clearAll()
| map.graphicLayer.startDraw({
| type: "rectangle",
| style: {
| color: "#00ffff",
| opacity: 0.3,
| outline: true,
| outlineWidth: 2,
| outlineColor: "#ffffff",
| clampToGround: true
| },
| success: function (graphic) {
| drawGraphic = graphic
| }
| })
| }
| // 框选查询 圆
| export function drawCircle() {
| clearAll()
| map.graphicLayer.startDraw({
| type: "circle",
| style: {
| color: "#00ffff",
| opacity: 0.3,
| outline: true,
| outlineWidth: 2,
| outlineColor: "#ffffff",
| clampToGround: true
| },
| success: function (graphic) {
| drawGraphic = graphic
| }
| })
| }
| // 框选查询 多边行
| export function drawPolygon() {
| clearAll()
| map.graphicLayer.startDraw({
| type: "polygon",
| style: {
| color: "#00ffff",
| opacity: 0.3,
| outline: true,
| outlineWidth: 2,
| outlineColor: "#ffffff",
| clampToGround: true
| },
| success: function (graphic) {
| drawGraphic = graphic
| }
| })
| }
| // 清除数据
| export function clearAll() {
| drawGraphic = null
| map.graphicLayer.clear()
| geoJsonLayer.clear()
| }
|
| // 查询数据
| export function queryData(queryVal) {
| if (drawGraphic == null) {
| globalMsg("请绘制查询区域!")
| return
| }
|
| queryMapserver.query({
| column: "用地名称",
| text: queryVal,
| graphic: drawGraphic,
| page: false,
| success: (result) => {
| if (result.count === 0) {
| globalMsg("未查询到相关记录!")
| return
| }
| console.log("查询到的记录", result)
|
| const drawGeoJSON = drawGraphic.toGeoJSON({ outline: true })
|
| const arrArea = []
| const arrFeatures = result.geojson.features
| for (let i = 0; i < arrFeatures.length; i++) {
| const feature = arrFeatures[i]
|
| try {
| const geojsonNew = turf.intersect(drawGeoJSON, feature) // 切割
|
| if (geojsonNew) {
| feature.geometry = geojsonNew.geometry
| }
| } catch (e) {
| globalMsg("切割异常,请重新切割")
| clearAll()
| }
|
| const area = turf.area(feature) || feature.properties.Shape_Area || 0
| feature.properties.muArea = mars3d.Util.formatNum(area * 0.0015, 2) // 平方米转亩
|
| // 需要统计的数据
| arrArea.push({
| type: feature.properties.用地名称,
| area: feature.properties.muArea
| })
| }
|
| // 显示数据
| geoJsonLayer.load({ data: result.geojson })
| calculateArea(arrArea)
| },
| error: (error, msg) => {
| console.log("服务访问错误", error)
| globalAlert(msg, "服务访问错误")
| }
| })
| }
|
| // 统计面积数据并按表格图表来展示
| function calculateArea(arr) {
| console.log("计算前数据", arr)
|
| const objTemp = {}
| for (let i = 0; i < arr.length; i++) {
| const item = arr[i]
|
| if (!objTemp[item.type]) {
| objTemp[item.type] = { area: 0, count: 0 }
| }
|
| objTemp[item.type].area += item.area
| objTemp[item.type].count++
| }
|
| const arrTable = [] // 类型+面积+数量
| for (const type in objTemp) {
| const area = mars3d.Util.formatNum(objTemp[type].area, 2)
| arrTable.push({ type: type, area: area, count: objTemp[type].count })
| }
| eventTarget.fire("tableData", { list: arrTable })
| }
|
| // 规划面着色配置
| const styleFieldOptions = {
| A1: {
| // 行政办公用地
| color: "rgba(255,127,159,0.9)"
| },
| A2: {
| // 文化设施用地
| color: "rgba(255,159,127,0.9)"
| },
| A22: {
| // 文化活动用地
| color: "rgba(255,159,127,0.9)"
| },
| A3: {
| // 教育科研用地
| color: "rgba(255,127,191,0.9)"
| },
| A31: {
| // 高等院校用地
| color: "rgba(255,127,191,0.9)"
| },
| A32: {
| // 中等专业学校用地
| color: "rgba(255,127,191,0.9)"
| },
| A33: {
| // 中小学用地
| color: "rgba(255,255,127,0.9)"
| },
| A34: {
| // 特殊教育用地
| color: "rgba(255,127,191,0.9)"
| },
| A35: {
| // 科研用地
| color: "rgba(255,127,191,0.9)"
| },
| A4: {
| // 体育用地
| color: "rgba(255,127,0,0.9)"
| },
| A41: {
| // 体育场馆用地
| color: "rgba(255,127,0,0.9)"
| },
| A5: {
| // 医疗卫生用地
| color: "rgba(255,127,127,0.9)"
| },
| A51: {
| // 医院用地
| color: "rgba(255,127,127,0.9)"
| },
| A52: {
| // 卫生防疫用地
| color: "rgba(255,127,127,0.9)"
| },
| A59: {
| // 其他医疗卫生用地
| color: "rgba(255,127,127,0.9)"
| },
| A6: {
| // 社会福利用地
| color: "rgba(165,82,103,0.9)"
| },
| A7: {
| // 文物古迹用地
| color: "rgba(165,41,0,0.9)"
| },
| A9: {
| // 宗教用地
| color: "rgba(165,82,103,0.9)"
| },
| B: {
| // 商业服务业设施用地
| color: "rgba(255,0,63,0.9)"
| },
| B1: {
| // 商业用地
| color: "rgba(255,0,63,0.9)"
| },
| B11: {
| // 零售商业用地
| color: "rgba(255,0,63,0.9)"
| },
| B12: {
| // 批发市场用地
| color: "rgba(255,0,63,0.9)"
| },
| B13: {
| // 餐饮用地
| color: "rgba(255,0,63,0.9)"
| },
| B14: {
| // 旅馆用地
| color: "rgba(255,0,63,0.9)"
| },
| B2: {
| // 商务用地
| color: "rgba(255,0,63,0.9)"
| },
| B21: {
| // 金融保险用地
| color: "rgba(255,0,63,0.9)"
| },
| B29: {
| // 其他商务用地
| color: "rgba(255,0,63,0.9)"
| },
| B3: {
| // 娱乐康体用地
| color: "rgba(255,159,127,0.9)"
| },
| B31: {
| // 娱乐用地
| color: "rgba(255,159,127,0.9)"
| },
| B32: {
| // 康体用地
| color: "rgba(255,159,127,0.9)"
| },
| B4: {
| // 公用设施营业网点用地
| color: "rgba(255,159,127,0.9)"
| },
| B41: {
| // 加油加气站用地
| color: "rgba(255,159,127,0.9)"
| },
| B9: {
| // 其他服务设施用地
| color: "rgba(255,159,127,0.9)"
| },
| BR: {
| // 商住混合用地
| color: "rgba(255,0,63,0.9)"
| },
| E1: {
| // 水域
| color: "rgba(127,255,255,0.9)"
| },
| E2: {
| // 农林用地
| color: "rgba(41,165,0,0.9)"
| },
| E9: {
| // 其他非建设用地
| color: "rgba(127,127,63,0.9)"
| },
| G: {
| // 绿地与广场用地
| color: "rgba(0,127,0,0.9)"
| },
| G1: {
| // 公园绿地
| color: "rgba(0,255,63,0.9)"
| },
| G2: {
| // 防护绿地
| color: "rgba(0,127,0,0.9)"
| },
| G3: {
| // 广场用地
| color: "rgba(128,128,128,0.9)"
| },
| H: {
| // 建设用地
| color: "rgba(165,124,0,0.9)"
| },
| H1: {
| // 城乡居民点建设用地
| color: "rgba(165,124,0,0.9)"
| },
| H14: {
| // 村庄建设用地
| color: "rgba(165,165,82,0.9)"
| },
| H2: {
| // 区域交通设施用地
| color: "rgba(192,192,192,0.9)"
| },
| H21: {
| // 铁路用地
| color: "rgba(192,192,192,0.9)"
| },
| H22: {
| // 公路用地
| color: "rgba(192,192,192,0.9)"
| },
| H23: {
| // 港口用地
| color: "rgba(192,192,192,0.9)"
| },
| H3: {
| // 区域公共设施用地
| color: "rgba(82,165,82,0.9)"
| },
| H4: {
| // 特殊用地
| color: "rgba(47,76,38,0.9)"
| },
| H41: {
| // 军事用地
| color: "rgba(47,76,38,0.9)"
| },
| H42: {
| // 安保用地
| color: "rgba(47,76,38,0.9)"
| },
| H9: {
| // 其他建设用地
| color: "rgba(165,165,82,0.9)"
| },
| M: {
| // 工业用地
| color: "rgba(127,95,63,0.9)"
| },
| M1: {
| // 一类工业用地
| color: "rgba(127,95,63,0.9)"
| },
| M2: {
| // 二类工业用地
| color: "rgba(76,57,38,0.9)"
| },
| M4: {
| // 农业服务设施用地
| color: "rgba(153,38,0,0.9)"
| },
| R: {
| // 居住用地
| color: "rgba(255,255,0,0.9)"
| },
| R1: {
| // 一类居住用地
| color: "rgba(255,255,127,0.9)"
| },
| R2: {
| // 二类居住用地
| color: "rgba(255,255,0,0.9)"
| },
| R21: {
| // 住宅用地
| color: "rgba(255,255,0,0.9)"
| },
| R22: {
| // 服务设施用地
| color: "rgba(255,255,0,0.9)"
| },
| RB: {
| // 商住混合用地
| color: "rgba(255,191,0,0.9)"
| },
| S: {
| // 道路与交通设施用地
| color: "rgba(128,128,128,0.9)"
| },
| S2: {
| // 城市轨道交通用地
| color: "rgba(128,128,128,0.9)"
| },
| S3: {
| // 交通枢纽用地
| color: "rgba(192,192,192,0.9)"
| },
| S4: {
| // 交通场站用地
| color: "rgba(128,128,128,0.9)"
| },
| S41: {
| // 公共交通场站用地
| color: "rgba(128,128,128,0.9)"
| },
| S42: {
| // 社会停车场用地
| color: "rgba(128,128,128,0.9)"
| },
| S9: {
| // 其他交通设施用地
| color: "rgba(63,111,127,0.9)"
| },
| U: {
| // 公用设施用地
| color: "rgba(0,95,127,0.9)"
| },
| U1: {
| // 供应设施用地
| color: "rgba(0,95,127,0.9)"
| },
| U11: {
| // 供水用地
| color: "rgba(0,95,127,0.9)"
| },
| U12: {
| // 供电用地
| color: "rgba(0,95,127,0.9)"
| },
| U13: {
| // 供燃气用地
| color: "rgba(0,95,127,0.9)"
| },
| U14: {
| // 供热用地
| color: "rgba(0,95,127,0.9)"
| },
| U15: {
| // 通信用地
| color: "rgba(0,95,127,0.9)"
| },
| U2: {
| // 环境设施用地
| color: "rgba(0,95,127,0.9)"
| },
| U21: {
| // 排水用地
| color: "rgba(0,95,127,0.9)"
| },
| U22: {
| // 环卫用地
| color: "rgba(0,95,127,0.9)"
| },
| U3: {
| // 安全设施用地
| color: "rgba(0,95,127,0.9)"
| },
| U4: {
| // 环境设施用地
| color: "rgba(0,95,127,0.9)"
| },
| U9: {
| // 其他公用设施用地
| color: "rgba(0,95,127,0.9)"
| },
| W: {
| // 仓储用地
| color: "rgba(159,127,255,0.9)"
| }
| }
|
|