@sword916/vae-map-plus 1.0.0 → 1.0.1

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 (185) hide show
  1. package/lib/index.js +5376 -0
  2. package/lib/style.css +1 -0
  3. package/lib/vae-amap/favicon.ico +0 -0
  4. package/lib/vae-amap/images/game.png +0 -0
  5. package/lib/vae-amap/images/grid.png +0 -0
  6. package/lib/vae-amap/images/marker.png +0 -0
  7. package/lib/vae-amap/index.js +209 -0
  8. package/lib/vae-amap/style.css +1 -0
  9. package/lib/vae-cloudmap/favicon.ico +0 -0
  10. package/lib/vae-cloudmap/images/game.png +0 -0
  11. package/lib/vae-cloudmap/images/grid.png +0 -0
  12. package/lib/vae-cloudmap/images/marker.png +0 -0
  13. package/lib/vae-cloudmap/index.html +30 -0
  14. package/lib/vae-cloudmap/index.js +4085 -0
  15. package/lib/vae-cloudmap/style.css +1 -0
  16. package/lib/vae-map/favicon.ico +0 -0
  17. package/lib/vae-map/images/game.png +0 -0
  18. package/lib/vae-map/images/grid.png +0 -0
  19. package/lib/vae-map/images/marker.png +0 -0
  20. package/lib/vae-map/index.html +30 -0
  21. package/lib/vae-map/index.js +4322 -0
  22. package/lib/vae-map/style.css +1 -0
  23. package/package.json +1 -1
  24. package/plugins/L.AnimatedMarker/favicon.ico +0 -0
  25. package/plugins/L.AnimatedMarker/images/game.png +0 -0
  26. package/plugins/L.AnimatedMarker/images/grid.png +0 -0
  27. package/plugins/L.AnimatedMarker/images/marker.png +0 -0
  28. package/plugins/L.AnimatedMarker/index.html +30 -0
  29. package/plugins/L.AnimatedMarker/index.js +83 -0
  30. package/plugins/L.EchartsLayer/favicon.ico +0 -0
  31. package/plugins/L.EchartsLayer/images/game.png +0 -0
  32. package/plugins/L.EchartsLayer/images/grid.png +0 -0
  33. package/plugins/L.EchartsLayer/images/marker.png +0 -0
  34. package/plugins/L.EchartsLayer/index.html +30 -0
  35. package/plugins/L.EchartsLayer/index.js +176 -0
  36. package/plugins/L.FootageCalculator.Area/favicon.ico +0 -0
  37. package/plugins/L.FootageCalculator.Area/images/game.png +0 -0
  38. package/plugins/L.FootageCalculator.Area/images/grid.png +0 -0
  39. package/plugins/L.FootageCalculator.Area/images/marker.png +0 -0
  40. package/plugins/L.FootageCalculator.Area/index.html +30 -0
  41. package/plugins/L.FootageCalculator.Area/index.js +418 -0
  42. package/plugins/L.FootageCalculator.Line/favicon.ico +0 -0
  43. package/plugins/L.FootageCalculator.Line/images/game.png +0 -0
  44. package/plugins/L.FootageCalculator.Line/images/grid.png +0 -0
  45. package/plugins/L.FootageCalculator.Line/images/marker.png +0 -0
  46. package/plugins/L.FootageCalculator.Line/index.html +30 -0
  47. package/plugins/L.FootageCalculator.Line/index.js +416 -0
  48. package/plugins/L.GeoUtil/favicon.ico +0 -0
  49. package/plugins/L.GeoUtil/images/game.png +0 -0
  50. package/plugins/L.GeoUtil/images/grid.png +0 -0
  51. package/plugins/L.GeoUtil/images/marker.png +0 -0
  52. package/plugins/L.GeoUtil/index.html +30 -0
  53. package/plugins/L.GeoUtil/index.js +279 -0
  54. package/plugins/L.Glyphicon/favicon.ico +0 -0
  55. package/plugins/L.Glyphicon/images/game.png +0 -0
  56. package/plugins/L.Glyphicon/images/grid.png +0 -0
  57. package/plugins/L.Glyphicon/images/marker.png +0 -0
  58. package/plugins/L.Glyphicon/index.html +30 -0
  59. package/plugins/L.Glyphicon/index.js +57 -0
  60. package/plugins/L.Glyphicon/style.css +1 -0
  61. package/plugins/L.MarkerClusterX/favicon.ico +0 -0
  62. package/plugins/L.MarkerClusterX/images/game.png +0 -0
  63. package/plugins/L.MarkerClusterX/images/grid.png +0 -0
  64. package/plugins/L.MarkerClusterX/images/marker.png +0 -0
  65. package/plugins/L.MarkerClusterX/index.html +30 -0
  66. package/plugins/L.MarkerClusterX/index.js +33 -0
  67. package/plugins/L.MarkerClusterX/style.css +1 -0
  68. package/plugins/L.SafeDivOverlay/favicon.ico +0 -0
  69. package/plugins/L.SafeDivOverlay/images/game.png +0 -0
  70. package/plugins/L.SafeDivOverlay/images/grid.png +0 -0
  71. package/plugins/L.SafeDivOverlay/images/marker.png +0 -0
  72. package/plugins/L.SafeDivOverlay/index.html +30 -0
  73. package/plugins/L.SafeDivOverlay/index.js +26 -0
  74. package/plugins/L.TileLayer.ChinaProvider/favicon.ico +0 -0
  75. package/plugins/L.TileLayer.ChinaProvider/images/game.png +0 -0
  76. package/plugins/L.TileLayer.ChinaProvider/images/grid.png +0 -0
  77. package/plugins/L.TileLayer.ChinaProvider/images/marker.png +0 -0
  78. package/plugins/L.TileLayer.ChinaProvider/index.html +30 -0
  79. package/plugins/L.TileLayer.ChinaProvider/index.js +91 -0
  80. package/plugins/L.VuePopup/favicon.ico +0 -0
  81. package/plugins/L.VuePopup/images/game.png +0 -0
  82. package/plugins/L.VuePopup/images/grid.png +0 -0
  83. package/plugins/L.VuePopup/images/marker.png +0 -0
  84. package/plugins/L.VuePopup/index.html +30 -0
  85. package/plugins/L.VuePopup/index.js +68 -0
  86. package/plugins/L.VueTooltip/favicon.ico +0 -0
  87. package/plugins/L.VueTooltip/images/game.png +0 -0
  88. package/plugins/L.VueTooltip/images/grid.png +0 -0
  89. package/plugins/L.VueTooltip/images/marker.png +0 -0
  90. package/plugins/L.VueTooltip/index.html +30 -0
  91. package/plugins/L.VueTooltip/index.js +68 -0
  92. package/plugins/Mixin.Map.Measure/favicon.ico +0 -0
  93. package/plugins/Mixin.Map.Measure/images/game.png +0 -0
  94. package/plugins/Mixin.Map.Measure/images/grid.png +0 -0
  95. package/plugins/Mixin.Map.Measure/images/marker.png +0 -0
  96. package/plugins/Mixin.Map.Measure/index.html +30 -0
  97. package/plugins/Mixin.Map.Measure/index.js +84 -0
  98. package/plugins/globals/favicon.ico +0 -0
  99. package/plugins/globals/images/game.png +0 -0
  100. package/plugins/globals/images/grid.png +0 -0
  101. package/plugins/globals/images/marker.png +0 -0
  102. package/plugins/globals/index.html +30 -0
  103. package/plugins/globals/index.js +4 -0
  104. package/build/index.mjs +0 -113
  105. package/examples/App.vue +0 -18
  106. package/examples/index.js +0 -13
  107. package/examples/router/index.js +0 -35
  108. package/examples/views/amap.vue +0 -29
  109. package/examples/views/amarker.vue +0 -58
  110. package/examples/views/buffer.vue +0 -66
  111. package/examples/views/cluster.vue +0 -74
  112. package/examples/views/cover.vue +0 -85
  113. package/examples/views/draw-line.vue +0 -49
  114. package/examples/views/draw.vue +0 -54
  115. package/examples/views/echarts.vue +0 -142
  116. package/examples/views/emarker.vue +0 -39
  117. package/examples/views/image.vue +0 -182
  118. package/examples/views/index.vue +0 -61
  119. package/examples/views/lrmap.vue +0 -108
  120. package/examples/views/map.vue +0 -82
  121. package/examples/views/measure.vue +0 -86
  122. package/examples/views/parts/popup.vue +0 -39
  123. package/examples/views/parts/tooltip.vue +0 -39
  124. package/examples/views/push-area.vue +0 -52
  125. package/examples/views/push-line.vue +0 -84
  126. package/examples/views/trace.vue +0 -49
  127. package/jsconfig.json +0 -17
  128. package/src/components/resize-listener/component.jsx +0 -30
  129. package/src/components/resize-listener/index.js +0 -3
  130. package/src/composables/useAutoMessage.js +0 -41
  131. package/src/composables/useContextMenu.js +0 -99
  132. package/src/composables/useMapMeasure.js +0 -191
  133. package/src/composables/useResizeObserver.js +0 -81
  134. package/src/mixins/message.js +0 -1
  135. package/src/packages/index.js +0 -16
  136. package/src/packages/vae-amap/index.js +0 -8
  137. package/src/packages/vae-amap/style.less +0 -9
  138. package/src/packages/vae-amap/vae-amap.jsx +0 -98
  139. package/src/packages/vae-cloudmap/ctrl-context-menu/index.vue +0 -74
  140. package/src/packages/vae-cloudmap/ctrl-draw/index.vue +0 -499
  141. package/src/packages/vae-cloudmap/ctrl-draw-line/index.vue +0 -161
  142. package/src/packages/vae-cloudmap/index.js +0 -57
  143. package/src/packages/vae-cloudmap/scripts/L.MarkerCluster/index.js +0 -2690
  144. package/src/packages/vae-cloudmap/scripts/L.MarkerCluster/style.css +0 -14
  145. package/src/packages/vae-cloudmap/scripts/L.Vae.CRS/index.js +0 -212
  146. package/src/packages/vae-cloudmap/scripts/L.Vae.Client/index.js +0 -780
  147. package/src/packages/vae-cloudmap/scripts/Mixin.ContextMenu/index.js +0 -101
  148. package/src/packages/vae-cloudmap/style.less +0 -163
  149. package/src/packages/vae-cloudmap/vae-cloudmap.jsx +0 -272
  150. package/src/packages/vae-map/ctrl-context-menu/index.vue +0 -74
  151. package/src/packages/vae-map/ctrl-draw/index.vue +0 -498
  152. package/src/packages/vae-map/ctrl-draw-line/index.vue +0 -128
  153. package/src/packages/vae-map/index.js +0 -59
  154. package/src/packages/vae-map/scripts/L.MarkerCluster/index.js +0 -2690
  155. package/src/packages/vae-map/scripts/L.MarkerCluster/style.css +0 -14
  156. package/src/packages/vae-map/scripts/L.Vae.CRS/index.js +0 -114
  157. package/src/packages/vae-map/scripts/L.Vae.Client/index.js +0 -548
  158. package/src/packages/vae-map/scripts/Mixin.ContextMenu/index.js +0 -1
  159. package/src/packages/vae-map/style.less +0 -161
  160. package/src/packages/vae-map/vae-lrmap.jsx +0 -237
  161. package/src/packages/vae-map/vae-map.jsx +0 -135
  162. package/src/plugins/L.AnimatedMarker/index.js +0 -158
  163. package/src/plugins/L.EchartsLayer/index.js +0 -339
  164. package/src/plugins/L.ElasticMarker/index.js +0 -162
  165. package/src/plugins/L.FootageCalculator.Area/index.js +0 -263
  166. package/src/plugins/L.FootageCalculator.Line/index.js +0 -273
  167. package/src/plugins/L.GeoUtil/buffer.js +0 -67
  168. package/src/plugins/L.GeoUtil/index.js +0 -284
  169. package/src/plugins/L.Glyphicon/index.js +0 -91
  170. package/src/plugins/L.Glyphicon/style.less +0 -37
  171. package/src/plugins/L.MarkerClusterX/index.js +0 -93
  172. package/src/plugins/L.MarkerClusterX/style.less +0 -162
  173. package/src/plugins/L.SafeDivOverlay/index.js +0 -55
  174. package/src/plugins/L.TileLayer.ChinaProvider/index.js +0 -108
  175. package/src/plugins/L.VuePopup/index.js +0 -67
  176. package/src/plugins/L.VueTooltip/index.js +0 -63
  177. package/src/plugins/Mixin.Map.Measure/index.js +0 -248
  178. package/src/plugins/globals/index.js +0 -7
  179. package/src/utils/index.js +0 -36
  180. package/src/utils/resize-event.js +0 -45
  181. /package/{public → lib}/favicon.ico +0 -0
  182. /package/{public → lib}/images/game.png +0 -0
  183. /package/{public → lib}/images/grid.png +0 -0
  184. /package/{public → lib}/images/marker.png +0 -0
  185. /package/{public → lib/vae-amap}/index.html +0 -0
@@ -1,99 +0,0 @@
1
- import { computed, h, nextTick, onBeforeUnmount, ref, unref, watch } from 'vue'
2
- import ContextMenu from '@/packages/vae-map/ctrl-context-menu/index.vue'
3
-
4
- function resolveElement(target) {
5
- return target?.$el ?? target ?? null
6
- }
7
-
8
- export function useContextMenu({ mapRef, mapContainerRef, menusRef }) {
9
- const contextMenuRef = ref(null)
10
- const showContextMenu = ref(false)
11
- const contextMenuEvent = ref(null)
12
- const contextMenuLeft = ref(0)
13
- const contextMenuTop = ref(0)
14
-
15
- const menuList = computed(() => unref(menusRef) ?? [])
16
-
17
- const hideContextMenu = () => {
18
- const map = unref(mapRef)
19
- map?.off('click', hideContextMenu)
20
- showContextMenu.value = false
21
- contextMenuEvent.value = null
22
- }
23
-
24
- const handleCallback = (callback) => {
25
- showContextMenu.value = false
26
- if (callback && _.isFunction(callback)) {
27
- callback(contextMenuEvent.value)
28
- }
29
- }
30
-
31
- const handleRightClick = async (event) => {
32
- showContextMenu.value = true
33
- contextMenuEvent.value = event
34
- await nextTick()
35
-
36
- const menuEl = resolveElement(contextMenuRef.value)
37
- const containerEl = resolveElement(unref(mapContainerRef))
38
- if (!menuEl || !containerEl) {
39
- return
40
- }
41
-
42
- const menuHeight = menuEl.scrollHeight
43
- const menuWidth = menuEl.scrollWidth
44
- const containerHeight = containerEl.scrollHeight
45
- const containerWidth = containerEl.scrollWidth
46
-
47
- contextMenuLeft.value = event.containerPoint.x
48
- contextMenuTop.value = event.containerPoint.y
49
-
50
- if (contextMenuLeft.value + menuWidth > containerWidth && containerWidth > menuWidth) {
51
- contextMenuLeft.value = containerWidth - menuWidth
52
- }
53
-
54
- if (contextMenuTop.value + menuHeight > containerHeight && containerHeight > menuHeight) {
55
- contextMenuTop.value = containerHeight - menuHeight
56
- }
57
-
58
- unref(mapRef)?.on('click', hideContextMenu)
59
- }
60
-
61
- const addContextMenu = () => {
62
- const map = unref(mapRef)
63
- if (!map) {
64
- return
65
- }
66
- map.off('contextmenu', handleRightClick)
67
- if (menuList.value.length > 0) {
68
- map.on('contextmenu', handleRightClick)
69
- }
70
- }
71
-
72
- watch(menuList, addContextMenu, { deep: true })
73
-
74
- onBeforeUnmount(() => {
75
- const map = unref(mapRef)
76
- map?.off('contextmenu', handleRightClick)
77
- map?.off('click', hideContextMenu)
78
- })
79
-
80
- const renderContextMenu = () => {
81
- if (menuList.value.length === 0 || !showContextMenu.value) {
82
- return null
83
- }
84
-
85
- return h(ContextMenu, {
86
- ref: contextMenuRef,
87
- menus: menuList.value,
88
- left: contextMenuLeft.value,
89
- top: contextMenuTop.value,
90
- onCallback: handleCallback
91
- })
92
- }
93
-
94
- return {
95
- addContextMenu,
96
- hideContextMenu,
97
- renderContextMenu
98
- }
99
- }
@@ -1,191 +0,0 @@
1
- import { onBeforeUnmount, ref } from 'vue'
2
-
3
- let map
4
- let drawItems = L.featureGroup()
5
- let drawHelpItems = L.featureGroup()
6
- let currentLatLng
7
- let lineVertexes = []
8
- let lineCurrentDistance
9
- let lineHintMarker
10
- let polygonVertexes = []
11
- let polygonCurrentArea
12
- let polygonHintMarker
13
- let polygonHintpolygon
14
-
15
- const createTextIcon = (value, className) => {
16
- const iconWidth = value.length > 6 ? (value.length - 6) * 5 + 60 : 60
17
- return L.divIcon({
18
- html: `<div>${value}</div>`,
19
- className: `icon--simple-text ${className ?? ''}`.trim(),
20
- iconSize: [iconWidth, 18]
21
- })
22
- }
23
-
24
- const unregisterDrawEvents = () => {
25
- map?.off('pm:create', Events.onLayerCreate)
26
- map?.off('pm:drawstart', Events.onDrawStart)
27
- map?.off('pm:drawend', Events.onDrawEnd)
28
- }
29
-
30
- const handleMouseMoveAtLine = _.throttle((event) => {
31
- currentLatLng = event.latlng
32
- const currentLatLngs = _.concat(lineVertexes, currentLatLng)
33
- lineCurrentDistance = L.GeoUtil.distanceByLatLngs(currentLatLngs, map)
34
-
35
- if (lineVertexes.length > 0) {
36
- const hintMarkerIcon = createTextIcon(L.GeometryUtil.readableDistance(lineCurrentDistance), 'dark')
37
- if (lineHintMarker) {
38
- lineHintMarker.setIcon(hintMarkerIcon).setLatLng(currentLatLng)
39
- } else {
40
- lineHintMarker = L.marker(currentLatLng, { interactive: false }).setIcon(hintMarkerIcon).addTo(drawHelpItems)
41
- }
42
- }
43
- }, 20)
44
-
45
- const handleMouseMoveAtPolygon = _.throttle((event) => {
46
- currentLatLng = event.latlng
47
- const currentLatLngs = _.concat(polygonVertexes, currentLatLng)
48
-
49
- let useLatLng = true
50
- if (map.vae && !map.vae.crs.code) {
51
- useLatLng = false
52
- }
53
-
54
- polygonCurrentArea = useLatLng
55
- ? L.GeoUtil.areaByLatLngs(currentLatLngs)
56
- : L.GeoUtil.areaByPoints(currentLatLngs.map((value) => ({ x: value.lat, y: value.lng })))
57
-
58
- if (polygonVertexes.length > 1) {
59
- const hintMarkerIcon = createTextIcon(L.GeoUtil.readableArea(polygonCurrentArea), 'dark')
60
- if (polygonHintMarker) {
61
- polygonHintMarker.setIcon(hintMarkerIcon).setLatLng(currentLatLng)
62
- } else {
63
- polygonHintMarker = L.marker(currentLatLng, { interactive: false }).setIcon(hintMarkerIcon).addTo(drawHelpItems)
64
- }
65
-
66
- if (polygonHintpolygon) {
67
- polygonHintpolygon.setLatLngs(currentLatLngs)
68
- } else {
69
- polygonHintpolygon = L.polygon(polygonVertexes, { stroke: false, fillOpacity: 0.1 }).addTo(drawHelpItems)
70
- }
71
- }
72
- }, 20)
73
-
74
- const Events = {
75
- onLayerCreate(event) {
76
- event.layer.remove().addTo(drawItems)
77
- if (event.shape === 'Polygon') {
78
- const hintMarkerIcon = createTextIcon(L.GeoUtil.readableArea(polygonCurrentArea))
79
- L.marker(currentLatLng, { interactive: false }).setIcon(hintMarkerIcon).addTo(drawItems)
80
- }
81
- },
82
- onDrawStart(event) {
83
- const workingLayer = event.workingLayer
84
- if (event.shape === 'Line') {
85
- map.on('mousemove', handleMouseMoveAtLine)
86
- workingLayer.on('pm:vertexadded', (vertex) => {
87
- const hintMarker = L.marker(vertex.latlng, { interactive: false })
88
- lineVertexes = workingLayer._latlngs
89
- if (lineVertexes.length === 1) {
90
- hintMarker.setIcon(createTextIcon('测距起点')).addTo(drawHelpItems)
91
- } else {
92
- const distanceText = L.GeometryUtil.readableDistance(lineCurrentDistance)
93
- hintMarker.setIcon(createTextIcon(distanceText)).addTo(drawHelpItems)
94
- }
95
- })
96
- } else if (event.shape === 'Polygon') {
97
- map.on('mousemove', handleMouseMoveAtPolygon)
98
- workingLayer.on('pm:vertexadded', () => {
99
- polygonVertexes = workingLayer._latlngs
100
- })
101
- }
102
- },
103
- onDrawEnd(event) {
104
- if (event.shape === 'Line') {
105
- map.off('mousemove', handleMouseMoveAtLine)
106
- if (lineHintMarker) {
107
- drawHelpItems.removeLayer(lineHintMarker)
108
- lineHintMarker = null
109
- }
110
- lineVertexes = []
111
- currentLatLng = null
112
- lineCurrentDistance = null
113
- } else if (event.shape === 'Polygon') {
114
- map.off('mousemove', handleMouseMoveAtPolygon)
115
- if (polygonHintMarker) {
116
- drawHelpItems.removeLayer(polygonHintMarker)
117
- polygonHintMarker = null
118
- }
119
- if (polygonHintpolygon) {
120
- drawHelpItems.removeLayer(polygonHintpolygon)
121
- polygonHintpolygon = null
122
- }
123
- polygonVertexes = []
124
- currentLatLng = null
125
- polygonCurrentArea = null
126
- }
127
-
128
- drawHelpItems.eachLayer((layer) => {
129
- drawHelpItems.removeLayer(layer)
130
- layer.addTo(drawItems)
131
- })
132
- drawHelpItems.clearLayers()
133
- unregisterDrawEvents()
134
- }
135
- }
136
-
137
- const registerDrawEvents = () => {
138
- map?.on('pm:create', Events.onLayerCreate)
139
- map?.on('pm:drawstart', Events.onDrawStart)
140
- map?.on('pm:drawend', Events.onDrawEnd)
141
- }
142
-
143
- export function useMapMeasure() {
144
- const drawStatus = ref(false)
145
-
146
- const enableMeasure = (value) => {
147
- map = value
148
- map.pm.setLang('zh')
149
- drawItems.clearLayers().addTo(map)
150
- drawHelpItems.clearLayers().addTo(map)
151
- }
152
-
153
- const startMeasure = (shape) => {
154
- registerDrawEvents()
155
- map.pm.enableDraw(shape)
156
- drawStatus.value = true
157
- }
158
-
159
- const cancelMeasure = () => {
160
- drawHelpItems.clearLayers()
161
- map.pm.Draw.getShapes().forEach((shape) => {
162
- map.pm.disableDraw(shape)
163
- })
164
-
165
- if (drawItems.getLayers().length === 0) {
166
- drawStatus.value = false
167
- }
168
- }
169
-
170
- const clearMeasure = () => {
171
- cancelMeasure()
172
- drawItems.clearLayers()
173
- drawStatus.value = false
174
- }
175
-
176
- onBeforeUnmount(() => {
177
- clearMeasure()
178
- if (map) {
179
- map.removeLayer(drawItems)
180
- map.removeLayer(drawHelpItems)
181
- }
182
- })
183
-
184
- return {
185
- DrawStatus: drawStatus,
186
- EnableMeasure: enableMeasure,
187
- StartMeasure: startMeasure,
188
- CancelMeasure: cancelMeasure,
189
- ClearMeasure: clearMeasure
190
- }
191
- }
@@ -1,81 +0,0 @@
1
- import { onBeforeUnmount, unref, watch } from 'vue'
2
-
3
- const observerRegistry = new WeakMap()
4
-
5
- function normalizeEntry(entry) {
6
- return {
7
- width: entry.contentRect.width,
8
- height: entry.contentRect.height,
9
- visible: !!(entry.contentRect.height && entry.contentRect.width),
10
- entry
11
- }
12
- }
13
-
14
- function getOrCreateRecord(element) {
15
- let record = observerRegistry.get(element)
16
- if (!record) {
17
- record = {
18
- listeners: new Set(),
19
- observer: new ResizeObserver((entries) => {
20
- for (const entry of entries) {
21
- const current = observerRegistry.get(entry.target)
22
- if (!current) {
23
- continue
24
- }
25
- const payload = normalizeEntry(entry)
26
- current.listeners.forEach((listener) => listener(payload))
27
- }
28
- })
29
- }
30
- record.observer.observe(element)
31
- observerRegistry.set(element, record)
32
- }
33
- return record
34
- }
35
-
36
- function cleanupRecord(element) {
37
- const record = observerRegistry.get(element)
38
- if (!record || record.listeners.size > 0) {
39
- return
40
- }
41
- record.observer.disconnect()
42
- observerRegistry.delete(element)
43
- }
44
-
45
- export function observeElementResize(element, callback) {
46
- if (!element || typeof callback !== 'function') {
47
- return () => {}
48
- }
49
- const record = getOrCreateRecord(element)
50
- record.listeners.add(callback)
51
-
52
- return () => {
53
- const current = observerRegistry.get(element)
54
- if (!current) {
55
- return
56
- }
57
- current.listeners.delete(callback)
58
- cleanupRecord(element)
59
- }
60
- }
61
-
62
- export function useElementResize(target, callback) {
63
- let stop = null
64
-
65
- const bind = (element) => {
66
- stop?.()
67
- stop = element ? observeElementResize(element, callback) : null
68
- }
69
-
70
- watch(
71
- () => unref(target),
72
- (element) => {
73
- bind(element)
74
- },
75
- { immediate: true }
76
- )
77
-
78
- onBeforeUnmount(() => {
79
- stop?.()
80
- })
81
- }
@@ -1 +0,0 @@
1
- export { useAutoMessage as default } from '@/composables/useAutoMessage'
@@ -1,16 +0,0 @@
1
- import '@/plugins/globals'
2
-
3
- import VaeAmap from './vae-amap/index.js'
4
- import VaeMap from './vae-map/index.js'
5
- import VaeCloudmap from './vae-cloudmap'
6
- const components = [VaeAmap, VaeMap, VaeCloudmap]
7
-
8
- const install = (app, options = {}) => {
9
- components.forEach((component) => {
10
- app.use(component, options)
11
- })
12
- }
13
-
14
- export { VaeAmap, VaeMap, VaeCloudmap }
15
-
16
- export default { install }
@@ -1,8 +0,0 @@
1
- import VaeAmap from './vae-amap.jsx'
2
- import './style.less'
3
-
4
- VaeAmap.install = (app, options = {}) => {
5
- app.component(`${options.prefix || 'vae'}-amap`, VaeAmap)
6
- }
7
-
8
- export default VaeAmap
@@ -1,9 +0,0 @@
1
- .vae-amap {
2
- .amap-logo {
3
- opacity: 0;
4
- }
5
-
6
- .amap-copyright {
7
- opacity: 0;
8
- }
9
- }
@@ -1,98 +0,0 @@
1
- import { defineComponent, onBeforeUnmount, onMounted, ref, watch } from 'vue'
2
- import AMapLoader from '@amap/amap-jsapi-loader'
3
- import { idGen } from '@/utils'
4
-
5
- export default defineComponent({
6
- name: 'VaeAmap',
7
- props: {
8
- height: {
9
- type: String,
10
- default: '100%'
11
- },
12
- width: {
13
- type: String,
14
- default: '100%'
15
- },
16
- apiKey: {
17
- type: String,
18
- default: ''
19
- },
20
- version: {
21
- type: String,
22
- default: '2.0'
23
- },
24
- plugins: {
25
- type: Array,
26
- default: () => []
27
- },
28
- options: {
29
- type: Object,
30
- default: () => ({})
31
- }
32
- },
33
- emits: ['amap-ready', 'init-map'],
34
- setup(props, { emit }) {
35
- const uuid = ref(`vae_amap_${idGen()}`)
36
- const amap = ref(null)
37
-
38
- const redefineAMap = () => {
39
- const originalConvertFrom = AMap.convertFrom
40
- AMap.convertFrom = function (lnglat, type = 'gps') {
41
- return new Promise((resolve) => {
42
- originalConvertFrom(lnglat, type, (status, result) => {
43
- resolve(result.locations)
44
- })
45
- })
46
- }
47
- }
48
-
49
- const loadResource = async () => {
50
- if (!window.AMap) {
51
- await AMapLoader.load({
52
- key: props.apiKey,
53
- version: props.version,
54
- plugins: props.plugins
55
- })
56
- redefineAMap()
57
- }
58
- emit('amap-ready')
59
- }
60
-
61
- const createMap = () => {
62
- if (!amap.value && !_.isEmpty(props.options)) {
63
- if (window.AMap) {
64
- amap.value = new AMap.Map(uuid.value, props.options)
65
- amap.value.on('complete', () => {
66
- emit('init-map', amap.value)
67
- })
68
- } else {
69
- console.error("AMap is not ready, set options in 'amap-ready' event")
70
- }
71
- }
72
- }
73
-
74
- watch(
75
- () => props.options,
76
- () => {
77
- createMap()
78
- },
79
- { deep: true }
80
- )
81
-
82
- onMounted(() => {
83
- loadResource()
84
- })
85
-
86
- onBeforeUnmount(() => {
87
- amap.value?.destroy()
88
- })
89
-
90
- return () => (
91
- <div
92
- id={uuid.value}
93
- class="vae-amap"
94
- style={{ height: props.height, width: props.width }}>
95
- </div>
96
- )
97
- }
98
- })
@@ -1,74 +0,0 @@
1
- <template>
2
- <div class="vae-map-ctrl--context-menu" :style="style">
3
- <template v-for="item in menus" :key="item.text">
4
- <div class="item" :class="{ 'is-disabled': item.disabled, 'is-divided': item.divided }" @click="handleItemClick(item)">
5
- {{ item.text }}
6
- </div>
7
- </template>
8
- </div>
9
- </template>
10
-
11
- <script setup>
12
- import { computed } from 'vue'
13
-
14
- const props = defineProps({
15
- left: {
16
- type: Number,
17
- default: 0
18
- },
19
- top: {
20
- type: Number,
21
- default: 0
22
- },
23
- menus: {
24
- type: Array,
25
- default: () => []
26
- }
27
- })
28
-
29
- const emit = defineEmits(['callback'])
30
-
31
- const handleItemClick = (item) => {
32
- if (!item.disabled) {
33
- emit('callback', item.callback)
34
- }
35
- }
36
-
37
- const style = computed(() => ({
38
- left: `${props.left}px`,
39
- top: `${props.top}px`
40
- }))
41
- </script>
42
-
43
- <style lang="less" scoped>
44
- .vae-map-ctrl--context-menu {
45
- position: absolute;
46
- width: 200px;
47
- background-color: white;
48
- padding: 3px 0px;
49
- box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2);
50
- z-index: 2000;
51
-
52
- .item {
53
- height: 28px;
54
- line-height: 28px;
55
- font-size: 12px;
56
- padding: 0px 12px;
57
- letter-spacing: 1px;
58
- cursor: default;
59
-
60
- &:not(:first-child).is-divided {
61
- border-top: 1px solid #dcdfe6;
62
- }
63
-
64
- &:hover {
65
- background-color: #eee;
66
- }
67
-
68
- &.is-disabled {
69
- color: #c0c4cc;
70
- background-color: white;
71
- }
72
- }
73
- }
74
- </style>