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
| import * as mars3d from "mars3d"
|
| export let map // mars3d.Map三维地图对象
|
| // 需要覆盖config.json中地图属性参数(当前示例框架中自动处理合并)
| export const mapOptions = {
| scene: {
| center: { lat: 31.798703, lng: 117.207366, alt: 2033, heading: 31, pitch: -29 }
| },
| terrain: {
| show: false
| },
| layers: [
| {
| name: "合肥教育点",
| type: "wfs",
| url: "//server.mars3d.cn/geoserver/mars/wfs",
| layer: "mars:hfjy",
| parameters: {
| // 支持所有wfs的参数
| maxFeatures: 500
| },
| minimumLevel: 13,
| debuggerTileInfo: false,
| symbol: {
| type: "billboardP",
| styleOptions: {
| image: "img/marker/mark1.png",
| scale: 0.7,
| verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
| scaleByDistance: true,
| scaleByDistance_far: 20000,
| scaleByDistance_farValue: 0.5,
| scaleByDistance_near: 1000,
| scaleByDistance_nearValue: 1,
| clampToGround: true,
| label: {
| text: "{项目名称}",
| font_size: 15,
| color: "#ffffff",
| outline: true,
| outlineColor: "#000000",
| pixelOffsetY: -30,
| distanceDisplayCondition: true,
| distanceDisplayCondition_far: 2000,
| distanceDisplayCondition_near: 0
| }
| }
| },
| popup: "all",
| show: true
| }
| ]
| }
|
| /**
| * 初始化地图业务,生命周期钩子函数(必须)
| * 框架在地图初始化完成后自动调用该函数
| * @param {mars3d.Map} mapInstance 地图对象
| * @returns {void} 无
| */
| export function onMounted(mapInstance) {
| map = mapInstance // 记录首次创建的map
| map.basemap = 2017 // 蓝色底图
|
| addWmsLayer()
| }
|
| /**
| * 释放当前地图业务的生命周期函数
| * @returns {void} 无
| */
| export function onUnmounted() {
| map = null
| }
| /**
| * WFS图层
| *
| * @returns {void} 无
| */
| function addWmsLayer() {
| const changeLevel = 15
|
| // 瓦片图,参考用
| const tileLayer = new mars3d.layer.WmsLayer({
| name: "建筑物面WMS",
| type: "wms",
| url: "//server.mars3d.cn/geoserver/mars/wms",
| layers: "mars:hfjzw",
| crs: "EPSG:4326",
| parameters: {
| transparent: "true",
| format: "image/png"
| },
| maximumLevel: changeLevel - 1,
| maximumTerrainLevel: changeLevel - 1,
| popup: "名称:{NAME}<br />层数:{floor}",
| show: true
| })
| map.addLayer(tileLayer)
|
| const wfsLayer = new mars3d.layer.WfsLayer({
| name: "建筑物面WFS",
| url: "//server.mars3d.cn/geoserver/mars/wfs",
| layer: "mars:hfjzw",
| parameters: {
| // 支持所有wfs的参数
| maxFeatures: 210
| },
| minimumLevel: changeLevel,
| symbol: {
| type: "polygonP",
| styleOptions: {
| color: "#00469c",
| outline: false,
| opacity: 1
| }
| },
| buildings: {
| cloumn: "floor"
| },
| debuggerTileInfo: false,
| popup: "名称:{NAME}<br />层数:{floor}",
| show: true
| })
| map.addLayer(wfsLayer)
|
| // 绑定事件
| wfsLayer.on(mars3d.EventType.click, function (event) {
| console.log("单击了图层", event)
| })
|
| let timeTik
| wfsLayer.on(mars3d.EventType.update, function (event) {
| console.log(`图层内数据更新了`, event)
|
| clearTimeout(timeTik)
| timeTik = setTimeout(() => {
| if (!wfsLayer.isLoading) {
| console.log(`本批次数据加载完成`)
| }
| }, 1000)
| })
| }
|
| // 图层状态 在组件中进行管理的图层
| export function getManagerLayer() {
| return map.getLayer("建筑物面WFS", "name")
| }
|
|