ym-giswidget-2d 1.0.79 → 1.0.80
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/API.md +399 -0
- package/README.md +37 -19
- package/components/address-search/AddressSearch.vue.d.ts +3 -0
- package/components/address-search/AddressSearch.vue.js +1 -1
- package/components/address-search/AddressSearch.vue2.js +62 -25
- package/components/address-search/index.css +17 -17
- package/components/address-search/index.d.ts +3 -0
- package/components/difference/Difference.vue.js +1 -1
- package/components/export/Export.vue.js +1 -1
- package/components/export/Export.vue2.js +1 -0
- package/components/export/index.css +1 -1
- package/components/heatmap/Heatmap.vue.d.ts +1 -1
- package/components/heatmap/Heatmap.vue.js +1 -1
- package/components/heatmap/Heatmap.vue2.js +135 -132
- package/components/heatmap/index.css +17 -3
- package/components/multi-screen/MultiScreen.vue.js +1 -1
- package/components/multi-screen/index.css +10 -3
- package/components/swipe-layer/SwipeLayer.vue.d.ts +4 -1
- package/components/swipe-layer/SwipeLayer.vue.js +9 -7
- package/components/swipe-layer/index.d.ts +5 -1
- package/config/Config.d.ts +8 -0
- package/config/Config.js +2 -0
- package/http/poi.d.ts +22 -1
- package/http/poi.js +61 -9
- package/package.json +2 -2
package/API.md
ADDED
|
@@ -0,0 +1,399 @@
|
|
|
1
|
+
# ym-giswidget-2d API 文档
|
|
2
|
+
|
|
3
|
+
> 基于 Vue 3 + Element Plus + [ym-gis-2d](https://www.npmjs.com/package/ym-gis-2d) 的 WebGIS UI 组件库。
|
|
4
|
+
> 当前版本:`1.0.79`
|
|
5
|
+
|
|
6
|
+
完整在线文档(含交互示例)见 monorepo 内 `giswidget-2d-docs`,或本地运行 `pnpm --filter giswidget-2d-docs dev`。
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 目录
|
|
11
|
+
|
|
12
|
+
- [安装](#安装)
|
|
13
|
+
- [快速开始](#快速开始)
|
|
14
|
+
- [全局配置 Config](#全局配置-config)
|
|
15
|
+
- [工具条 ITool](#工具条-itool)
|
|
16
|
+
- [组件一览](#组件一览)
|
|
17
|
+
- [HorizontallyTopToolbar 工具条](#horizontallytoptoolbar-工具条)
|
|
18
|
+
- [MapView 地图容器](#mapview-地图容器)
|
|
19
|
+
- [图层组件](#图层组件)
|
|
20
|
+
- [地图控件](#地图控件)
|
|
21
|
+
- [查询与定位](#查询与定位)
|
|
22
|
+
- [编辑工具](#编辑工具)
|
|
23
|
+
- [量测工具](#量测工具)
|
|
24
|
+
- [分析展示](#分析展示)
|
|
25
|
+
- [导入导出](#导入导出)
|
|
26
|
+
- [完整示例](#完整示例)
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## 安装
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install ym-giswidget-2d ym-gis-2d element-plus
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
import 'ol/ol.css';
|
|
38
|
+
import 'ym-gis-2d/assets/main.css';
|
|
39
|
+
import 'element-plus/dist/index.css';
|
|
40
|
+
|
|
41
|
+
import { createApp } from 'vue';
|
|
42
|
+
import ElementPlus from 'element-plus';
|
|
43
|
+
import YmGisWidget2d from 'ym-giswidget-2d';
|
|
44
|
+
|
|
45
|
+
const app = createApp(App);
|
|
46
|
+
app.use(ElementPlus);
|
|
47
|
+
app.use(YmGisWidget2d);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
按需引入:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { MapView, Draw, Select, TocCard } from 'ym-giswidget-2d';
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
---
|
|
57
|
+
|
|
58
|
+
## 快速开始
|
|
59
|
+
|
|
60
|
+
```vue
|
|
61
|
+
<template>
|
|
62
|
+
<MapView style="height: 500px" @init="map = $event" />
|
|
63
|
+
<Draw v-if="map" :map="map" geometry-type="polygon" />
|
|
64
|
+
</template>
|
|
65
|
+
|
|
66
|
+
<script setup lang="ts">
|
|
67
|
+
import { ref } from 'vue';
|
|
68
|
+
import { MapView, Draw } from 'ym-giswidget-2d';
|
|
69
|
+
|
|
70
|
+
const map = ref();
|
|
71
|
+
</script>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**约定**:除 `MapView` / `MultiScreen` 外,所有组件均需传入 `map: OLMap`,建议 `v-if="map"` 等待初始化。
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 全局配置 Config
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import Config from 'ym-giswidget-2d/config/Config';
|
|
82
|
+
|
|
83
|
+
Config.tdtToken = 'YOUR_TIANDITU_TOKEN';
|
|
84
|
+
Config.amapKey = 'YOUR_AMAP_KEY';
|
|
85
|
+
Config.baiduAk = 'YOUR_BAIDU_AK';
|
|
86
|
+
Config.ServiceUrl = 'http://api-server';
|
|
87
|
+
Config.GisServiceUrl = 'http://gis-server';
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
| 属性 | 说明 |
|
|
91
|
+
|------|------|
|
|
92
|
+
| ServiceUrl | 后端业务服务 |
|
|
93
|
+
| GisServiceUrl | GIS 分析服务(SHP 导入导出) |
|
|
94
|
+
| tdtToken | 天地图 Token |
|
|
95
|
+
| amapKey | 高德 POI Key |
|
|
96
|
+
| baiduAk | 百度 POI AK |
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 工具条 ITool
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
interface ITool {
|
|
104
|
+
id: string;
|
|
105
|
+
title: string;
|
|
106
|
+
toolTip?: string;
|
|
107
|
+
classPath?: string; // 相对 components/ 的路径,如 '../draw/index.ts'
|
|
108
|
+
icon: string; // 激活态图标加 _active 后缀
|
|
109
|
+
isOnce: boolean; // true:一次性执行
|
|
110
|
+
isRepels: boolean; // true:互斥,不可同时激活
|
|
111
|
+
children?: ITool[];
|
|
112
|
+
alwaysLoad?: boolean; // true:始终挂载,v-show 控制
|
|
113
|
+
data?: any; // 传给子组件
|
|
114
|
+
showSplit?: boolean;
|
|
115
|
+
}
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## 组件一览
|
|
121
|
+
|
|
122
|
+
| 组件 | 导入 | 说明 |
|
|
123
|
+
|------|------|------|
|
|
124
|
+
| MapView | `ym-giswidget-2d` | 地图容器 |
|
|
125
|
+
| HorizontallyTopToolbar | `ym-giswidget-2d` | 顶部工具条 |
|
|
126
|
+
| TocCard | `ym-giswidget-2d` | 图层目录卡片 |
|
|
127
|
+
| LayerSwitcher | `ym-giswidget-2d` | 底图切换 |
|
|
128
|
+
| Legend | `ym-giswidget-2d` | 图例 |
|
|
129
|
+
| MousePositon | `ym-giswidget-2d` | 鼠标坐标 |
|
|
130
|
+
| ScaleLine | `ym-giswidget-2d` | 比例尺 |
|
|
131
|
+
| Draw | `ym-giswidget-2d` | 绘制 |
|
|
132
|
+
| Select | `ym-giswidget-2d` | 选择 |
|
|
133
|
+
| Identify | `ym-giswidget-2d` | I 查询 |
|
|
134
|
+
| Modify | `ym-giswidget-2d` | 节点编辑 |
|
|
135
|
+
| Snap | `ym-giswidget-2d` | 吸附 |
|
|
136
|
+
| Split | `ym-giswidget-2d` | 分割 |
|
|
137
|
+
| Difference | `ym-giswidget-2d` | 挖除 |
|
|
138
|
+
| Repair | `ym-giswidget-2d` | 修补 |
|
|
139
|
+
| Clear | `ym-giswidget-2d` | 清除要素 |
|
|
140
|
+
| AreaMeasurement | `ym-giswidget-2d` | 面积量测 |
|
|
141
|
+
| DistanceMeasurement | `ym-giswidget-2d` | 距离量测 |
|
|
142
|
+
| Location | `ym-giswidget-2d` | 坐标定位 |
|
|
143
|
+
| AddressSearch | `ym-giswidget-2d` | 地名搜索 |
|
|
144
|
+
| Heatmap | `ym-giswidget-2d` | 热力图 |
|
|
145
|
+
| SwipeLayer | `ym-giswidget-2d` | 卷帘对比 |
|
|
146
|
+
| MultiScreen | `ym-giswidget-2d` | 多屏地图 |
|
|
147
|
+
| Import | `ym-giswidget-2d` | 导入 |
|
|
148
|
+
| Export | `ym-giswidget-2d` | 导出 |
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## HorizontallyTopToolbar 工具条
|
|
153
|
+
|
|
154
|
+
```vue
|
|
155
|
+
<HorizontallyTopToolbar
|
|
156
|
+
:map="map"
|
|
157
|
+
:tools="tools"
|
|
158
|
+
:field-name="fieldName"
|
|
159
|
+
:field-values="fieldValues"
|
|
160
|
+
@loaded="onLoaded"
|
|
161
|
+
/>
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
| 属性 | 类型 | 说明 |
|
|
165
|
+
|------|------|------|
|
|
166
|
+
| map | OLMap | 必填 |
|
|
167
|
+
| tools | ITool[] | 工具配置 |
|
|
168
|
+
| fieldName | string | 传给子工具的过滤字段 |
|
|
169
|
+
| fieldValues | any[] | 传给子工具的过滤值 |
|
|
170
|
+
|
|
171
|
+
| 事件 | 说明 |
|
|
172
|
+
|------|------|
|
|
173
|
+
| loaded | alwaysLoad 子组件加载完成 |
|
|
174
|
+
|
|
175
|
+
子组件需 emit `activeInteraction({ success, message? })` 反馈激活结果。
|
|
176
|
+
|
|
177
|
+
---
|
|
178
|
+
|
|
179
|
+
## MapView 地图容器
|
|
180
|
+
|
|
181
|
+
| 属性 | 类型 | 默认 |
|
|
182
|
+
|------|------|------|
|
|
183
|
+
| projection | number | 4490 |
|
|
184
|
+
| center | number[] | — |
|
|
185
|
+
| extent | number[] | — |
|
|
186
|
+
| zoom | number | 10 |
|
|
187
|
+
| minZoom / maxZoom | number | 0 / 28 |
|
|
188
|
+
|
|
189
|
+
| 事件 | 参数 |
|
|
190
|
+
|------|------|
|
|
191
|
+
| init | `(map: OLMap)` |
|
|
192
|
+
|
|
193
|
+
| Expose | 说明 |
|
|
194
|
+
|--------|------|
|
|
195
|
+
| map | OLMap 实例 |
|
|
196
|
+
| addWKT / addWKTs / clearTempFeatures | 同 OLMap |
|
|
197
|
+
|
|
198
|
+
---
|
|
199
|
+
|
|
200
|
+
## 图层组件
|
|
201
|
+
|
|
202
|
+
### TocCard
|
|
203
|
+
|
|
204
|
+
| 属性 | 说明 |
|
|
205
|
+
|------|------|
|
|
206
|
+
| map, data | 必填 |
|
|
207
|
+
| editLayerTag | 可编辑层 tag |
|
|
208
|
+
| showOpacity / showFilter | 透明度 / 搜索 |
|
|
209
|
+
| #title | 标题插槽 |
|
|
210
|
+
|
|
211
|
+
### LayerSwitcher
|
|
212
|
+
|
|
213
|
+
| 属性 | 说明 |
|
|
214
|
+
|------|------|
|
|
215
|
+
| map, layers | 底图列表,支持 isRepels、thumbnail、checked |
|
|
216
|
+
|
|
217
|
+
### Legend
|
|
218
|
+
|
|
219
|
+
| 属性 | 说明 |
|
|
220
|
+
|------|------|
|
|
221
|
+
| map, data, title | 图例面板 |
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
## 地图控件
|
|
226
|
+
|
|
227
|
+
### MousePositon
|
|
228
|
+
|
|
229
|
+
| 属性 | 默认 | 说明 |
|
|
230
|
+
|------|------|------|
|
|
231
|
+
| showSpheroid | false | 经纬度显示 |
|
|
232
|
+
| position | bottom-left | 四角位置 |
|
|
233
|
+
| fractionDigits | 2 | 小数位 |
|
|
234
|
+
|
|
235
|
+
### ScaleLine
|
|
236
|
+
|
|
237
|
+
| 属性 | 说明 |
|
|
238
|
+
|------|------|
|
|
239
|
+
| bar / text | 线型 / 文字比例尺 |
|
|
240
|
+
| units | metric / imperial |
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## 查询与定位
|
|
245
|
+
|
|
246
|
+
### Identify
|
|
247
|
+
|
|
248
|
+
框选查询 + 属性 Popup。插槽 `#footer="{ feature, layerName }"`。
|
|
249
|
+
|
|
250
|
+
### Select
|
|
251
|
+
|
|
252
|
+
| 属性 | 说明 |
|
|
253
|
+
|------|------|
|
|
254
|
+
| selectType | rectangle / polygon / point / pointermove |
|
|
255
|
+
| selectLayers | 可查询图层 |
|
|
256
|
+
| @selected | 选中要素列表 |
|
|
257
|
+
|
|
258
|
+
### AddressSearch
|
|
259
|
+
|
|
260
|
+
| 属性 | 说明 |
|
|
261
|
+
|------|------|
|
|
262
|
+
| source | tdt / amap / baidu |
|
|
263
|
+
| zoom | 定位级别,默认 16 |
|
|
264
|
+
|
|
265
|
+
### Location
|
|
266
|
+
|
|
267
|
+
坐标定位面板,支持度分秒 / 经纬度 / 平面坐标。
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## 编辑工具
|
|
272
|
+
|
|
273
|
+
| 组件 | 关键说明 |
|
|
274
|
+
|------|----------|
|
|
275
|
+
| Draw | geometryType、@drawEnd;需 currentEditLayer |
|
|
276
|
+
| Modify | 编辑选中要素节点 |
|
|
277
|
+
| Snap | options 吸附配置 |
|
|
278
|
+
| Split | 面/线分割 |
|
|
279
|
+
| Difference | 面挖除 |
|
|
280
|
+
| Repair | 面修补(v1.0.78+) |
|
|
281
|
+
| Clear | 挂载即清除临时要素,isOnce 工具 |
|
|
282
|
+
|
|
283
|
+
编辑类工具可通过 `fieldName` + `fieldValues` 过滤 `getEditFeatures`。
|
|
284
|
+
|
|
285
|
+
---
|
|
286
|
+
|
|
287
|
+
## 量测工具
|
|
288
|
+
|
|
289
|
+
### AreaMeasurement / DistanceMeasurement
|
|
290
|
+
|
|
291
|
+
| 属性 | 说明 |
|
|
292
|
+
|------|------|
|
|
293
|
+
| unit | 测量单位 |
|
|
294
|
+
| precision | 小数位,默认 2 |
|
|
295
|
+
| spheroid | 椭球计算 |
|
|
296
|
+
| showLabel | 显示标注 |
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
## 分析展示
|
|
301
|
+
|
|
302
|
+
### Heatmap
|
|
303
|
+
|
|
304
|
+
```typescript
|
|
305
|
+
data: { title: string; points: { x, y, weight }[] }[]
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
### SwipeLayer
|
|
309
|
+
|
|
310
|
+
| 属性 | 说明 |
|
|
311
|
+
|------|------|
|
|
312
|
+
| dockedVisible | Left / Right / Top / Bottom |
|
|
313
|
+
|
|
314
|
+
### MultiScreen
|
|
315
|
+
|
|
316
|
+
| 属性 | 说明 |
|
|
317
|
+
|------|------|
|
|
318
|
+
| layers, screenNum | 图层与分屏数 |
|
|
319
|
+
| @loaded | 分屏地图就绪 |
|
|
320
|
+
| expose screenMaps | 各屏 OLMap |
|
|
321
|
+
|
|
322
|
+
---
|
|
323
|
+
|
|
324
|
+
## 导入导出
|
|
325
|
+
|
|
326
|
+
### Import
|
|
327
|
+
|
|
328
|
+
挂载时打开文件选择,支持 kml/kmz/zip(shp)。
|
|
329
|
+
|
|
330
|
+
### Export
|
|
331
|
+
|
|
332
|
+
导出选中要素为 shp/kml/kmz,需先 Select 选中。
|
|
333
|
+
|
|
334
|
+
---
|
|
335
|
+
|
|
336
|
+
## 完整示例
|
|
337
|
+
|
|
338
|
+
```vue
|
|
339
|
+
<template>
|
|
340
|
+
<div style="position: relative; height: 100vh">
|
|
341
|
+
<div id="map" style="width:100%;height:100%"></div>
|
|
342
|
+
<HorizontallyTopToolbar v-if="map" :map="map" :tools="tools" />
|
|
343
|
+
<MousePositon v-if="map" :map="map" />
|
|
344
|
+
<ScaleLine v-if="map" :map="map" />
|
|
345
|
+
<LayerSwitcher v-if="map" :map="map" :layers="baseLayers" />
|
|
346
|
+
</div>
|
|
347
|
+
</template>
|
|
348
|
+
|
|
349
|
+
<script setup lang="ts">
|
|
350
|
+
import { onMounted, ref } from 'vue';
|
|
351
|
+
import OLMap from 'ym-gis-2d/mapView/Map';
|
|
352
|
+
import {
|
|
353
|
+
HorizontallyTopToolbar,
|
|
354
|
+
MousePositon,
|
|
355
|
+
ScaleLine,
|
|
356
|
+
LayerSwitcher,
|
|
357
|
+
} from 'ym-giswidget-2d';
|
|
358
|
+
import type { IMapService } from 'ym-gis-2d/entity';
|
|
359
|
+
import type ITool from 'ym-giswidget-2d/entity/iToool';
|
|
360
|
+
|
|
361
|
+
const map = ref<OLMap>();
|
|
362
|
+
const baseLayers: IMapService[] = [/* ... */];
|
|
363
|
+
|
|
364
|
+
const tools: ITool[] = [{
|
|
365
|
+
id: 'draw-tool',
|
|
366
|
+
title: '工具',
|
|
367
|
+
icon: './img/tool/draw-tool.png',
|
|
368
|
+
isOnce: false,
|
|
369
|
+
isRepels: false,
|
|
370
|
+
children: [
|
|
371
|
+
{ id: 'drawTool', title: '勾绘', classPath: '../draw/index.ts', icon: './img/add.png', isOnce: false, isRepels: true },
|
|
372
|
+
{ id: 'selectTool', title: '选择', classPath: '../select/index.ts', icon: './img/select.png', isOnce: false, isRepels: true },
|
|
373
|
+
],
|
|
374
|
+
}];
|
|
375
|
+
|
|
376
|
+
onMounted(() => {
|
|
377
|
+
map.value = new OLMap('map', { projection: 4490, zoom: 10 });
|
|
378
|
+
baseLayers.forEach(l => map.value!.addMapLayer(l));
|
|
379
|
+
});
|
|
380
|
+
</script>
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
---
|
|
384
|
+
|
|
385
|
+
## 注意事项
|
|
386
|
+
|
|
387
|
+
1. 依赖 `ym-gis-2d`,图层配置见 [ym-gis-2d API](./node_modules/ym-gis-2d/API.md) 或 npm 文档。
|
|
388
|
+
2. 编辑工具需设置 `map.currentEditLayer`(含 `geometryType`)。
|
|
389
|
+
3. `MousePositon` 为历史拼写,导入时使用该名称。
|
|
390
|
+
4. SHP 导入导出需配置 `Config.GisServiceUrl`。
|
|
391
|
+
5. 与 Element Plus 配合使用时需全局注册 Element Plus。
|
|
392
|
+
|
|
393
|
+
## 相关包
|
|
394
|
+
|
|
395
|
+
| 包 | 说明 |
|
|
396
|
+
|----|------|
|
|
397
|
+
| ym-gis-2d | GIS 核心(地图、图层、几何) |
|
|
398
|
+
| element-plus | UI 基础组件 |
|
|
399
|
+
| ol | OpenLayers |
|
package/README.md
CHANGED
|
@@ -1,33 +1,51 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ym-giswidget-2d
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
基于 Vue 3 + Element Plus + [ym-gis-2d](https://www.npmjs.com/package/ym-gis-2d) 的 WebGIS UI 组件库。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 安装
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install ym-giswidget-2d ym-gis-2d element-plus
|
|
9
|
+
```
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## 快速开始
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
```vue
|
|
14
|
+
<template>
|
|
15
|
+
<MapView style="height: 500px" @init="onInit" />
|
|
16
|
+
<Draw v-if="map" :map="map" geometry-type="polygon" />
|
|
17
|
+
</template>
|
|
12
18
|
|
|
13
|
-
|
|
19
|
+
<script setup lang="ts">
|
|
20
|
+
import { ref } from 'vue';
|
|
21
|
+
import { MapView, Draw } from 'ym-giswidget-2d';
|
|
14
22
|
|
|
15
|
-
|
|
23
|
+
const map = ref();
|
|
24
|
+
function onInit(m) { map.value = m; }
|
|
25
|
+
</script>
|
|
26
|
+
```
|
|
16
27
|
|
|
17
|
-
##
|
|
28
|
+
## 文档
|
|
18
29
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
30
|
+
| 文档 | 说明 |
|
|
31
|
+
|------|------|
|
|
32
|
+
| [API.md](./API.md) | 完整 API 参考(npm 离线文档) |
|
|
33
|
+
| [giswidget-2d-docs/zh-CN/component](../../giswidget-2d-docs/zh-CN/component/) | 在线文档源文件(含交互 Demo) |
|
|
22
34
|
|
|
23
|
-
|
|
35
|
+
本地预览文档站点:
|
|
24
36
|
|
|
25
|
-
```
|
|
26
|
-
pnpm dev
|
|
37
|
+
```bash
|
|
38
|
+
pnpm --filter giswidget-2d-docs dev
|
|
27
39
|
```
|
|
28
40
|
|
|
29
|
-
|
|
41
|
+
## 主要组件
|
|
30
42
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
MapView · HorizontallyTopToolbar · TocCard · LayerSwitcher · Legend · Draw · Select · Identify · Modify · 量测 · 导入导出 · 卷帘 · 多屏 · 热力图
|
|
44
|
+
|
|
45
|
+
## 依赖
|
|
46
|
+
|
|
47
|
+
`vue` 3 · `element-plus` · `ym-gis-2d` · `ol`
|
|
48
|
+
|
|
49
|
+
## License
|
|
50
|
+
|
|
51
|
+
ISC
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import { PoiDataSource } from '../../http/poi';
|
|
1
2
|
import { default as OLMap } from 'ym-gis-2d/mapView/Map';
|
|
2
3
|
type __VLS_Props = {
|
|
3
4
|
map: OLMap;
|
|
4
5
|
zoom?: number;
|
|
5
6
|
locationImg?: string;
|
|
7
|
+
source?: PoiDataSource;
|
|
6
8
|
};
|
|
7
9
|
declare const _default: import('vue').DefineComponent<__VLS_Props, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
10
|
+
source: PoiDataSource;
|
|
8
11
|
zoom: number;
|
|
9
12
|
locationImg: string;
|
|
10
13
|
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _sfc_main from "./AddressSearch.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import _export_sfc from "../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const _AddressSearch = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-
|
|
4
|
+
const _AddressSearch = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-84185d52"]]);
|
|
5
5
|
export {
|
|
6
6
|
_AddressSearch as default
|
|
7
7
|
};
|
|
@@ -7,7 +7,7 @@ import "element-plus/es/components/button/style/css";
|
|
|
7
7
|
import "element-plus/es/components/icon/style/css";
|
|
8
8
|
import { defineComponent, ref, reactive, computed, onMounted, onUnmounted, createElementBlock, openBlock, createElementVNode, createVNode, toDisplayString, withCtx, withKeys, withModifiers, unref, Transition, withDirectives, TransitionGroup, Fragment, renderList, normalizeClass, vShow, nextTick } from "vue";
|
|
9
9
|
import { Search, Switch } from "@element-plus/icons-vue";
|
|
10
|
-
import {
|
|
10
|
+
import { getPOIData } from "../../http/poi.js";
|
|
11
11
|
import { ElMessage } from "element-plus";
|
|
12
12
|
import { gcj02towgs84 } from "ym-gis-2d/utils/gcj02Util";
|
|
13
13
|
import FeatureManager from "ym-gis-2d/feature/FeatureManager";
|
|
@@ -25,7 +25,8 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
25
25
|
props: {
|
|
26
26
|
map: {},
|
|
27
27
|
zoom: { default: 16 },
|
|
28
|
-
locationImg: { default: dw }
|
|
28
|
+
locationImg: { default: dw },
|
|
29
|
+
source: { default: "tdt" }
|
|
29
30
|
},
|
|
30
31
|
setup(__props) {
|
|
31
32
|
const props = __props;
|
|
@@ -70,36 +71,71 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
70
71
|
const result = ref([]);
|
|
71
72
|
const currentName = ref("");
|
|
72
73
|
const option = computed(() => options[activeIndex.value]);
|
|
74
|
+
function normalizeTdtResult(resultData) {
|
|
75
|
+
const resultType = resultData.resultType - 0;
|
|
76
|
+
if (resultType === 1) {
|
|
77
|
+
return resultData.pois || [];
|
|
78
|
+
}
|
|
79
|
+
if (resultType === 2 && resultData.statistics && resultData.statistics.priorityCitys) {
|
|
80
|
+
return resultData.statistics.priorityCitys.map((element) => ({
|
|
81
|
+
name: element.adminName,
|
|
82
|
+
lonlat: element.lonlat,
|
|
83
|
+
address: element.adminName
|
|
84
|
+
}));
|
|
85
|
+
}
|
|
86
|
+
if (resultType === 3) {
|
|
87
|
+
return resultData.area ? [resultData.area] : [];
|
|
88
|
+
}
|
|
89
|
+
if (resultType === 4) {
|
|
90
|
+
return resultData.suggests || [];
|
|
91
|
+
}
|
|
92
|
+
if (resultType === 5) {
|
|
93
|
+
return resultData.lineData || [];
|
|
94
|
+
}
|
|
95
|
+
return [];
|
|
96
|
+
}
|
|
97
|
+
function normalizeAmapResult(resultData) {
|
|
98
|
+
const pois = (resultData == null ? void 0 : resultData.pois) || [];
|
|
99
|
+
return pois.map((item) => ({
|
|
100
|
+
name: item.name,
|
|
101
|
+
lonlat: item.location,
|
|
102
|
+
address: item.address || item.pname || ""
|
|
103
|
+
}));
|
|
104
|
+
}
|
|
105
|
+
function normalizeBaiduResult(resultData) {
|
|
106
|
+
const results = (resultData == null ? void 0 : resultData.result) || [];
|
|
107
|
+
return results.filter((item) => {
|
|
108
|
+
var _a, _b;
|
|
109
|
+
return ((_a = item == null ? void 0 : item.location) == null ? void 0 : _a.lng) !== void 0 && ((_b = item == null ? void 0 : item.location) == null ? void 0 : _b.lat) !== void 0;
|
|
110
|
+
}).map((item) => ({
|
|
111
|
+
name: item.name,
|
|
112
|
+
lonlat: `${item.location.lng},${item.location.lat}`,
|
|
113
|
+
address: item.city ? `${item.city}${item.district ? ` ${item.district}` : ""}` : item.district || ""
|
|
114
|
+
}));
|
|
115
|
+
}
|
|
116
|
+
function normalizeSearchResult(source, resultData) {
|
|
117
|
+
switch (source) {
|
|
118
|
+
case "amap":
|
|
119
|
+
return normalizeAmapResult(resultData);
|
|
120
|
+
case "baidu":
|
|
121
|
+
return normalizeBaiduResult(resultData);
|
|
122
|
+
case "tdt":
|
|
123
|
+
default:
|
|
124
|
+
return normalizeTdtResult(resultData);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
73
127
|
function locationSearch() {
|
|
74
128
|
result.value = [];
|
|
75
129
|
SearchForm.value.validate((validate) => {
|
|
76
130
|
if (validate) {
|
|
77
131
|
status.loading = true;
|
|
78
|
-
|
|
132
|
+
getPOIData(form.value, { source: props.source }).then((res) => {
|
|
79
133
|
if (!res.data) {
|
|
80
134
|
return;
|
|
81
135
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
result.value = resultData.pois;
|
|
86
|
-
} else if (resultType === 2 && resultData.statistics && resultData.statistics.priorityCitys) {
|
|
87
|
-
let priorityCitys = [];
|
|
88
|
-
for (let index = 0; index < resultData.statistics.priorityCitys.length; index++) {
|
|
89
|
-
const element = resultData.statistics.priorityCitys[index];
|
|
90
|
-
priorityCitys.push({
|
|
91
|
-
name: element.adminName,
|
|
92
|
-
lonlat: element.lonlat
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
result.value = priorityCitys;
|
|
96
|
-
} else if (resultType === 3) {
|
|
97
|
-
result.value = [resultData.area];
|
|
98
|
-
} else if (resultType === 4) {
|
|
99
|
-
result.value = resultData.suggests;
|
|
100
|
-
} else if (resultType === 5) {
|
|
101
|
-
result.value = resultData.lineData;
|
|
102
|
-
}
|
|
136
|
+
result.value = normalizeSearchResult(props.source, res.data);
|
|
137
|
+
}).catch((err) => {
|
|
138
|
+
ElMessage.error((err == null ? void 0 : err.message) || "检索失败");
|
|
103
139
|
}).finally(() => {
|
|
104
140
|
status.loading = false;
|
|
105
141
|
});
|
|
@@ -135,12 +171,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
135
171
|
if (item.lonlat) {
|
|
136
172
|
const delimiter = item.lonlat.includes(",") ? "," : ",";
|
|
137
173
|
const [longitude, latitude] = item.lonlat.split(delimiter);
|
|
174
|
+
const shouldTransform = props.source === "amap";
|
|
138
175
|
showResPOI({
|
|
139
176
|
location: {
|
|
140
177
|
lng: longitude,
|
|
141
178
|
lat: latitude
|
|
142
179
|
}
|
|
143
|
-
},
|
|
180
|
+
}, shouldTransform);
|
|
144
181
|
} else {
|
|
145
182
|
ElMessage.warning("未查找到坐标");
|
|
146
183
|
}
|