@sword916/vae-map-plus 1.0.0

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.
Files changed (86) hide show
  1. package/README.md +3 -0
  2. package/build/index.mjs +113 -0
  3. package/examples/App.vue +18 -0
  4. package/examples/index.js +13 -0
  5. package/examples/router/index.js +35 -0
  6. package/examples/views/amap.vue +29 -0
  7. package/examples/views/amarker.vue +58 -0
  8. package/examples/views/buffer.vue +66 -0
  9. package/examples/views/cluster.vue +74 -0
  10. package/examples/views/cover.vue +85 -0
  11. package/examples/views/draw-line.vue +49 -0
  12. package/examples/views/draw.vue +54 -0
  13. package/examples/views/echarts.vue +142 -0
  14. package/examples/views/emarker.vue +39 -0
  15. package/examples/views/image.vue +182 -0
  16. package/examples/views/index.vue +61 -0
  17. package/examples/views/lrmap.vue +108 -0
  18. package/examples/views/map.vue +82 -0
  19. package/examples/views/measure.vue +86 -0
  20. package/examples/views/parts/popup.vue +39 -0
  21. package/examples/views/parts/tooltip.vue +39 -0
  22. package/examples/views/push-area.vue +52 -0
  23. package/examples/views/push-line.vue +84 -0
  24. package/examples/views/trace.vue +49 -0
  25. package/index.html +13 -0
  26. package/jsconfig.json +17 -0
  27. package/package.json +47 -0
  28. package/public/favicon.ico +0 -0
  29. package/public/images/game.png +0 -0
  30. package/public/images/grid.png +0 -0
  31. package/public/images/marker.png +0 -0
  32. package/public/index.html +30 -0
  33. package/src/components/resize-listener/component.jsx +30 -0
  34. package/src/components/resize-listener/index.js +3 -0
  35. package/src/composables/useAutoMessage.js +41 -0
  36. package/src/composables/useContextMenu.js +99 -0
  37. package/src/composables/useMapMeasure.js +191 -0
  38. package/src/composables/useResizeObserver.js +81 -0
  39. package/src/mixins/message.js +1 -0
  40. package/src/packages/index.js +16 -0
  41. package/src/packages/vae-amap/index.js +8 -0
  42. package/src/packages/vae-amap/style.less +9 -0
  43. package/src/packages/vae-amap/vae-amap.jsx +98 -0
  44. package/src/packages/vae-cloudmap/ctrl-context-menu/index.vue +74 -0
  45. package/src/packages/vae-cloudmap/ctrl-draw/index.vue +499 -0
  46. package/src/packages/vae-cloudmap/ctrl-draw-line/index.vue +161 -0
  47. package/src/packages/vae-cloudmap/index.js +57 -0
  48. package/src/packages/vae-cloudmap/scripts/L.MarkerCluster/index.js +2690 -0
  49. package/src/packages/vae-cloudmap/scripts/L.MarkerCluster/style.css +14 -0
  50. package/src/packages/vae-cloudmap/scripts/L.Vae.CRS/index.js +212 -0
  51. package/src/packages/vae-cloudmap/scripts/L.Vae.Client/index.js +780 -0
  52. package/src/packages/vae-cloudmap/scripts/Mixin.ContextMenu/index.js +101 -0
  53. package/src/packages/vae-cloudmap/style.less +163 -0
  54. package/src/packages/vae-cloudmap/vae-cloudmap.jsx +272 -0
  55. package/src/packages/vae-map/ctrl-context-menu/index.vue +74 -0
  56. package/src/packages/vae-map/ctrl-draw/index.vue +498 -0
  57. package/src/packages/vae-map/ctrl-draw-line/index.vue +128 -0
  58. package/src/packages/vae-map/index.js +59 -0
  59. package/src/packages/vae-map/scripts/L.MarkerCluster/index.js +2690 -0
  60. package/src/packages/vae-map/scripts/L.MarkerCluster/style.css +14 -0
  61. package/src/packages/vae-map/scripts/L.Vae.CRS/index.js +114 -0
  62. package/src/packages/vae-map/scripts/L.Vae.Client/index.js +548 -0
  63. package/src/packages/vae-map/scripts/Mixin.ContextMenu/index.js +1 -0
  64. package/src/packages/vae-map/style.less +161 -0
  65. package/src/packages/vae-map/vae-lrmap.jsx +237 -0
  66. package/src/packages/vae-map/vae-map.jsx +135 -0
  67. package/src/plugins/L.AnimatedMarker/index.js +158 -0
  68. package/src/plugins/L.EchartsLayer/index.js +339 -0
  69. package/src/plugins/L.ElasticMarker/index.js +162 -0
  70. package/src/plugins/L.FootageCalculator.Area/index.js +263 -0
  71. package/src/plugins/L.FootageCalculator.Line/index.js +273 -0
  72. package/src/plugins/L.GeoUtil/buffer.js +67 -0
  73. package/src/plugins/L.GeoUtil/index.js +284 -0
  74. package/src/plugins/L.Glyphicon/index.js +91 -0
  75. package/src/plugins/L.Glyphicon/style.less +37 -0
  76. package/src/plugins/L.MarkerClusterX/index.js +93 -0
  77. package/src/plugins/L.MarkerClusterX/style.less +162 -0
  78. package/src/plugins/L.SafeDivOverlay/index.js +55 -0
  79. package/src/plugins/L.TileLayer.ChinaProvider/index.js +108 -0
  80. package/src/plugins/L.VuePopup/index.js +67 -0
  81. package/src/plugins/L.VueTooltip/index.js +63 -0
  82. package/src/plugins/Mixin.Map.Measure/index.js +248 -0
  83. package/src/plugins/globals/index.js +7 -0
  84. package/src/utils/index.js +36 -0
  85. package/src/utils/resize-event.js +45 -0
  86. package/vite.config.mjs +25 -0
@@ -0,0 +1,142 @@
1
+ <template>
2
+ <div class="map-container">
3
+ <vae-map :options="options" :base-layers="baseLayers" @init-map="initMap" />
4
+ <span class="actions">
5
+ <el-button size="small" @click="switchLineLayers">迁徙图</el-button>
6
+ <el-button size="small" @click="switchHeatLayers">热力图</el-button>
7
+ </span>
8
+ </div>
9
+ </template>
10
+
11
+ <script setup>
12
+ import { ref } from 'vue'
13
+
14
+ const latLngs = [
15
+ [40.2539, 116.4551],
16
+ [31.2891, 121.4648],
17
+ [23.2196, 113.5107]
18
+ ]
19
+
20
+ const echartsLatLngs = latLngs.map((item) => [item[1], item[0]])
21
+
22
+ const map = ref(null)
23
+ const options = {
24
+ zoom: 5
25
+ }
26
+ const baseLayers = ['Geoq.Normal.PurplishBlue']
27
+ const lineLayers = L.layerGroup()
28
+ const heatLayers = L.layerGroup()
29
+
30
+ const addLineLayer = () => {
31
+ const planePath = 'path://M1705.06,1318.313v-89.254l-319.9-221.799l0.073-208.063c0.521-84.662-26.629-121.796-63.961-121.491c-37.332-0.305-64.482,36.829-63.961,121.491l0.073,208.063l-319.9,221.799v89.254l330.343-157.288l12.238,241.308l-134.449,92.931l0.531,42.034l175.125-42.917l175.125,42.917l0.531-42.034l-134.449-92.931l12.238-241.308L1705.06,1318.313z'
32
+ const series = [
33
+ {
34
+ coordinateSystem: 'leaflet',
35
+ type: 'lines',
36
+ zlevel: 1,
37
+ polyline: true,
38
+ effect: {
39
+ show: true,
40
+ period: 5,
41
+ trailLength: 0.8,
42
+ color: '#ffc107',
43
+ symbolSize: 8
44
+ },
45
+ lineStyle: {
46
+ color: '#0dcaf0',
47
+ opacity: 0.1,
48
+ width: 1
49
+ },
50
+ data: [{ coords: echartsLatLngs }]
51
+ },
52
+ {
53
+ coordinateSystem: 'leaflet',
54
+ type: 'lines',
55
+ zlevel: 3,
56
+ symbol: ['none', 'arrow'],
57
+ symbolSize: 10,
58
+ effect: {
59
+ show: true,
60
+ period: 5,
61
+ trailLength: 0,
62
+ symbol: planePath,
63
+ symbolSize: 25
64
+ },
65
+ lineStyle: {
66
+ width: 1,
67
+ curveness: 0.2
68
+ },
69
+ data: [{ coords: [echartsLatLngs[0], echartsLatLngs[2]] }]
70
+ },
71
+ {
72
+ coordinateSystem: 'leaflet',
73
+ type: 'effectScatter',
74
+ zlevel: 2,
75
+ symbolSize: 10,
76
+ rippleEffect: {
77
+ brushType: 'stroke'
78
+ },
79
+ data: echartsLatLngs
80
+ }
81
+ ]
82
+ L.echartsLayer({ series }).addTo(lineLayers)
83
+ }
84
+
85
+ const addHeatLayer = () => {
86
+ const chartOptions = {
87
+ visualMap: {
88
+ show: false,
89
+ seriesIndex: 0,
90
+ inRange: {
91
+ color: ['#313695', '#4575b4', '#74add1', '#abd9e9', '#e0f3f8', '#ffffbf', '#fee090', '#fdae61', '#f46d43', '#d73027', '#a50026']
92
+ }
93
+ },
94
+ series: [{
95
+ coordinateSystem: 'leaflet',
96
+ type: 'heatmap',
97
+ data: echartsLatLngs.map((item, index) => item.concat([(index + 1) * 50])),
98
+ pointSize: 15,
99
+ blurSize: 5
100
+ }]
101
+ }
102
+ L.echartsLayer(chartOptions).addTo(heatLayers)
103
+ }
104
+
105
+ const initMap = (value) => {
106
+ map.value = value
107
+ lineLayers.addTo(map.value)
108
+ heatLayers.addTo(map.value)
109
+ addLineLayer()
110
+ addHeatLayer()
111
+ }
112
+
113
+ const switchLineLayers = () => {
114
+ if (map.value.hasLayer(lineLayers)) {
115
+ map.value.removeLayer(lineLayers)
116
+ } else {
117
+ map.value.addLayer(lineLayers)
118
+ }
119
+ }
120
+
121
+ const switchHeatLayers = () => {
122
+ if (map.value.hasLayer(heatLayers)) {
123
+ map.value.removeLayer(heatLayers)
124
+ } else {
125
+ map.value.addLayer(heatLayers)
126
+ }
127
+ }
128
+ </script>
129
+
130
+ <style lang="less" scoped>
131
+ .map-container {
132
+ height: 100%;
133
+ position: relative;
134
+
135
+ .actions {
136
+ position: absolute;
137
+ right: 10px;
138
+ top: 10px;
139
+ z-index: 1000;
140
+ }
141
+ }
142
+ </style>
@@ -0,0 +1,39 @@
1
+ <template>
2
+ <div class="map-container">
3
+ <vae-map :base-layers="baseLayers" @init-map="initMap" />
4
+ </div>
5
+ </template>
6
+
7
+ <script setup>
8
+ const baseLayers = ['GaoDe.Normal.Map']
9
+
10
+ const initMap = (map) => {
11
+ map.on('click', (event) => console.log(event))
12
+
13
+ L.elasticMarker(map.getCenter()).setIcon(L.glyphicon({
14
+ icon: 'fas fa-cat',
15
+ size: 40,
16
+ color: 'deeppink'
17
+ })).addTo(map)
18
+
19
+ L.elasticMarker({ lat: 34.30028857253559, lng: 117.39745616912843 }, {
20
+ elasticOpacity: false
21
+ }).addTo(map)
22
+
23
+ L.elasticMarker({ lat: 34.2974745093329, lng: 117.38054215908052 }).setIcon(L.icon({
24
+ iconUrl: '/images/marker.png',
25
+ iconSize: [22, 32],
26
+ iconAnchor: [11, 32]
27
+ })).bindTooltip('elasticMarker', {
28
+ permanent: true,
29
+ direction: 'right'
30
+ }).addTo(map)
31
+ }
32
+ </script>
33
+
34
+ <style lang="less" scoped>
35
+ .map-container {
36
+ height: 100%;
37
+ position: relative;
38
+ }
39
+ </style>
@@ -0,0 +1,182 @@
1
+ <template>
2
+ <div class="outer">
3
+ <div class="inner">
4
+ <vae-map :options="options" @init-map="initMap" />
5
+ </div>
6
+ <div class="actions">
7
+ <div style="margin-top: 15px">
8
+ <el-button size="small" type="success" @click="addGridOverlay">添加栅格图片</el-button>
9
+ <el-button size="small" type="success" @click="addGameOverlay">添加游戏地图</el-button>
10
+ </div>
11
+ <el-input v-model="latlngValue" style="margin-top: 25px" />
12
+ <div style="margin-top: 15px; text-align: right">
13
+ <el-button size="small" @click="addDargonMarker">添加标注</el-button>
14
+ <el-button size="small" type="danger" @click="clearDargonMarker">清理标注</el-button>
15
+ </div>
16
+ <div style="margin-top: 30px; text-align: right">
17
+ <el-button size="small" @click="addFightMarker">添加动态标注</el-button>
18
+ <el-button size="small" type="danger" @click="clearFightMarker">清理动态标注</el-button>
19
+ </div>
20
+ <div style="margin-top: 30px; text-align: right">
21
+ <el-button size="small" type="primary" @click="resetMap">RESET</el-button>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ </template>
26
+
27
+ <script setup>
28
+ import { ref } from 'vue'
29
+
30
+ const fighterIcon = L.glyphicon({
31
+ icon: 'fas fa-walking',
32
+ size: 32,
33
+ borderWidth: 2,
34
+ background: 'FireBrick',
35
+ color: 'white',
36
+ boxShadow: false
37
+ })
38
+
39
+ const dargonIcon = L.glyphicon({
40
+ icon: 'fas fa-dragon',
41
+ size: 40,
42
+ borderWidth: 2,
43
+ background: 'Indigo',
44
+ color: 'white'
45
+ })
46
+
47
+ const fighterLatLngs = [
48
+ { lat: 290, lng: 261 }, { lat: 318, lng: 250 }, { lat: 330, lng: 233 }, { lat: 356, lng: 217 }, { lat: 380, lng: 218 }, { lat: 407, lng: 216 }, { lat: 425, lng: 219 }, { lat: 429, lng: 174 }, { lat: 428, lng: 120 }, { lat: 427, lng: 67 }, { lat: 428, lng: 28 }, { lat: 398, lng: 35 }, { lat: 368, lng: 54 }, { lat: 327, lng: 68 }, { lat: 258, lng: 70 }, { lat: 233, lng: 62 }, { lat: 192, lng: 56 }, { lat: 157, lng: 54 }, { lat: 131, lng: 53 }, { lat: 102, lng: 54 },
49
+ { lat: 105, lng: 79 }, { lat: 122, lng: 113 }, { lat: 132, lng: 131 }, { lat: 149, lng: 147 }, { lat: 171, lng: 164 }, { lat: 192, lng: 174 }, { lat: 213, lng: 182 }, { lat: 224, lng: 194 }, { lat: 228, lng: 210 }, { lat: 224, lng: 233 }, { lat: 207, lng: 253 }, { lat: 186, lng: 255 }, { lat: 171, lng: 259 }, { lat: 178, lng: 280 }, { lat: 190, lng: 298 }, { lat: 194, lng: 318 }, { lat: 189, lng: 339 }, { lat: 183, lng: 364 }, { lat: 179, lng: 398 }, { lat: 188, lng: 417 },
50
+ { lat: 182, lng: 449 }, { lat: 171, lng: 479 }, { lat: 172, lng: 503 }, { lat: 175, lng: 532 }, { lat: 182, lng: 553 }, { lat: 184, lng: 589 }, { lat: 199, lng: 610 }, { lat: 234, lng: 618 }, { lat: 260, lng: 620 }, { lat: 274, lng: 614 }, { lat: 278, lng: 584 }, { lat: 278, lng: 553 }, { lat: 278, lng: 531 }, { lat: 282, lng: 501 }, { lat: 287, lng: 491 }, { lat: 296, lng: 491 }, { lat: 313, lng: 496 }, { lat: 333, lng: 505 }, { lat: 348, lng: 508 }, { lat: 368, lng: 505 },
51
+ { lat: 379, lng: 488 }, { lat: 391, lng: 476 }, { lat: 402, lng: 458 }, { lat: 408, lng: 448 }, { lat: 415, lng: 435 }, { lat: 421, lng: 418 }, { lat: 424, lng: 404 }, { lat: 432, lng: 380 }, { lat: 448, lng: 380 }, { lat: 448, lng: 431 }, { lat: 447, lng: 459 }, { lat: 446, lng: 491 }, { lat: 447, lng: 524 }, { lat: 449, lng: 569 }, { lat: 433, lng: 591 }, { lat: 419, lng: 592 }, { lat: 397, lng: 607 }, { lat: 376, lng: 608 }, { lat: 369, lng: 623 }, { lat: 372, lng: 658 }
52
+ ]
53
+
54
+ const mapBounds = [[0, 0], [500, 800]]
55
+
56
+ const map = ref(null)
57
+ const gridOverlay = ref(null)
58
+ const gameOverlay = ref(null)
59
+ const latlngValue = ref('')
60
+ const dragonMarker = ref(null)
61
+ const dragonLayers = L.layerGroup()
62
+ const fightLayers = L.layerGroup()
63
+ const options = {
64
+ zoom: 0,
65
+ maxZoom: 1,
66
+ minZoom: -1,
67
+ crs: L.CRS.Simple
68
+ }
69
+
70
+ const initMap = (value) => {
71
+ map.value = value
72
+ dragonLayers.addTo(map.value)
73
+ fightLayers.addTo(map.value)
74
+ map.value.fitBounds(mapBounds)
75
+ }
76
+
77
+ const resetMap = () => {
78
+ map.value.setView([250, 400], 0)
79
+ }
80
+
81
+ const addGridOverlay = () => {
82
+ if (gridOverlay.value) {
83
+ map.value.removeLayer(gridOverlay.value)
84
+ }
85
+ gridOverlay.value = L.imageOverlay('/images/grid.png', mapBounds).addTo(map.value)
86
+ }
87
+
88
+ const addGameOverlay = () => {
89
+ if (gameOverlay.value) {
90
+ map.value.removeLayer(gameOverlay.value)
91
+ }
92
+ gameOverlay.value = L.imageOverlay('/images/game.png', mapBounds).bringToBack().addTo(map.value)
93
+ }
94
+
95
+ const addDargonMarker = () => {
96
+ const latlng = latlngValue.value.split(',')
97
+ if (latlng.length === 2) {
98
+ dragonMarker.value = L.marker(latlng).setIcon(dargonIcon).bindTooltip(latlngValue.value, {
99
+ permanent: true,
100
+ direction: 'right',
101
+ offset: [15, 0]
102
+ }).addTo(dragonLayers)
103
+ }
104
+ }
105
+
106
+ const clearDargonMarker = () => {
107
+ dragonMarker.value = null
108
+ dragonLayers.clearLayers()
109
+ }
110
+
111
+ const showDialog = () => {
112
+ const list = [
113
+ '我来了',
114
+ '是的,我看到了',
115
+ '我走了三天三夜',
116
+ `你走过了${fighterLatLngs.length}个地方`,
117
+ '今天的勇者找恶龙就分享到这里',
118
+ '感谢大家观看'
119
+ ]
120
+
121
+ const showText = (index = 0) => {
122
+ const currentLatLng = index % 2 === 0 ? _.last(fighterLatLngs) : dragonMarker.value.getLatLng()
123
+ if (!list[index]) {
124
+ return
125
+ }
126
+ L.popup({ offset: [0, -10] }).setContent(
127
+ `<div style='font-size:13px;'>${list[index]}</div>`
128
+ ).setLatLng(currentLatLng).openOn(map.value)
129
+ _.delay(() => {
130
+ showText(index + 1)
131
+ }, 2000)
132
+ }
133
+
134
+ showText(0)
135
+ }
136
+
137
+ const addFightMarker = () => {
138
+ const amarker = L.animatedMarker({
139
+ latLngs: fighterLatLngs,
140
+ duration: 1000 * 15
141
+ }).setIcon(fighterIcon).addTo(fightLayers)
142
+
143
+ amarker.on('stopmove', () => {
144
+ if (dragonMarker.value) {
145
+ showDialog()
146
+ }
147
+ })
148
+
149
+ _.delay(() => {
150
+ amarker.startMove()
151
+ }, 500)
152
+ }
153
+
154
+ const clearFightMarker = () => {
155
+ fightLayers.clearLayers()
156
+ }
157
+ </script>
158
+
159
+ <style lang="less" scoped>
160
+ .outer {
161
+ height: 100%;
162
+ width: 100%;
163
+ display: flex;
164
+ align-items: center;
165
+ justify-content: center;
166
+ background: #010101;
167
+
168
+ .inner {
169
+ height: 550px;
170
+ width: 850px;
171
+ background: #880000;
172
+ }
173
+
174
+ .actions {
175
+ height: 780px;
176
+ width: 400px;
177
+ margin-left: 150px;
178
+ background: #eee;
179
+ padding: 10px 20px;
180
+ }
181
+ }
182
+ </style>
@@ -0,0 +1,61 @@
1
+ <template>
2
+ <div class="examples">
3
+ <el-button @click="navi = true" type="primary" class="toggle">菜单</el-button>
4
+ <el-drawer v-model="navi" :show-close="false">
5
+ <el-row :gutter="10">
6
+ <el-col v-for="item in navis" :key="item" :span="8">
7
+ <el-button size="small" style="width: 100%" @click="routeTo(item)">{{ item }}</el-button>
8
+ </el-col>
9
+ </el-row>
10
+ </el-drawer>
11
+ <router-view />
12
+ </div>
13
+ </template>
14
+
15
+ <script setup>
16
+ import { ref } from 'vue'
17
+ import { useRouter } from 'vue-router'
18
+
19
+ const router = useRouter()
20
+ const navi = ref(false)
21
+ const navis = ['amap', 'map', 'lrmap', 'push-area', 'push-line', 'echarts', 'trace', 'cluster', 'cover', 'draw', 'draw-line', 'measure', 'amarker', 'emarker', 'buffer', 'image']
22
+
23
+ const routeTo = (path) => {
24
+ router.push(`/views/${path}`).finally(() => {
25
+ navi.value = false
26
+ })
27
+ }
28
+ </script>
29
+
30
+ <style lang="less">
31
+ .examples {
32
+ position: relative;
33
+ height: 100%;
34
+
35
+ .el-drawer__header {
36
+ padding: 0;
37
+ margin: 0;
38
+ }
39
+
40
+ .el-drawer__body {
41
+ padding: 10px;
42
+
43
+ .el-col {
44
+ text-align: center;
45
+ margin-top: 20px;
46
+ }
47
+
48
+ .el-button {
49
+ width: 88px;
50
+ }
51
+ }
52
+
53
+ .toggle {
54
+ position: absolute;
55
+ top: calc(50% - 20px);
56
+ right: 0;
57
+ z-index: 1500;
58
+ box-shadow: -2px 2px 5px rgba(0, 0, 0, 0.5);
59
+ }
60
+ }
61
+ </style>
@@ -0,0 +1,108 @@
1
+ <template>
2
+ <div class="container">
3
+ <div class="actions">
4
+ <el-button type="success" size="small" @click="setLayerSet">切换图组</el-button>
5
+ <el-button type="primary" size="small" @click="getImage">缩略图</el-button>
6
+ <div style="background: #ccc">
7
+ <el-image :src="imageSrc" />
8
+ </div>
9
+ </div>
10
+ <div class="layers">
11
+ <el-tree ref="treeRef" :data="treeLayers" node-key="id" :default-checked-keys="visibleKeys" show-checkbox />
12
+ <div>
13
+ <el-button type="primary" size="small" @click="confirmLayers">确认</el-button>
14
+ </div>
15
+ </div>
16
+ <vae-lrmap :before-create="beforeCreate" :options="options" @init-map="initMap" @reload-map="initMap" />
17
+ </div>
18
+ </template>
19
+
20
+ <script setup>
21
+ import { computed, ref } from 'vue'
22
+
23
+ const treeRef = ref(null)
24
+ const map = ref(null)
25
+ const treeLayers = ref([])
26
+ const visibleKeys = ref([])
27
+ const imageSrc = ref(null)
28
+
29
+ const options = computed(() => ({
30
+ url: 'http://123.56.162.219:8702/gis-xzk/',
31
+ dsname: 'XZMKGIS',
32
+ rotate: true,
33
+ crs: 'bj54'
34
+ }))
35
+
36
+ const initMap = async (value) => {
37
+ map.value = value
38
+ treeLayers.value = map.value.vae.treeLayers
39
+ visibleKeys.value = map.value.vae.visibleKeys
40
+
41
+ const arr = [
42
+ [32.76422859210167, 116.46418594831812],
43
+ [32.759949154841145, 116.48346373812541],
44
+ [32.757756957291484, 116.4829576836318],
45
+ [32.7620293706736, 116.46364205232726]
46
+ ]
47
+
48
+ L.polygon(arr, { fillColor: 'green', fillOpacity: 0.1 }).addTo(map.value).bindTooltip('测试', {
49
+ permanent: true,
50
+ direction: 'right',
51
+ className: 'nice-tooltip dark',
52
+ offset: [6, 28]
53
+ })
54
+ }
55
+
56
+ const beforeCreate = (context) => new Promise((resolve) => {
57
+ _.delay(() => {
58
+ console.log(context)
59
+ resolve()
60
+ }, 500)
61
+ })
62
+
63
+ const confirmLayers = () => {
64
+ map.value.vae.showLayers(treeRef.value.getCheckedKeys()).then((layers) => {
65
+ console.log(layers)
66
+ })
67
+ }
68
+
69
+ const setLayerSet = async () => {
70
+ const keys = await map.value.vae.showLayerSets('安全监测监控系统图')
71
+ treeRef.value.setCheckedKeys(keys)
72
+ }
73
+
74
+ const getImage = () => {
75
+ map.value.vae.getThumbnail().then((imageData) => {
76
+ imageSrc.value = imageData
77
+ })
78
+ }
79
+ </script>
80
+
81
+ <style lang="less" scoped>
82
+ .container {
83
+ height: 100%;
84
+ position: relative;
85
+
86
+ .actions {
87
+ position: absolute;
88
+ top: 10px;
89
+ left: 10px;
90
+ z-index: 1000;
91
+ }
92
+
93
+ .layers {
94
+ overflow: auto;
95
+ position: absolute;
96
+ top: 10px;
97
+ right: 10px;
98
+ z-index: 1000;
99
+ height: 600px;
100
+ width: 400px;
101
+ background: #f5f7fa;
102
+
103
+ :deep(.el-tree) {
104
+ background: #f5f7fa;
105
+ }
106
+ }
107
+ }
108
+ </style>
@@ -0,0 +1,82 @@
1
+ <template>
2
+ <vae-map :base-layers="baseLayers" :options="options" :context-menu="menus" @init-map="initMap" />
3
+ </template>
4
+
5
+ <script setup>
6
+ import { ref } from 'vue'
7
+ import vpopup from './parts/popup.vue'
8
+ import vtooltip from './parts/tooltip.vue'
9
+
10
+ const map = ref(null)
11
+ const baseLayers = ref([])
12
+ const menus = ref([])
13
+ const options = ref({})
14
+ const latLngs = ref([])
15
+ const points = ref([])
16
+
17
+ const initMap = (value) => {
18
+ const icon = L.glyphicon({
19
+ icon: 'fab fa-alipay',
20
+ effect: {
21
+ type: 'halo'
22
+ }
23
+ })
24
+
25
+ const marker = L.marker(value.getCenter()).setIcon(icon).addTo(value)
26
+ marker.bindPopup(L.vuePopup({ vueInstance: vpopup, props: { name: 'vae' } }))
27
+ marker.bindTooltip(L.vueTooltip({ vueInstance: vtooltip, props: { name: 'vae' } }), {
28
+ permanent: true,
29
+ direction: 'right',
30
+ offset: [10, 0]
31
+ })
32
+
33
+ baseLayers.value = ['GaoDe.Normal.Map']
34
+ _.delay(() => {
35
+ baseLayers.value = ['TianDiTu.Satellite.Map@1a346e3ea95a3227a097cabf11a901b7']
36
+ }, 3000)
37
+
38
+ map.value = value
39
+
40
+ const polygonLatlngs = [
41
+ [37, -109.05],
42
+ [41, -109.03],
43
+ [41, -102.05],
44
+ [37, -102.04]
45
+ ]
46
+
47
+ const polygon = L.polygon(polygonLatlngs, { color: 'red' }).addTo(map.value)
48
+ polygon.bindTooltip(L.vueTooltip({ vueInstance: vtooltip, props: { name: 'vae' } }), {
49
+ permanent: true,
50
+ direction: 'right',
51
+ offset: [10, 0]
52
+ })
53
+ map.value.fitBounds(polygon.getBounds())
54
+
55
+ menus.value = [
56
+ {
57
+ text: 'hello world',
58
+ callback: (event) => {
59
+ L.marker(event.latlng).addTo(map.value)
60
+ if (points.value.length !== 4) {
61
+ latLngs.value.push(event.latlng)
62
+ if (latLngs.value.length === 4) {
63
+ L.polygon(latLngs.value).addTo(map.value)
64
+ }
65
+ }
66
+ }
67
+ },
68
+ {
69
+ text: 'zoom in',
70
+ divided: true
71
+ },
72
+ {
73
+ text: 'zoom out'
74
+ },
75
+ {
76
+ text: 'fly to',
77
+ divided: true,
78
+ disabled: true
79
+ }
80
+ ]
81
+ }
82
+ </script>
@@ -0,0 +1,86 @@
1
+ <template>
2
+ <div class="map-container">
3
+ <vae-lrmap :options="options" @init-map="initMap" />
4
+ <span class="actions">
5
+ <div style="text-align: right">
6
+ <el-button size="small" type="danger" @click="ClearMeasure">清理</el-button>
7
+ <el-button size="small" type="warning" @click="CancelMeasure">取消当前</el-button>
8
+ <el-button size="small" type="primary" @click="StartMeasure('Line')">测距</el-button>
9
+ <el-button size="small" type="primary" @click="StartMeasure('Polygon')">测面积</el-button>
10
+ </div>
11
+ <div style="margin-top: 10px; text-align: right">
12
+ <el-button size="small">绘制状态 # {{ DrawStatus }}</el-button>
13
+ <el-button size="small" type="danger" @click="clearDrawSegement">清理线段</el-button>
14
+ <el-button size="small" type="info" @click="drawSegement">画线段 # 非测距</el-button>
15
+ </div>
16
+ </span>
17
+ </div>
18
+ </template>
19
+
20
+ <script setup>
21
+ import { ref } from 'vue'
22
+ import { useMapMeasure } from '@/composables/useMapMeasure'
23
+
24
+ const { DrawStatus, EnableMeasure, StartMeasure, CancelMeasure, ClearMeasure } = useMapMeasure()
25
+
26
+ const map = ref(null)
27
+ const drawItems = L.layerGroup()
28
+ const options = {
29
+ url: 'http://58.218.64.10:38500/',
30
+ dsname: 'XS_MLGIS',
31
+ crs: 'bj54',
32
+ defaultLayerSets: ['采掘工程平面图>8煤']
33
+ }
34
+
35
+ const initMap = (value) => {
36
+ map.value = value
37
+ EnableMeasure(value)
38
+ }
39
+
40
+ const drawSegement = () => {
41
+ drawItems.addTo(map.value)
42
+
43
+ const onLayerCreate = (event) => {
44
+ event.layer.remove().addTo(drawItems)
45
+ }
46
+ const onDrawStart = (event) => {
47
+ const workingLayer = event.workingLayer
48
+ if (event.shape === 'Line') {
49
+ workingLayer.on('pm:vertexadded', (vertex) => {
50
+ if (workingLayer._latlngs.length === 2) {
51
+ vertex.marker.fire('click')
52
+ }
53
+ })
54
+ }
55
+ }
56
+ const onDrawEnd = () => {
57
+ map.value.off('pm:create', onLayerCreate)
58
+ map.value.off('pm:drawstart', onDrawStart)
59
+ map.value.off('pm:drawend', onDrawEnd)
60
+ }
61
+
62
+ map.value.on('pm:create', onLayerCreate)
63
+ map.value.on('pm:drawstart', onDrawStart)
64
+ map.value.on('pm:drawend', onDrawEnd)
65
+ map.value.pm.enableDraw('Line')
66
+ }
67
+
68
+ const clearDrawSegement = () => {
69
+ map.value.pm.disableDraw('Line')
70
+ drawItems.clearLayers()
71
+ }
72
+ </script>
73
+
74
+ <style lang="less" scoped>
75
+ .map-container {
76
+ height: 100%;
77
+ position: relative;
78
+
79
+ .actions {
80
+ position: absolute;
81
+ right: 10px;
82
+ top: 10px;
83
+ z-index: 1000;
84
+ }
85
+ }
86
+ </style>