af-mobile-client-vue3 1.1.3 → 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.
- package/package.json +1 -1
- package/src/assets/img/component/location.png +0 -0
- package/src/assets/img/component/mapLayers.png +0 -0
- package/src/assets/img/component/positioning.png +0 -0
- package/src/components/data/XOlMap/README.md +178 -169
- package/src/components/data/XOlMap/XLocationPicker/index.vue +191 -0
- package/src/components/data/XOlMap/index.vue +818 -433
- package/src/components/data/XOlMap/types.ts +138 -0
- package/src/router/routes.ts +7 -1
- package/src/services/api/common.ts +2 -2
- package/src/views/component/XOlMapView/XLocationPicker/index.vue +120 -0
- package/src/views/component/XOlMapView/index.vue +420 -0
- package/src/views/component/index.vue +5 -1
- package/src/components/data/XOlMap/demo.vue +0 -330
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/** 地址选择结果接口 */
|
|
2
|
+
export interface LocationResult {
|
|
3
|
+
/** 经度 */
|
|
4
|
+
longitude: number
|
|
5
|
+
/** 纬度 */
|
|
6
|
+
latitude: number
|
|
7
|
+
/** 地址描述 */
|
|
8
|
+
address: string
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** 手机状态接口 */
|
|
12
|
+
export interface PhoneLocationStatus {
|
|
13
|
+
/** 纬度 */
|
|
14
|
+
f_latitude: number
|
|
15
|
+
/** 经度 */
|
|
16
|
+
f_longitude: number
|
|
17
|
+
/** 其他可能的状态属性 */
|
|
18
|
+
[key: string]: unknown
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** 初始化参数接口 */
|
|
22
|
+
export interface InitParams {
|
|
23
|
+
/** 地图中心点坐标 [经度, 纬度] */
|
|
24
|
+
center?: [number, number]
|
|
25
|
+
/** 地图缩放级别 */
|
|
26
|
+
zoom?: number
|
|
27
|
+
/** 最大缩放级别 */
|
|
28
|
+
maxZoom?: number
|
|
29
|
+
/** 最小缩放级别 */
|
|
30
|
+
minZoom?: number
|
|
31
|
+
/** 天地图密钥 */
|
|
32
|
+
tianDiTuKey?: string
|
|
33
|
+
/** 是否开启地址选择模式 */
|
|
34
|
+
enableLocationPicker?: boolean
|
|
35
|
+
/** 高德地图 API key */
|
|
36
|
+
amapKey?: string
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** 点位数据接口 */
|
|
40
|
+
export interface PointData {
|
|
41
|
+
/** 经度 */
|
|
42
|
+
longitude: number
|
|
43
|
+
/** 纬度 */
|
|
44
|
+
latitude: number
|
|
45
|
+
/** 点标题 */
|
|
46
|
+
title?: string
|
|
47
|
+
/** 自定义数据 */
|
|
48
|
+
extData?: Record<string, any>
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** 点位数据提供者函数类型 */
|
|
52
|
+
export type PointDataProvider = () => PointData[] | Promise<PointData[]>
|
|
53
|
+
|
|
54
|
+
/** 点位图层配置接口 */
|
|
55
|
+
export interface PointLayerConfig {
|
|
56
|
+
/** 图层ID */
|
|
57
|
+
id: number
|
|
58
|
+
/** 图层名称 */
|
|
59
|
+
value: string
|
|
60
|
+
/** 是否显示 */
|
|
61
|
+
show: boolean
|
|
62
|
+
/** 是否在控制面板显示 */
|
|
63
|
+
showInControl?: boolean
|
|
64
|
+
/** 图标URL */
|
|
65
|
+
icon: string
|
|
66
|
+
/** 图标锚点 */
|
|
67
|
+
iconAnchor?: [number, number]
|
|
68
|
+
/** 点击事件处理函数 */
|
|
69
|
+
onClick?: (point: PointData, event: any) => void
|
|
70
|
+
/** 点位数据提供者 */
|
|
71
|
+
dataProvider?: () => PointData[] | Promise<PointData[]>
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** WebGL渲染配置接口 */
|
|
75
|
+
export interface WebGLPointOptions extends PointLayerConfig {
|
|
76
|
+
/** 图标大小 */
|
|
77
|
+
iconSize?: [number, number]
|
|
78
|
+
/** 是否开启聚合 */
|
|
79
|
+
enableCluster?: boolean
|
|
80
|
+
/** 聚合距离,单位像素 */
|
|
81
|
+
clusterDistance?: number
|
|
82
|
+
/** 聚合样式配置 */
|
|
83
|
+
clusterStyle?: {
|
|
84
|
+
/** 填充颜色 */
|
|
85
|
+
fillColor?: string
|
|
86
|
+
/** 边框颜色 */
|
|
87
|
+
strokeColor?: string
|
|
88
|
+
/** 文字颜色 */
|
|
89
|
+
textColor?: string
|
|
90
|
+
}
|
|
91
|
+
/** 渲染性能配置 */
|
|
92
|
+
performance?: {
|
|
93
|
+
/** 是否开启分块加载 */
|
|
94
|
+
enableChunk?: boolean
|
|
95
|
+
/** 每块数据量 */
|
|
96
|
+
chunkSize?: number
|
|
97
|
+
/** 是否开启节流 */
|
|
98
|
+
enableThrottle?: boolean
|
|
99
|
+
/** 节流时间间隔(ms) */
|
|
100
|
+
throttleWait?: number
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** WMS 图层配置接口 */
|
|
105
|
+
export interface WMSLayerConfig {
|
|
106
|
+
/** 图层名称 */
|
|
107
|
+
layerName: string
|
|
108
|
+
/** 图层显示名称 */
|
|
109
|
+
value: string
|
|
110
|
+
/** 是否显示 */
|
|
111
|
+
show: boolean
|
|
112
|
+
/** 手机端是否显示 */
|
|
113
|
+
phoneShow: boolean
|
|
114
|
+
/** 图层 ID */
|
|
115
|
+
id: number
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** WMS 服务配置接口 */
|
|
119
|
+
export interface WMSConfig {
|
|
120
|
+
/** 工作空间 */
|
|
121
|
+
workspace: string
|
|
122
|
+
/** 坐标系 */
|
|
123
|
+
srs: string
|
|
124
|
+
/** 图片格式 */
|
|
125
|
+
format: string
|
|
126
|
+
/** WMS 版本 */
|
|
127
|
+
version: string
|
|
128
|
+
/** WMS 服务地址 */
|
|
129
|
+
url: string
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** WMS 完整配置接口 */
|
|
133
|
+
export interface WMSOptions {
|
|
134
|
+
/** WMS 图层列表 */
|
|
135
|
+
layers: WMSLayerConfig[]
|
|
136
|
+
/** WMS 服务配置 */
|
|
137
|
+
wms: WMSConfig
|
|
138
|
+
}
|
package/src/router/routes.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { RouteRecordRaw } from 'vue-router'
|
|
2
2
|
import XForm from '@af-mobile-client-vue3/components/data/XForm/index.vue'
|
|
3
|
-
import XOlMapView from '@af-mobile-client-vue3/components/data/XOlMap/demo.vue'
|
|
4
3
|
import XReport from '@af-mobile-client-vue3/components/data/XReportGrid/XReport.vue'
|
|
5
4
|
import GridView from '@af-mobile-client-vue3/layout/GridView/index.vue'
|
|
6
5
|
import PageLayout from '@af-mobile-client-vue3/layout/PageLayout.vue'
|
|
@@ -13,6 +12,8 @@ import XCellListView from '@af-mobile-client-vue3/views/component/XCellListView/
|
|
|
13
12
|
import XFormAppraiseView from '@af-mobile-client-vue3/views/component/XFormAppraiseView/index.vue'
|
|
14
13
|
import XFormGroupView from '@af-mobile-client-vue3/views/component/XFormGroupView/index.vue'
|
|
15
14
|
import XFormView from '@af-mobile-client-vue3/views/component/XFormView/index.vue'
|
|
15
|
+
import XOlMapView from '@af-mobile-client-vue3/views/component/XOlMapView/index.vue'
|
|
16
|
+
import XLocationPicker from '@af-mobile-client-vue3/views/component/XOlMapView/XLocationPicker/index.vue'
|
|
16
17
|
import XReportFormIframeView from '@af-mobile-client-vue3/views/component/XReportFormIframeView/index.vue'
|
|
17
18
|
import XReportFormView from '@af-mobile-client-vue3/views/component/XReportFormView/index.vue'
|
|
18
19
|
import XReportGridView from '@af-mobile-client-vue3/views/component/XReportGridView/index.vue'
|
|
@@ -82,6 +83,11 @@ const routes: Array<RouteRecordRaw> = [
|
|
|
82
83
|
name: 'XOlMapView',
|
|
83
84
|
component: XOlMapView,
|
|
84
85
|
},
|
|
86
|
+
{
|
|
87
|
+
path: '/Component/XOlMapView/XLocationPicker',
|
|
88
|
+
name: 'XLocationPicker',
|
|
89
|
+
component: XLocationPicker,
|
|
90
|
+
},
|
|
85
91
|
// {
|
|
86
92
|
// path: '/Components/XForm',
|
|
87
93
|
// name: 'XForm',
|
|
@@ -50,8 +50,8 @@ export function getConfigByNameWithoutIndexedDB(configName: string, serviceName
|
|
|
50
50
|
/**
|
|
51
51
|
* 通用执行业务逻辑
|
|
52
52
|
*/
|
|
53
|
-
export function runLogic(logicName: string, parameter: object, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME) {
|
|
54
|
-
return post(`/${serviceName}/logic/${logicName}`, parameter)
|
|
53
|
+
export function runLogic<T>(logicName: string, parameter: object, serviceName = import.meta.env.VITE_APP_SYSTEM_NAME): Promise<T> {
|
|
54
|
+
return post<T>(`/${serviceName}/logic/${logicName}`, parameter)
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
/**
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { LocationResult } from '@af-mobile-client-vue3/components/data/XOlMap/types'
|
|
3
|
+
import LocationPicker from '@af-mobile-client-vue3/components/data/XOlMap/XLocationPicker/index.vue'
|
|
4
|
+
import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
|
|
5
|
+
import { showNotify } from 'vant'
|
|
6
|
+
import { ref } from 'vue'
|
|
7
|
+
|
|
8
|
+
const selectedLocation = ref<LocationResult>()
|
|
9
|
+
|
|
10
|
+
// 处理位置选择
|
|
11
|
+
function handleLocationConfirm(location: LocationResult) {
|
|
12
|
+
console.log('选择的位置:', location)
|
|
13
|
+
selectedLocation.value = location
|
|
14
|
+
showNotify({ type: 'success', message: '位置已选择' })
|
|
15
|
+
}
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<template>
|
|
19
|
+
<NormalDataLayout id="XLocationPicker" title="XOlMap地址选择器">
|
|
20
|
+
<template #layout_content>
|
|
21
|
+
<div class="location-picker-demo">
|
|
22
|
+
<!-- 页面标题 -->
|
|
23
|
+
<div class="page-header">
|
|
24
|
+
<div class="title">
|
|
25
|
+
位置选择
|
|
26
|
+
</div>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<!-- 选择结果展示 -->
|
|
30
|
+
<div v-if="selectedLocation" class="location-result">
|
|
31
|
+
<div class="label">
|
|
32
|
+
已选位置:
|
|
33
|
+
</div>
|
|
34
|
+
<div class="value">
|
|
35
|
+
{{ selectedLocation.address }}
|
|
36
|
+
</div>
|
|
37
|
+
<div class="coordinates">
|
|
38
|
+
经度: {{ selectedLocation.longitude.toFixed(6) }},
|
|
39
|
+
纬度: {{ selectedLocation.latitude.toFixed(6) }}
|
|
40
|
+
</div>
|
|
41
|
+
</div>
|
|
42
|
+
|
|
43
|
+
<!-- 地图组件 -->
|
|
44
|
+
<div class="map-container">
|
|
45
|
+
<LocationPicker
|
|
46
|
+
v-model="selectedLocation"
|
|
47
|
+
tian-di-tu-key="c16876b28898637c0a1a68b3fa410504"
|
|
48
|
+
amap-key="5ebabc4536d4b42e0dd1e20175cca8ab"
|
|
49
|
+
:default-center="[108.948024, 34.263161]"
|
|
50
|
+
:default-zoom="12"
|
|
51
|
+
@confirm="handleLocationConfirm"
|
|
52
|
+
/>
|
|
53
|
+
</div>
|
|
54
|
+
</div>
|
|
55
|
+
</template>
|
|
56
|
+
</NormalDataLayout>
|
|
57
|
+
</template>
|
|
58
|
+
|
|
59
|
+
<style scoped lang="less">
|
|
60
|
+
.location-picker-demo {
|
|
61
|
+
width: 100%;
|
|
62
|
+
height: 100%;
|
|
63
|
+
position: relative;
|
|
64
|
+
display: flex;
|
|
65
|
+
flex-direction: column;
|
|
66
|
+
background-color: #f7f8fa;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.page-header {
|
|
70
|
+
height: 44px;
|
|
71
|
+
display: flex;
|
|
72
|
+
align-items: center;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
background: white;
|
|
75
|
+
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
|
|
76
|
+
position: relative;
|
|
77
|
+
z-index: 1;
|
|
78
|
+
|
|
79
|
+
.title {
|
|
80
|
+
font-size: 16px;
|
|
81
|
+
color: #333;
|
|
82
|
+
font-weight: 500;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
.location-result {
|
|
87
|
+
background: white;
|
|
88
|
+
padding: 12px 16px;
|
|
89
|
+
margin: 10px;
|
|
90
|
+
border-radius: 8px;
|
|
91
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
|
|
92
|
+
|
|
93
|
+
.label {
|
|
94
|
+
font-size: 14px;
|
|
95
|
+
color: #666;
|
|
96
|
+
margin-bottom: 4px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.value {
|
|
100
|
+
font-size: 16px;
|
|
101
|
+
color: #333;
|
|
102
|
+
margin-bottom: 8px;
|
|
103
|
+
word-break: break-all;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.coordinates {
|
|
107
|
+
font-size: 12px;
|
|
108
|
+
color: #999;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.map-container {
|
|
113
|
+
flex: 1;
|
|
114
|
+
position: relative;
|
|
115
|
+
margin: 0 10px 10px 10px;
|
|
116
|
+
border-radius: 8px;
|
|
117
|
+
overflow: hidden;
|
|
118
|
+
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
|
119
|
+
}
|
|
120
|
+
</style>
|
|
@@ -0,0 +1,420 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import NormalDataLayout from '@af-mobile-client-vue3/components/layout/NormalDataLayout/index.vue'
|
|
3
|
+
import { showNotify } from 'vant'
|
|
4
|
+
import { onMounted, ref } from 'vue'
|
|
5
|
+
import XOlMap from '../../../components/data/XOlMap/index.vue'
|
|
6
|
+
import 'vant/lib/index.css'
|
|
7
|
+
|
|
8
|
+
const mapRef = ref()
|
|
9
|
+
|
|
10
|
+
// WMS 配置
|
|
11
|
+
const wmsConfig = {
|
|
12
|
+
layers: [
|
|
13
|
+
{
|
|
14
|
+
phoneShow: false,
|
|
15
|
+
show: false,
|
|
16
|
+
id: 1,
|
|
17
|
+
layerName: 'gis:lp',
|
|
18
|
+
value: '低压管线',
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
phoneShow: true,
|
|
22
|
+
show: true,
|
|
23
|
+
id: 2,
|
|
24
|
+
layerName: 'gis:mp',
|
|
25
|
+
value: '中压管线',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
phoneShow: false,
|
|
29
|
+
show: false,
|
|
30
|
+
id: 3,
|
|
31
|
+
layerName: 'gis:surface_valve',
|
|
32
|
+
value: '地面阀门',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
phoneShow: false,
|
|
36
|
+
show: false,
|
|
37
|
+
id: 4,
|
|
38
|
+
layerName: 'gis:valve_chamber',
|
|
39
|
+
value: '阀门井',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
phoneShow: false,
|
|
43
|
+
show: false,
|
|
44
|
+
id: 6,
|
|
45
|
+
layerName: 'gis:hp',
|
|
46
|
+
value: '高压管线',
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
phoneShow: false,
|
|
50
|
+
show: false,
|
|
51
|
+
id: 5,
|
|
52
|
+
layerName: 'gis:pressure_regulating_box',
|
|
53
|
+
value: '调压箱',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
wms: {
|
|
57
|
+
workspace: 'gis',
|
|
58
|
+
srs: 'EPSG:3857',
|
|
59
|
+
format: 'image/png',
|
|
60
|
+
version: '1.1.0',
|
|
61
|
+
url: '/linepatrol/geoserver/gis/wms',
|
|
62
|
+
},
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// 初始化地图
|
|
66
|
+
onMounted(() => {
|
|
67
|
+
mapRef.value.init({
|
|
68
|
+
center: [108.948024, 34.263161], // 西安坐标
|
|
69
|
+
zoom: 12,
|
|
70
|
+
maxZoom: 18,
|
|
71
|
+
minZoom: 4,
|
|
72
|
+
tianDiTuKey: 'c16876b28898637c0a1a68b3fa410504',
|
|
73
|
+
})
|
|
74
|
+
mapRef.value.addWMSLayers(wmsConfig)
|
|
75
|
+
})
|
|
76
|
+
|
|
77
|
+
// 地图控制函数
|
|
78
|
+
const handleSetCenter = () => mapRef.value.setCenter([116.404, 39.915]) // 切换到北京
|
|
79
|
+
const handleSetZoom = () => mapRef.value.setZoom(14) // 设置缩放级别为14
|
|
80
|
+
const handleGetZoom = () => showNotify({ type: 'primary', message: `当前缩放级别:${mapRef.value.getZoom()}` })
|
|
81
|
+
const handleSetCenterAndZoom = () => mapRef.value.setCenterAndZoom([120.153576, 30.287459], 15) // 切换到杭州
|
|
82
|
+
|
|
83
|
+
// 点位数据
|
|
84
|
+
const poiPoints = [
|
|
85
|
+
{
|
|
86
|
+
longitude: 108.988024,
|
|
87
|
+
latitude: 34.283161,
|
|
88
|
+
title: '大雁塔',
|
|
89
|
+
extData: { type: 'poi' },
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
longitude: 108.948024,
|
|
93
|
+
latitude: 34.263161,
|
|
94
|
+
title: '钟楼',
|
|
95
|
+
extData: { type: 'poi' },
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
longitude: 108.968024,
|
|
99
|
+
latitude: 34.273161,
|
|
100
|
+
title: '小寨',
|
|
101
|
+
extData: { type: 'poi' },
|
|
102
|
+
},
|
|
103
|
+
]
|
|
104
|
+
|
|
105
|
+
const schoolPoints = [
|
|
106
|
+
{
|
|
107
|
+
longitude: 108.968024,
|
|
108
|
+
latitude: 34.273161,
|
|
109
|
+
title: '西安电子科技大学',
|
|
110
|
+
extData: {
|
|
111
|
+
type: 'school',
|
|
112
|
+
level: '985',
|
|
113
|
+
studentCount: 25000,
|
|
114
|
+
departments: ['通信学院', '计算机学院', '电子工程学院'],
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
]
|
|
118
|
+
|
|
119
|
+
const hospitalPoints = [
|
|
120
|
+
{
|
|
121
|
+
longitude: 108.948024,
|
|
122
|
+
latitude: 34.263161,
|
|
123
|
+
title: '西安市第一医院',
|
|
124
|
+
extData: {
|
|
125
|
+
type: 'hospital',
|
|
126
|
+
level: '三甲',
|
|
127
|
+
departments: ['急诊科', '内科', '外科'],
|
|
128
|
+
contact: '029-12345678',
|
|
129
|
+
address: '西安市雁塔区',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
longitude: 108.978024,
|
|
134
|
+
latitude: 34.278161,
|
|
135
|
+
title: '西安市中心医院',
|
|
136
|
+
extData: {
|
|
137
|
+
type: 'hospital',
|
|
138
|
+
level: '三甲',
|
|
139
|
+
departments: ['急诊科', '内科', '外科'],
|
|
140
|
+
contact: '029-87654321',
|
|
141
|
+
address: '西安市新城区',
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
]
|
|
145
|
+
|
|
146
|
+
// 点位处理函数
|
|
147
|
+
function handlePointClick(point: any) {
|
|
148
|
+
showNotify({
|
|
149
|
+
type: 'primary',
|
|
150
|
+
message: `点击了: ${point.title}\n类型: ${point.extData.type}`,
|
|
151
|
+
})
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// 添加点位示例
|
|
155
|
+
function handleAddPoints() {
|
|
156
|
+
mapRef.value.addPointLayer({
|
|
157
|
+
id: 1,
|
|
158
|
+
value: '学校啊啊啊',
|
|
159
|
+
show: true,
|
|
160
|
+
showInControl: false, // 不添加图层控制按钮
|
|
161
|
+
icon: 'https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-red.png',
|
|
162
|
+
iconAnchor: [0.5, 1],
|
|
163
|
+
onClick: handlePointClick,
|
|
164
|
+
dataProvider: async () => {
|
|
165
|
+
// 模拟从API获取学校数据
|
|
166
|
+
return new Promise((resolve) => {
|
|
167
|
+
setTimeout(() => {
|
|
168
|
+
resolve([
|
|
169
|
+
{
|
|
170
|
+
longitude: 108.968024,
|
|
171
|
+
latitude: 34.273161,
|
|
172
|
+
title: '普通点位',
|
|
173
|
+
extData: {
|
|
174
|
+
type: 'school',
|
|
175
|
+
level: '985',
|
|
176
|
+
studentCount: 25000,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
])
|
|
180
|
+
}, 1000)
|
|
181
|
+
})
|
|
182
|
+
},
|
|
183
|
+
})
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// 添加分类点位示例
|
|
187
|
+
function handleAddPointLayer() {
|
|
188
|
+
// 添加学校点位图层
|
|
189
|
+
mapRef.value.addPointLayer({
|
|
190
|
+
id: 1,
|
|
191
|
+
value: '学校',
|
|
192
|
+
show: true,
|
|
193
|
+
icon: 'https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
|
|
194
|
+
iconAnchor: [0.5, 1],
|
|
195
|
+
onClick: handlePointClick,
|
|
196
|
+
dataProvider: async () => {
|
|
197
|
+
// 模拟从API获取学校数据
|
|
198
|
+
return new Promise((resolve) => {
|
|
199
|
+
setTimeout(() => {
|
|
200
|
+
resolve([
|
|
201
|
+
{
|
|
202
|
+
longitude: 108.958024,
|
|
203
|
+
latitude: 34.283161,
|
|
204
|
+
title: '西安交通大学',
|
|
205
|
+
extData: {
|
|
206
|
+
type: 'school',
|
|
207
|
+
level: '985',
|
|
208
|
+
studentCount: 30000,
|
|
209
|
+
departments: ['机械学院', '电气学院', '管理学院'],
|
|
210
|
+
},
|
|
211
|
+
},
|
|
212
|
+
])
|
|
213
|
+
}, 1000)
|
|
214
|
+
})
|
|
215
|
+
},
|
|
216
|
+
})
|
|
217
|
+
|
|
218
|
+
// 添加医院点位图层
|
|
219
|
+
mapRef.value.addPointLayer({
|
|
220
|
+
id: 2,
|
|
221
|
+
value: '医院',
|
|
222
|
+
show: true,
|
|
223
|
+
icon: 'https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png',
|
|
224
|
+
iconAnchor: [0.5, 1],
|
|
225
|
+
onClick: handlePointClick,
|
|
226
|
+
dataProvider: async () => {
|
|
227
|
+
// 模拟从API获取医院数据
|
|
228
|
+
return new Promise((resolve) => {
|
|
229
|
+
setTimeout(() => {
|
|
230
|
+
resolve([
|
|
231
|
+
{
|
|
232
|
+
longitude: 108.978024,
|
|
233
|
+
latitude: 34.278161,
|
|
234
|
+
title: '西安市中心医院',
|
|
235
|
+
extData: {
|
|
236
|
+
type: 'hospital',
|
|
237
|
+
level: '三甲',
|
|
238
|
+
departments: ['急诊科', '内科', '外科'],
|
|
239
|
+
contact: '029-87654321',
|
|
240
|
+
address: '西安市新城区',
|
|
241
|
+
},
|
|
242
|
+
},
|
|
243
|
+
])
|
|
244
|
+
}, 1000)
|
|
245
|
+
})
|
|
246
|
+
},
|
|
247
|
+
})
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// 添加海量点示例
|
|
251
|
+
function handleAddMassPoints() {
|
|
252
|
+
mapRef.value.addWebGLPoints({
|
|
253
|
+
id: 3,
|
|
254
|
+
value: '海量点',
|
|
255
|
+
show: true,
|
|
256
|
+
icon: 'https://a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-red.png',
|
|
257
|
+
iconSize: [6, 6],
|
|
258
|
+
onClick: handlePointClick,
|
|
259
|
+
dataProvider: () => {
|
|
260
|
+
// 生成10000个随机点
|
|
261
|
+
return Array.from({ length: 10000 }, (_, index) => ({
|
|
262
|
+
longitude: 108.948024 + (Math.random() - 0.5) * 0.1,
|
|
263
|
+
latitude: 34.263161 + (Math.random() - 0.5) * 0.1,
|
|
264
|
+
title: `点位${index + 1}`,
|
|
265
|
+
extData: { type: 'mass' },
|
|
266
|
+
}))
|
|
267
|
+
},
|
|
268
|
+
})
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// 导航模式相关
|
|
272
|
+
const isNavigationMode = ref(false)
|
|
273
|
+
|
|
274
|
+
// 开启导航模式
|
|
275
|
+
function startNavigation() {
|
|
276
|
+
isNavigationMode.value = true
|
|
277
|
+
mapRef.value?.startNavigation()
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
// 停止导航模式
|
|
281
|
+
function stopNavigation() {
|
|
282
|
+
isNavigationMode.value = false
|
|
283
|
+
mapRef.value?.stopNavigation()
|
|
284
|
+
}
|
|
285
|
+
</script>
|
|
286
|
+
|
|
287
|
+
<template>
|
|
288
|
+
<NormalDataLayout id="XOlMapView" title="XOlMap地图组件">
|
|
289
|
+
<template #layout_content>
|
|
290
|
+
<div class="demo-container">
|
|
291
|
+
<div class="map-container">
|
|
292
|
+
<XOlMap ref="mapRef" />
|
|
293
|
+
</div>
|
|
294
|
+
<div class="control-panel">
|
|
295
|
+
<div class="control-group">
|
|
296
|
+
<div class="group-title">
|
|
297
|
+
地图控制
|
|
298
|
+
</div>
|
|
299
|
+
<van-button type="primary" size="small" @click="handleSetCenter">
|
|
300
|
+
切换到北京
|
|
301
|
+
</van-button>
|
|
302
|
+
<van-button type="primary" size="small" @click="handleSetZoom">
|
|
303
|
+
设置缩放级别14
|
|
304
|
+
</van-button>
|
|
305
|
+
<van-button type="primary" size="small" @click="handleGetZoom">
|
|
306
|
+
获取当前缩放级别
|
|
307
|
+
</van-button>
|
|
308
|
+
<van-button type="primary" size="small" @click="handleSetCenterAndZoom">
|
|
309
|
+
切换到杭州(级别15)
|
|
310
|
+
</van-button>
|
|
311
|
+
</div>
|
|
312
|
+
|
|
313
|
+
<div class="control-group">
|
|
314
|
+
<div class="group-title">
|
|
315
|
+
点位示例
|
|
316
|
+
</div>
|
|
317
|
+
<van-button type="success" size="small" @click="handleAddPoints">
|
|
318
|
+
添加普通点位
|
|
319
|
+
</van-button>
|
|
320
|
+
<van-button type="success" size="small" @click="handleAddPointLayer">
|
|
321
|
+
添加分类点位
|
|
322
|
+
</van-button>
|
|
323
|
+
<van-button type="warning" size="small" @click="handleAddMassPoints">
|
|
324
|
+
添加海量点(1万)
|
|
325
|
+
</van-button>
|
|
326
|
+
</div>
|
|
327
|
+
|
|
328
|
+
<div class="control-group">
|
|
329
|
+
<div class="group-title">
|
|
330
|
+
导航模式测试
|
|
331
|
+
</div>
|
|
332
|
+
<van-button
|
|
333
|
+
:type="isNavigationMode ? 'danger' : 'primary'"
|
|
334
|
+
size="small"
|
|
335
|
+
@click="isNavigationMode ? stopNavigation() : startNavigation()"
|
|
336
|
+
>
|
|
337
|
+
{{ isNavigationMode ? '停止导航' : '开始导航' }}
|
|
338
|
+
</van-button>
|
|
339
|
+
</div>
|
|
340
|
+
</div>
|
|
341
|
+
</div>
|
|
342
|
+
</template>
|
|
343
|
+
</NormalDataLayout>
|
|
344
|
+
</template>
|
|
345
|
+
|
|
346
|
+
<style scoped lang="less">
|
|
347
|
+
.demo-container {
|
|
348
|
+
width: 100%;
|
|
349
|
+
height: 100%;
|
|
350
|
+
position: relative;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
.map-container {
|
|
354
|
+
width: 100%;
|
|
355
|
+
height: 100%;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
.control-panel {
|
|
359
|
+
position: absolute;
|
|
360
|
+
left: 10px;
|
|
361
|
+
top: 10px;
|
|
362
|
+
z-index: 1000;
|
|
363
|
+
background: white;
|
|
364
|
+
padding: 10px;
|
|
365
|
+
border-radius: 4px;
|
|
366
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
|
367
|
+
display: flex;
|
|
368
|
+
flex-direction: column;
|
|
369
|
+
gap: 16px;
|
|
370
|
+
|
|
371
|
+
.control-group {
|
|
372
|
+
display: flex;
|
|
373
|
+
flex-direction: column;
|
|
374
|
+
gap: 8px;
|
|
375
|
+
|
|
376
|
+
.group-title {
|
|
377
|
+
font-size: 14px;
|
|
378
|
+
font-weight: 500;
|
|
379
|
+
color: #333;
|
|
380
|
+
padding-left: 4px;
|
|
381
|
+
border-left: 3px solid #1989fa;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
:deep(.van-button) {
|
|
385
|
+
margin-bottom: 8px;
|
|
386
|
+
|
|
387
|
+
&:last-child {
|
|
388
|
+
margin-bottom: 0;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
:deep(.van-button) {
|
|
394
|
+
width: 140px;
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// 移动端适配
|
|
399
|
+
@media screen and (max-width: 768px) {
|
|
400
|
+
.control-panel {
|
|
401
|
+
left: 8px;
|
|
402
|
+
top: 8px;
|
|
403
|
+
padding: 8px;
|
|
404
|
+
gap: 12px;
|
|
405
|
+
|
|
406
|
+
.control-group {
|
|
407
|
+
gap: 6px;
|
|
408
|
+
|
|
409
|
+
.group-title {
|
|
410
|
+
font-size: 12px;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
:deep(.van-button) {
|
|
415
|
+
width: 120px;
|
|
416
|
+
font-size: 12px;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
</style>
|