@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,101 +0,0 @@
1
- import { computed, h, nextTick, onBeforeUnmount, ref, unref, watch } from 'vue'
2
- import ContextMenu from '../../ctrl-context-menu/index.vue'
3
-
4
- function resolveElement(target) {
5
- return target?.$el ?? target ?? null
6
- }
7
-
8
- export function useCloudmapContextMenu({ 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
- }
100
-
101
- export default useCloudmapContextMenu
@@ -1,163 +0,0 @@
1
- .vae-map,
2
- .vae-lrmap {
3
- position: relative;
4
-
5
- .leaflet-map {
6
- height: 100%;
7
- width: 100%;
8
- background: transparent;
9
-
10
- #tooltips();
11
- }
12
-
13
- .loading-mask {
14
- position: absolute;
15
- z-index: 2000;
16
- background: rgba(255, 255, 255, 0.8);
17
- top: 0;
18
- right: 0;
19
- bottom: 0;
20
- left: 0;
21
- transition: opacity 0.3s;
22
-
23
-
24
-
25
- .wrapper {
26
- display: flex;
27
- flex-direction: column;
28
- align-items: center;
29
- justify-content: center;
30
- height: 100%;
31
-
32
- .loading-icon {
33
- font-size: 42px;
34
- color: #409eff;
35
- }
36
-
37
- .loading-text {
38
- font-size: 14px;
39
- color: #409eff;
40
- margin-top: 5px;
41
- }
42
- }
43
- }
44
- }
45
-
46
- #tooltips() {
47
- .icon--simple-text {
48
- background: rgba(255, 255, 255, 0.8);
49
- border: 1px solid #dcdfe6;
50
- color: #303133;
51
- font-size: 12px;
52
- font-weight: bold;
53
- padding: 2px 4px;
54
- text-align: center;
55
- margin-top: -25px !important;
56
- box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.1);
57
-
58
- &.dark {
59
- color: white;
60
- background: #343a40;
61
- }
62
- }
63
-
64
- .ht-tooltip {
65
- font-size: 12px;
66
- padding: 2px 4px;
67
-
68
- .action {
69
- margin-right: 2px;
70
- }
71
-
72
- .green {
73
- color: seagreen;
74
- font-weight: bold;
75
- }
76
-
77
- .red {
78
- color: firebrick;
79
- font-weight: bold;
80
- }
81
- }
82
- }
83
-
84
- .vae-map-ctrl--draw {
85
- position: absolute;
86
- left: 10px;
87
- top: 10px;
88
- z-index: 1000;
89
- border-radius: 5px;
90
-
91
- .item-group {
92
- background: #f4f4f5;
93
- border-radius: 4px;
94
- box-shadow: 1px 2px 6px 0 rgba(0, 0, 0, 0.2);
95
-
96
- &:not(:first-child) {
97
- margin-top: 6px;
98
- }
99
-
100
- .item {
101
- display: flex;
102
- align-items: center;
103
- position: relative;
104
-
105
- &:not(:first-child) {
106
- border-top: 1px solid #e4e7ed;
107
- }
108
-
109
- .item-icon {
110
- display: inline-flex;
111
- align-items: center;
112
- justify-content: center;
113
- height: 34px;
114
- width: 36px;
115
- color: #606266;
116
- font-size: 16px;
117
- cursor: pointer;
118
-
119
- &:hover {
120
- color: #409eff;
121
- }
122
-
123
- &.disabled {
124
- color: #909399;
125
- }
126
- }
127
-
128
- .tooltips {
129
- position: absolute;
130
- font-size: 12px;
131
- color: #606266;
132
- left: 100%;
133
- margin-left: 6px;
134
- width: max-content;
135
-
136
- span {
137
- padding: 6px 9px;
138
- background: #3a8ee6;
139
- color: white;
140
- cursor: pointer;
141
-
142
- &:hover {
143
- background: #409eff;
144
- }
145
-
146
- &:not(:first-child) {
147
- border-left: 1px solid white;
148
- }
149
-
150
- &:first-child {
151
- border-top-left-radius: 2px;
152
- border-bottom-left-radius: 2px;
153
- }
154
-
155
- &:last-child {
156
- border-top-right-radius: 2px;
157
- border-bottom-right-radius: 2px;
158
- }
159
- }
160
- }
161
- }
162
- }
163
- }
@@ -1,272 +0,0 @@
1
- import { computed, defineComponent, nextTick, onBeforeUnmount, onMounted, ref, toRef, watch } from 'vue'
2
- import { idGen } from '@/utils'
3
- import ResizeListener from '@/components/resize-listener/index.js'
4
- import { useAutoMessage } from '@/composables/useAutoMessage'
5
- import { useCloudmapContextMenu } from './scripts/Mixin.ContextMenu'
6
-
7
- export default defineComponent({
8
- name: 'VaeCloudmap',
9
- props: {
10
- height: {
11
- type: String,
12
- default: '100%'
13
- },
14
- width: {
15
- type: String,
16
- default: '100%'
17
- },
18
- options: {
19
- type: Object,
20
- default: () => ({})
21
- },
22
- beforeCreate: {
23
- type: Function,
24
- default: _.noop
25
- },
26
- contextMenu: {
27
- type: Array,
28
- default: () => []
29
- }
30
- },
31
- emits: ['init-map', 'reload-map'],
32
- setup(props, { emit, expose }) {
33
- const autoMessage = useAutoMessage()
34
- const destroyed = ref(false)
35
- const client = ref(null)
36
- const uuid = ref(`vae_lrmap_${idGen()}`)
37
- const map = ref(null)
38
- const inited = ref(false)
39
- const loading = ref(false)
40
- const loadingText = ref('')
41
- const innerLoading = ref(false)
42
- const innerLoadingText = ref('')
43
- const tileLayer = ref(null)
44
- const mapContainerRef = ref(null)
45
- const { addContextMenu, renderContextMenu } = useCloudmapContextMenu({
46
- mapRef: map,
47
- mapContainerRef,
48
- menusRef: toRef(props, 'contextMenu')
49
- })
50
-
51
- const mapLoading = computed(() => loading.value || innerLoading.value)
52
- const mapLoadingText = computed(() => loadingText.value || innerLoadingText.value)
53
-
54
- const createContextInstance = (includeMap) => {
55
- const {
56
- leafletOptions, requestOptions, treeLayers, visibleKeys,
57
- requestServer, queryEntity, getFeatureDict, showLayers, showLayerSets, getLayerSetsKeys, getThumbnail
58
- } = client.value
59
-
60
- const properties = _.merge({ el: uuid.value, client: client.value }, leafletOptions, requestOptions)
61
- const layerProperties = includeMap ? { treeLayers, visibleKeys } : {}
62
- const requestFunctions = {
63
- requestServer: requestServer.bind(client.value),
64
- queryEntity: queryEntity.bind(client.value),
65
- getFeatureDict: getFeatureDict.bind(client.value),
66
- showLayers: showLayers.bind(client.value),
67
- showLayerSets: showLayerSets.bind(client.value),
68
- getLayerSetsKeys: getLayerSetsKeys.bind(client.value),
69
- getThumbnail: getThumbnail.bind(client.value)
70
- }
71
- const mapFunctions = includeMap ? {
72
- refreshMap: () => {
73
- refreshTileLayer()
74
- setDefaultView()
75
- },
76
- reloadMap
77
- } : null
78
-
79
- return _.merge(properties, layerProperties, requestFunctions, mapFunctions)
80
- }
81
-
82
- const openMask = (text) => {
83
- loading.value = true
84
- loadingText.value = text
85
- }
86
-
87
- const closeMask = () => {
88
- loading.value = false
89
- loadingText.value = ''
90
- }
91
-
92
- const openInnerMask = (text) => {
93
- innerLoading.value = true
94
- innerLoadingText.value = text
95
- }
96
-
97
- const closeInnerMask = () => {
98
- innerLoading.value = false
99
- innerLoadingText.value = ''
100
- }
101
-
102
- const onFail = (obj) => {
103
- if (typeof props.options?.onFail === 'function') {
104
- props.options.onFail(obj.message)
105
- }
106
- }
107
-
108
- const refreshTileLayer = () => {
109
- if (!map.value || !client.value) {
110
- return
111
- }
112
- if (tileLayer.value) {
113
- map.value.removeLayer(tileLayer.value)
114
- }
115
- tileLayer.value = client.value.currentTileLayer().addTo(map.value)
116
- }
117
-
118
- const refreshClient = () => {
119
- client.value = new L.Vae.CloudClient(L.extend({ uid: uuid.value }, props.options))
120
- client.value.on('message', (event) => {
121
- autoMessage({
122
- message: event.message,
123
- type: event.messageType
124
- })
125
- })
126
- client.value.on('openmask', (event) => {
127
- openInnerMask(event.text)
128
- })
129
- client.value.on('closemask', closeInnerMask)
130
- client.value.on('refreshtilelayer', refreshTileLayer)
131
- client.value.on('fail', onFail)
132
- }
133
-
134
- const setDefaultView = (animate = true) => {
135
- if (map.value) {
136
- if (props.options.zoom && props.options.center) {
137
- return
138
- }
139
- map.value.fitBounds(client.value.leafletOptions.bounds, { animate })
140
- }
141
- }
142
-
143
- const createMap = () => {
144
- if (!map.value) {
145
- const options = L.extend(
146
- {
147
- zoomControl: false,
148
- attributionControl: false,
149
- doubleClickZoom: false
150
- },
151
- _.omit(props.options, ['url', 'dsname', 'layerTreeType', 'defaultLayers', 'defaultLayerSets']),
152
- _.pick(client.value.leafletOptions, ['crs', 'center', 'maxZoom'])
153
- )
154
- map.value = L.map(uuid.value, options)
155
- setDefaultView(false)
156
-
157
- return new Promise((resolve) => {
158
- map.value.whenReady(resolve)
159
- })
160
- }
161
-
162
- return Promise.resolve()
163
- }
164
-
165
- const extendMapInstance = () => {
166
- map.value.vae = {}
167
- _.merge(map.value.vae, createContextInstance(true))
168
- }
169
-
170
- const requestMeta = ({ event = 'init-map', alert = true } = {}) => {
171
- refreshClient()
172
- client.value.start(alert).then(async (metaReady) => {
173
- if (!metaReady) {
174
- return
175
- }
176
-
177
- await props.beforeCreate(createContextInstance(false))
178
- await client.value.setDefaultLayers()
179
- await createMap()
180
- addContextMenu()
181
- refreshTileLayer()
182
- extendMapInstance()
183
- emit(event, map.value)
184
-
185
- if (event === 'init-map') {
186
- inited.value = true
187
- }
188
- })
189
- }
190
-
191
- const resizeMap = () => {
192
- map.value?.invalidateSize()
193
- }
194
-
195
- const reloadMap = () => {
196
- map.value?.remove()
197
- map.value = null
198
- tileLayer.value = null
199
- destroyed.value = true
200
- nextTick(() => {
201
- destroyed.value = false
202
- nextTick(() => {
203
- requestMeta({ event: 'reload-map' })
204
- })
205
- })
206
- }
207
-
208
- watch(
209
- () => props.options,
210
- () => {
211
- if (!inited.value) {
212
- requestMeta({ alert: true })
213
- }
214
- },
215
- { deep: true }
216
- )
217
-
218
- onMounted(() => {
219
- requestMeta({ alert: false })
220
- })
221
-
222
- onBeforeUnmount(() => {
223
- map.value?.remove()
224
- })
225
-
226
- expose({
227
- requestMeta,
228
- refreshClient,
229
- createMap,
230
- extendMapInstance,
231
- createContextInstance,
232
- refreshTileLayer,
233
- setDefaultView,
234
- openMask,
235
- closeMask,
236
- openInnerMask,
237
- closeInnerMask,
238
- resizeMap,
239
- reloadMap,
240
- onFail
241
- })
242
-
243
- return () => {
244
- if (destroyed.value) {
245
- return null
246
- }
247
-
248
- const loadingMask = mapLoading.value ? (
249
- <div class="loading-mask">
250
- <div class="wrapper">
251
- <div class="loading-icon">
252
- <i class="fas fa-circle-notch fa-spin"></i>
253
- </div>
254
- <div class="loading-text">{mapLoadingText.value}</div>
255
- </div>
256
- </div>
257
- ) : null
258
-
259
- return (
260
- <ResizeListener
261
- ref={mapContainerRef}
262
- class="vae-lrmap cloudmap"
263
- style={{ height: props.height, width: props.width }}
264
- onResize={resizeMap}>
265
- <div class="leaflet-map" id={uuid.value}></div>
266
- {renderContextMenu()}
267
- {loadingMask}
268
- </ResizeListener>
269
- )
270
- }
271
- }
272
- })
@@ -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 0;
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: 0 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>