af-mobile-client-vue3 1.1.2 → 1.1.4

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.
@@ -1,330 +0,0 @@
1
- <script setup lang="ts">
2
- import { showNotify } from 'vant'
3
- import { onMounted, ref } from 'vue'
4
- import XOlMap from './index.vue'
5
- import 'vant/lib/index.css'
6
-
7
- const mapRef = ref()
8
-
9
- // WMS 配置
10
- const wmsConfig = {
11
- layers: [
12
- {
13
- phoneShow: false,
14
- show: false,
15
- id: 1,
16
- layerName: 'gis:lp',
17
- value: '低压管线',
18
- },
19
- {
20
- phoneShow: true,
21
- show: true,
22
- id: 2,
23
- layerName: 'gis:mp',
24
- value: '中压管线',
25
- },
26
- {
27
- phoneShow: false,
28
- show: false,
29
- id: 3,
30
- layerName: 'gis:surface_valve',
31
- value: '地面阀门',
32
- },
33
- {
34
- phoneShow: false,
35
- show: false,
36
- id: 4,
37
- layerName: 'gis:valve_chamber',
38
- value: '阀门井',
39
- },
40
- {
41
- phoneShow: false,
42
- show: false,
43
- id: 6,
44
- layerName: 'gis:hp',
45
- value: '高压管线',
46
- },
47
- {
48
- phoneShow: false,
49
- show: false,
50
- id: 5,
51
- layerName: 'gis:pressure_regulating_box',
52
- value: '调压箱',
53
- },
54
- ],
55
- wms: {
56
- workspace: 'gis',
57
- srs: 'EPSG:3857',
58
- format: 'image/png',
59
- version: '1.1.0',
60
- url: '/linepatrol/geoserver/gis/wms',
61
- },
62
- }
63
-
64
- // 初始化地图
65
- onMounted(() => {
66
- mapRef.value.init({
67
- center: [108.948024, 34.263161], // 西安坐标
68
- zoom: 12,
69
- maxZoom: 18,
70
- minZoom: 4,
71
- tianDiTuKey: 'c16876b28898637c0a1a68b3fa410504',
72
- })
73
- mapRef.value.addWMSLayers(wmsConfig)
74
- })
75
-
76
- // 地图控制函数
77
- const handleSetCenter = () => mapRef.value.setCenter([116.404, 39.915]) // 切换到北京
78
- const handleSetZoom = () => mapRef.value.setZoom(14) // 设置缩放级别为14
79
- const handleGetZoom = () => showNotify({ type: 'primary', message: `当前缩放级别:${mapRef.value.getZoom()}` })
80
- const handleSetCenterAndZoom = () => mapRef.value.setCenterAndZoom([120.153576, 30.287459], 15) // 切换到杭州
81
-
82
- // 点位数据
83
- const poiPoints = [
84
- {
85
- longitude: 108.988024,
86
- latitude: 34.283161,
87
- title: '大雁塔',
88
- extData: { type: 'poi' },
89
- },
90
- {
91
- longitude: 108.948024,
92
- latitude: 34.263161,
93
- title: '钟楼',
94
- extData: { type: 'poi' },
95
- },
96
- {
97
- longitude: 108.968024,
98
- latitude: 34.273161,
99
- title: '小寨',
100
- extData: { type: 'poi' },
101
- },
102
- ]
103
-
104
- const schoolPoints = [
105
- {
106
- longitude: 108.968024,
107
- latitude: 34.273161,
108
- title: '西安电子科技大学',
109
- extData: {
110
- type: 'school',
111
- level: '985',
112
- studentCount: 25000,
113
- departments: ['通信学院', '计算机学院', '电子工程学院'],
114
- },
115
- },
116
- ]
117
-
118
- const hospitalPoints = [
119
- {
120
- longitude: 108.948024,
121
- latitude: 34.263161,
122
- title: '西安市第一医院',
123
- extData: {
124
- type: 'hospital',
125
- level: '三甲',
126
- departments: ['急诊科', '内科', '外科'],
127
- contact: '029-12345678',
128
- address: '西安市雁塔区',
129
- },
130
- },
131
- {
132
- longitude: 108.978024,
133
- latitude: 34.278161,
134
- title: '西安市中心医院',
135
- extData: {
136
- type: 'hospital',
137
- level: '三甲',
138
- departments: ['急诊科', '内科', '外科'],
139
- contact: '029-87654321',
140
- address: '西安市新城区',
141
- },
142
- },
143
- ]
144
-
145
- // 点位处理函数
146
- function handlePointClick(point: any) {
147
- showNotify({
148
- type: 'primary',
149
- message: `点击了: ${point.title}\n类型: ${point.extData.type}`,
150
- })
151
- }
152
-
153
- // 添加点位示例
154
- function handleAddPoints() {
155
- mapRef.value.addVectorPoints({
156
- icon: 'https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-red.png',
157
- iconAnchor: [0.5, 1],
158
- data: poiPoints,
159
- onClick: handlePointClick,
160
- })
161
- }
162
-
163
- // 添加分类点位示例
164
- function handleAddPointLayer() {
165
- // 添加学校点位图层
166
- mapRef.value.addPointLayer(
167
- {
168
- id: 1,
169
- value: '学校',
170
- show: true,
171
- icon: 'https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
172
- iconAnchor: [0.5, 1],
173
- onClick: handlePointClick,
174
- },
175
- schoolPoints,
176
- )
177
-
178
- // 添加医院点位图层
179
- mapRef.value.addPointLayer(
180
- {
181
- id: 2,
182
- value: '医院',
183
- show: true,
184
- icon: 'https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
185
- iconAnchor: [0.5, 1],
186
- onClick: handlePointClick,
187
- },
188
- hospitalPoints,
189
- )
190
- }
191
-
192
- // 添加海量点示例
193
- function handleAddMassPoints() {
194
- // 生成10000个随机点
195
- const data = Array.from({ length: 10000 }, (_, index) => ({
196
- longitude: 108.948024 + (Math.random() - 0.5) * 0.1,
197
- latitude: 34.263161 + (Math.random() - 0.5) * 0.1,
198
- title: `点位${index + 1}`,
199
- extData: { type: 'mass' },
200
- }))
201
-
202
- mapRef.value.addWebGLPoints({
203
- icon: 'https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-red.png',
204
- iconSize: [6, 6],
205
- data,
206
- performance: {
207
- enableChunk: true,
208
- chunkSize: 1000,
209
- },
210
- })
211
- }
212
- </script>
213
-
214
- <template>
215
- <div class="demo-container">
216
- <div class="map-container">
217
- <XOlMap ref="mapRef" />
218
- </div>
219
- <div class="control-panel">
220
- <div class="control-group">
221
- <div class="group-title">
222
- 地图控制
223
- </div>
224
- <van-button type="primary" size="small" @click="handleSetCenter">
225
- 切换到北京
226
- </van-button>
227
- <van-button type="primary" size="small" @click="handleSetZoom">
228
- 设置缩放级别14
229
- </van-button>
230
- <van-button type="primary" size="small" @click="handleGetZoom">
231
- 获取当前缩放级别
232
- </van-button>
233
- <van-button type="primary" size="small" @click="handleSetCenterAndZoom">
234
- 切换到杭州(级别15)
235
- </van-button>
236
- </div>
237
-
238
- <div class="control-group">
239
- <div class="group-title">
240
- 点位示例
241
- </div>
242
- <van-button type="success" size="small" @click="handleAddPoints">
243
- 添加普通点位
244
- </van-button>
245
- <van-button type="success" size="small" @click="handleAddPointLayer">
246
- 添加分类点位
247
- </van-button>
248
- <van-button type="warning" size="small" @click="handleAddMassPoints">
249
- 添加海量点(1万)
250
- </van-button>
251
- </div>
252
- </div>
253
- </div>
254
- </template>
255
-
256
- <style scoped lang="less">
257
- .demo-container {
258
- width: 100%;
259
- height: 100%;
260
- position: relative;
261
- }
262
-
263
- .map-container {
264
- width: 100%;
265
- height: 100%;
266
- }
267
-
268
- .control-panel {
269
- position: absolute;
270
- left: 10px;
271
- top: 10px;
272
- z-index: 1000;
273
- background: white;
274
- padding: 10px;
275
- border-radius: 4px;
276
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
277
- display: flex;
278
- flex-direction: column;
279
- gap: 16px;
280
-
281
- .control-group {
282
- display: flex;
283
- flex-direction: column;
284
- gap: 8px;
285
-
286
- .group-title {
287
- font-size: 14px;
288
- font-weight: 500;
289
- color: #333;
290
- padding-left: 4px;
291
- border-left: 3px solid #1989fa;
292
- }
293
-
294
- :deep(.van-button) {
295
- margin-bottom: 8px;
296
-
297
- &:last-child {
298
- margin-bottom: 0;
299
- }
300
- }
301
- }
302
-
303
- :deep(.van-button) {
304
- width: 140px;
305
- }
306
- }
307
-
308
- // 移动端适配
309
- @media screen and (max-width: 768px) {
310
- .control-panel {
311
- left: 8px;
312
- top: 8px;
313
- padding: 8px;
314
- gap: 12px;
315
-
316
- .control-group {
317
- gap: 6px;
318
-
319
- .group-title {
320
- font-size: 12px;
321
- }
322
- }
323
-
324
- :deep(.van-button) {
325
- width: 120px;
326
- font-size: 12px;
327
- }
328
- }
329
- }
330
- </style>