xt-element-ui 2.1.61 → 2.2.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 (202) hide show
  1. package/docs/components/base/xt-bar.md +5 -5
  2. package/docs/components/base/xt-chart.md +5 -5
  3. package/docs/components/base/xt-line.md +4 -4
  4. package/docs/components/base/xt-multi.md +5 -5
  5. package/docs/components/base/xt-pie.md +5 -5
  6. package/lib/index.common.js +503 -165
  7. package/lib/index.css +1 -1
  8. package/lib/index.umd.js +506 -168
  9. package/lib/index.umd.min.js +1 -1
  10. package/lib/xt-badge/demo.html +10 -0
  11. package/lib/xt-badge/index.js +1 -0
  12. package/lib/xt-badge/xt-badge.common.js +335 -0
  13. package/lib/xt-badge/xt-badge.css +1 -0
  14. package/lib/xt-badge/xt-badge.umd.js +345 -0
  15. package/lib/xt-badge/xt-badge.umd.min.js +1 -0
  16. package/lib/xt-button/demo.html +10 -0
  17. package/lib/xt-button/index.js +1 -0
  18. package/lib/xt-button/xt-button.common.js +331 -0
  19. package/lib/xt-button/xt-button.css +1 -0
  20. package/lib/xt-button/xt-button.umd.js +341 -0
  21. package/lib/xt-button/xt-button.umd.min.js +1 -0
  22. package/lib/xt-card/demo.html +10 -0
  23. package/lib/xt-card/index.js +1 -0
  24. package/lib/xt-card/xt-card.common.js +325 -0
  25. package/lib/xt-card/xt-card.css +1 -0
  26. package/lib/xt-card/xt-card.umd.js +335 -0
  27. package/lib/xt-card/xt-card.umd.min.js +1 -0
  28. package/lib/xt-card-item/demo.html +10 -0
  29. package/lib/xt-card-item/index.js +1 -0
  30. package/lib/xt-card-item/xt-card-item.common.js +291 -0
  31. package/lib/xt-card-item/xt-card-item.css +1 -0
  32. package/lib/xt-card-item/xt-card-item.umd.js +301 -0
  33. package/lib/xt-card-item/xt-card-item.umd.min.js +1 -0
  34. package/lib/xt-chart/demo.html +10 -0
  35. package/lib/xt-chart/index.js +1 -0
  36. package/lib/xt-chart/xt-chart.common.js +109203 -0
  37. package/lib/xt-chart/xt-chart.css +1 -0
  38. package/lib/xt-chart/xt-chart.umd.js +109213 -0
  39. package/lib/xt-chart/xt-chart.umd.min.js +1 -0
  40. package/lib/xt-config-provider/demo.html +10 -0
  41. package/lib/xt-config-provider/index.js +1 -0
  42. package/lib/xt-config-provider/xt-config-provider.common.js +108388 -0
  43. package/lib/xt-config-provider/xt-config-provider.css +1 -0
  44. package/lib/xt-config-provider/xt-config-provider.umd.js +108398 -0
  45. package/lib/xt-config-provider/xt-config-provider.umd.min.js +1 -0
  46. package/lib/xt-date-picker/demo.html +10 -0
  47. package/lib/xt-date-picker/index.js +1 -0
  48. package/lib/xt-date-picker/xt-date-picker.common.js +768 -0
  49. package/lib/xt-date-picker/xt-date-picker.css +1 -0
  50. package/lib/xt-date-picker/xt-date-picker.umd.js +778 -0
  51. package/lib/xt-date-picker/xt-date-picker.umd.min.js +1 -0
  52. package/lib/xt-flex-box/demo.html +10 -0
  53. package/lib/xt-flex-box/index.js +1 -0
  54. package/lib/xt-flex-box/xt-flex-box.common.js +303 -0
  55. package/lib/xt-flex-box/xt-flex-box.css +1 -0
  56. package/lib/xt-flex-box/xt-flex-box.umd.js +313 -0
  57. package/lib/xt-flex-box/xt-flex-box.umd.min.js +1 -0
  58. package/lib/xt-form-schema/demo.html +10 -0
  59. package/lib/xt-form-schema/index.js +1 -0
  60. package/lib/xt-form-schema/xt-form-schema.common.js +510 -0
  61. package/lib/xt-form-schema/xt-form-schema.css +1 -0
  62. package/lib/xt-form-schema/xt-form-schema.umd.js +520 -0
  63. package/lib/xt-form-schema/xt-form-schema.umd.min.js +1 -0
  64. package/lib/xt-grid-box/demo.html +10 -0
  65. package/lib/xt-grid-box/index.js +1 -0
  66. package/lib/xt-grid-box/xt-grid-box.common.js +404 -0
  67. package/lib/xt-grid-box/xt-grid-box.css +1 -0
  68. package/lib/xt-grid-box/xt-grid-box.umd.js +414 -0
  69. package/lib/xt-grid-box/xt-grid-box.umd.min.js +1 -0
  70. package/lib/xt-grid-item/demo.html +10 -0
  71. package/lib/xt-grid-item/index.js +1 -0
  72. package/lib/xt-grid-item/xt-grid-item.common.js +381 -0
  73. package/lib/xt-grid-item/xt-grid-item.css +1 -0
  74. package/lib/xt-grid-item/xt-grid-item.umd.js +391 -0
  75. package/lib/xt-grid-item/xt-grid-item.umd.min.js +1 -0
  76. package/lib/xt-icon/demo.html +10 -0
  77. package/lib/xt-icon/index.js +1 -0
  78. package/lib/xt-icon/xt-icon.common.js +430 -0
  79. package/lib/xt-icon/xt-icon.css +1 -0
  80. package/lib/xt-icon/xt-icon.umd.js +440 -0
  81. package/lib/xt-icon/xt-icon.umd.min.js +1 -0
  82. package/lib/xt-input/demo.html +10 -0
  83. package/lib/xt-input/index.js +1 -0
  84. package/lib/xt-input/xt-input.common.js +584 -0
  85. package/lib/xt-input/xt-input.css +1 -0
  86. package/lib/xt-input/xt-input.umd.js +594 -0
  87. package/lib/xt-input/xt-input.umd.min.js +1 -0
  88. package/lib/xt-list/demo.html +10 -0
  89. package/lib/xt-list/index.js +1 -0
  90. package/lib/xt-list/xt-list.common.js +714 -0
  91. package/lib/xt-list/xt-list.css +1 -0
  92. package/lib/xt-list/xt-list.umd.js +724 -0
  93. package/lib/xt-list/xt-list.umd.min.js +1 -0
  94. package/lib/xt-map/demo.html +10 -0
  95. package/lib/xt-map/index.js +1 -0
  96. package/lib/xt-map/xt-map.common.js +1951 -0
  97. package/lib/xt-map/xt-map.css +1 -0
  98. package/lib/xt-map/xt-map.umd.js +1961 -0
  99. package/lib/xt-map/xt-map.umd.min.js +1 -0
  100. package/lib/xt-map-provider/demo.html +10 -0
  101. package/lib/xt-map-provider/index.js +1 -0
  102. package/lib/xt-map-provider/xt-map-provider.common.js +644 -0
  103. package/lib/xt-map-provider/xt-map-provider.css +1 -0
  104. package/lib/xt-map-provider/xt-map-provider.umd.js +654 -0
  105. package/lib/xt-map-provider/xt-map-provider.umd.min.js +1 -0
  106. package/lib/xt-page/demo.html +10 -0
  107. package/lib/xt-page/index.js +1 -0
  108. package/lib/xt-page/xt-page.common.js +353 -0
  109. package/lib/xt-page/xt-page.css +1 -0
  110. package/lib/xt-page/xt-page.umd.js +363 -0
  111. package/lib/xt-page/xt-page.umd.min.js +1 -0
  112. package/lib/xt-progress/demo.html +10 -0
  113. package/lib/xt-progress/index.js +1 -0
  114. package/lib/xt-progress/xt-progress.common.js +327 -0
  115. package/lib/xt-progress/xt-progress.css +1 -0
  116. package/lib/xt-progress/xt-progress.umd.js +337 -0
  117. package/lib/xt-progress/xt-progress.umd.min.js +1 -0
  118. package/lib/xt-scroll-arrow/demo.html +10 -0
  119. package/lib/xt-scroll-arrow/index.js +1 -0
  120. package/lib/xt-scroll-arrow/xt-scroll-arrow.common.js +495 -0
  121. package/lib/xt-scroll-arrow/xt-scroll-arrow.css +1 -0
  122. package/lib/xt-scroll-arrow/xt-scroll-arrow.umd.js +505 -0
  123. package/lib/xt-scroll-arrow/xt-scroll-arrow.umd.min.js +1 -0
  124. package/lib/xt-select-tree/demo.html +10 -0
  125. package/lib/xt-select-tree/index.js +1 -0
  126. package/lib/xt-select-tree/xt-select-tree.common.js +1791 -0
  127. package/lib/xt-select-tree/xt-select-tree.css +1 -0
  128. package/lib/xt-select-tree/xt-select-tree.umd.js +1801 -0
  129. package/lib/xt-select-tree/xt-select-tree.umd.min.js +1 -0
  130. package/lib/xt-step-price/demo.html +10 -0
  131. package/lib/xt-step-price/index.js +1 -0
  132. package/lib/xt-step-price/xt-step-price.common.js +800 -0
  133. package/lib/xt-step-price/xt-step-price.css +1 -0
  134. package/lib/xt-step-price/xt-step-price.umd.js +810 -0
  135. package/lib/xt-step-price/xt-step-price.umd.min.js +1 -0
  136. package/lib/xt-step-price-item/demo.html +10 -0
  137. package/lib/xt-step-price-item/index.js +1 -0
  138. package/lib/xt-step-price-item/xt-step-price-item.common.js +417 -0
  139. package/lib/xt-step-price-item/xt-step-price-item.umd.js +427 -0
  140. package/lib/xt-step-price-item/xt-step-price-item.umd.min.js +1 -0
  141. package/lib/xt-tab-pane/demo.html +10 -0
  142. package/lib/xt-tab-pane/index.js +1 -0
  143. package/lib/xt-tab-pane/xt-tab-pane.common.js +309 -0
  144. package/lib/xt-tab-pane/xt-tab-pane.umd.js +319 -0
  145. package/lib/xt-tab-pane/xt-tab-pane.umd.min.js +1 -0
  146. package/lib/xt-table/demo.html +10 -0
  147. package/lib/xt-table/index.js +1 -0
  148. package/lib/xt-table/xt-table.common.js +1027 -0
  149. package/lib/xt-table/xt-table.css +1 -0
  150. package/lib/xt-table/xt-table.umd.js +1037 -0
  151. package/lib/xt-table/xt-table.umd.min.js +1 -0
  152. package/lib/xt-tabs/demo.html +10 -0
  153. package/lib/xt-tabs/index.js +1 -0
  154. package/lib/xt-tabs/xt-tabs.common.js +463 -0
  155. package/lib/xt-tabs/xt-tabs.css +1 -0
  156. package/lib/xt-tabs/xt-tabs.umd.js +473 -0
  157. package/lib/xt-tabs/xt-tabs.umd.min.js +1 -0
  158. package/lib/xt-text/demo.html +10 -0
  159. package/lib/xt-text/index.js +1 -0
  160. package/lib/xt-text/xt-text.common.js +536 -0
  161. package/lib/xt-text/xt-text.css +1 -0
  162. package/lib/xt-text/xt-text.umd.js +546 -0
  163. package/lib/xt-text/xt-text.umd.min.js +1 -0
  164. package/lib/xt-time/demo.html +10 -0
  165. package/lib/xt-time/index.js +1 -0
  166. package/lib/xt-time/xt-time.common.js +555 -0
  167. package/lib/xt-time/xt-time.css +1 -0
  168. package/lib/xt-time/xt-time.umd.js +565 -0
  169. package/lib/xt-time/xt-time.umd.min.js +1 -0
  170. package/lib/xt-transfer-tree/demo.html +10 -0
  171. package/lib/xt-transfer-tree/index.js +1 -0
  172. package/lib/xt-transfer-tree/xt-transfer-tree.common.js +594 -0
  173. package/lib/xt-transfer-tree/xt-transfer-tree.css +1 -0
  174. package/lib/xt-transfer-tree/xt-transfer-tree.umd.js +604 -0
  175. package/lib/xt-transfer-tree/xt-transfer-tree.umd.min.js +1 -0
  176. package/lib/xt-upload/demo.html +10 -0
  177. package/lib/xt-upload/index.js +1 -0
  178. package/lib/xt-upload/xt-upload.common.js +1292 -0
  179. package/lib/xt-upload/xt-upload.css +1 -0
  180. package/lib/xt-upload/xt-upload.umd.js +1302 -0
  181. package/lib/xt-upload/xt-upload.umd.min.js +1 -0
  182. package/package.json +10 -7
  183. package/src/components/xt-badge/index.js +8 -7
  184. package/src/components/xt-button/index.js +1 -0
  185. package/src/components/xt-card/index.js +1 -0
  186. package/src/components/xt-card-item/index.js +1 -0
  187. package/src/components/xt-config-provider/index.js +1 -0
  188. package/src/components/xt-flex-box/index.js +1 -0
  189. package/src/components/xt-grid-box/index.js +1 -0
  190. package/src/components/xt-icon/index.js +1 -0
  191. package/src/components/xt-input/index.js +1 -0
  192. package/src/components/xt-map/index.js +1 -0
  193. package/src/components/xt-progress/index.js +8 -7
  194. package/src/components/xt-scroll-arrow/index.js +8 -7
  195. package/src/components/xt-step-price/index.js +1 -0
  196. package/src/components/xt-tab-pane/index.js +10 -0
  197. package/src/components/{xt-tabs/TabPane.vue → xt-tab-pane/index.vue} +14 -1
  198. package/src/components/xt-tabs/index.js +9 -10
  199. package/src/components/xt-tabs/index.vue +303 -44
  200. package/src/components/xt-text/index.js +1 -0
  201. package/src/components/xt-time/index.js +1 -0
  202. package/src/index.js +34 -2
@@ -0,0 +1,1951 @@
1
+ module.exports =
2
+ /******/ (function(modules) { // webpackBootstrap
3
+ /******/ // The module cache
4
+ /******/ var installedModules = {};
5
+ /******/
6
+ /******/ // The require function
7
+ /******/ function __webpack_require__(moduleId) {
8
+ /******/
9
+ /******/ // Check if module is in cache
10
+ /******/ if(installedModules[moduleId]) {
11
+ /******/ return installedModules[moduleId].exports;
12
+ /******/ }
13
+ /******/ // Create a new module (and put it into the cache)
14
+ /******/ var module = installedModules[moduleId] = {
15
+ /******/ i: moduleId,
16
+ /******/ l: false,
17
+ /******/ exports: {}
18
+ /******/ };
19
+ /******/
20
+ /******/ // Execute the module function
21
+ /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
22
+ /******/
23
+ /******/ // Flag the module as loaded
24
+ /******/ module.l = true;
25
+ /******/
26
+ /******/ // Return the exports of the module
27
+ /******/ return module.exports;
28
+ /******/ }
29
+ /******/
30
+ /******/
31
+ /******/ // expose the modules object (__webpack_modules__)
32
+ /******/ __webpack_require__.m = modules;
33
+ /******/
34
+ /******/ // expose the module cache
35
+ /******/ __webpack_require__.c = installedModules;
36
+ /******/
37
+ /******/ // define getter function for harmony exports
38
+ /******/ __webpack_require__.d = function(exports, name, getter) {
39
+ /******/ if(!__webpack_require__.o(exports, name)) {
40
+ /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
41
+ /******/ }
42
+ /******/ };
43
+ /******/
44
+ /******/ // define __esModule on exports
45
+ /******/ __webpack_require__.r = function(exports) {
46
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
47
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
48
+ /******/ }
49
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
50
+ /******/ };
51
+ /******/
52
+ /******/ // create a fake namespace object
53
+ /******/ // mode & 1: value is a module id, require it
54
+ /******/ // mode & 2: merge all properties of value into the ns
55
+ /******/ // mode & 4: return value when already ns object
56
+ /******/ // mode & 8|1: behave like require
57
+ /******/ __webpack_require__.t = function(value, mode) {
58
+ /******/ if(mode & 1) value = __webpack_require__(value);
59
+ /******/ if(mode & 8) return value;
60
+ /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
61
+ /******/ var ns = Object.create(null);
62
+ /******/ __webpack_require__.r(ns);
63
+ /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
64
+ /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
65
+ /******/ return ns;
66
+ /******/ };
67
+ /******/
68
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
69
+ /******/ __webpack_require__.n = function(module) {
70
+ /******/ var getter = module && module.__esModule ?
71
+ /******/ function getDefault() { return module['default']; } :
72
+ /******/ function getModuleExports() { return module; };
73
+ /******/ __webpack_require__.d(getter, 'a', getter);
74
+ /******/ return getter;
75
+ /******/ };
76
+ /******/
77
+ /******/ // Object.prototype.hasOwnProperty.call
78
+ /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
79
+ /******/
80
+ /******/ // __webpack_public_path__
81
+ /******/ __webpack_require__.p = "";
82
+ /******/
83
+ /******/
84
+ /******/ // Load entry module and return exports
85
+ /******/ return __webpack_require__(__webpack_require__.s = "fb15");
86
+ /******/ })
87
+ /************************************************************************/
88
+ /******/ ({
89
+
90
+ /***/ "c759":
91
+ /***/ (function(module, exports, __webpack_require__) {
92
+
93
+ // extracted by mini-css-extract-plugin
94
+
95
+ /***/ }),
96
+
97
+ /***/ "fb15":
98
+ /***/ (function(module, __webpack_exports__, __webpack_require__) {
99
+
100
+ "use strict";
101
+ // ESM COMPAT FLAG
102
+ __webpack_require__.r(__webpack_exports__);
103
+
104
+ // EXPORTS
105
+ __webpack_require__.d(__webpack_exports__, "XtMap", function() { return /* reexport */ xt_map; });
106
+
107
+ // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/setPublicPath.js
108
+ // This file is imported into lib/wc client bundles.
109
+
110
+ if (typeof window !== 'undefined') {
111
+ var currentScript = window.document.currentScript
112
+ if (false) { var getCurrentScript; }
113
+
114
+ var src = currentScript && currentScript.src.match(/(.+\/)[^/]+\.js(\?.*)?$/)
115
+ if (src) {
116
+ __webpack_require__.p = src[1] // eslint-disable-line
117
+ }
118
+ }
119
+
120
+ // Indicate to webpack that this file can be concatenated
121
+ /* harmony default export */ var setPublicPath = (null);
122
+
123
+ // EXTERNAL MODULE: ./src/components/xt-map/style/index.scss
124
+ var style = __webpack_require__("c759");
125
+
126
+ // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js?{"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"b8cd9b04-vue-loader-template"}!./node_modules/vue-loader/lib/loaders/templateLoader.js??ref--5!./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/xt-map/index.vue?vue&type=template&id=0c15823e
127
+ var render = function render(){var _vm=this,_c=_vm._self._c;return _c('div',{staticClass:"xt-map-wrapper"},[_c('div',{ref:"mapContainer",staticClass:"xt-map-container",attrs:{"data-theme":_vm.mergedTheme}}),(_vm.loading)?_c('div',{staticClass:"xt-map-loading"},[_c('span',[_vm._v("地图加载中...")])]):_vm._e(),(_vm.errorMessage)?_c('div',{staticClass:"xt-map-error"},[_c('span',[_vm._v(_vm._s(_vm.errorMessage))])]):_vm._e(),_vm._t("overlay")],2)
128
+ }
129
+ var staticRenderFns = []
130
+
131
+
132
+ // CONCATENATED MODULE: ./src/components/xt-map/index.vue?vue&type=template&id=0c15823e
133
+
134
+ // CONCATENATED MODULE: ./src/components/xt-map/loaders/script-loader.js
135
+ /**
136
+ * 动态脚本加载器
137
+ * 负责动态注入地图 SDK <script> 标签,并返回 Promise
138
+ * 同一 URL 只会加载一次,缓存已加载的结果
139
+ */
140
+
141
+ const loadedScripts = new Map() // URL -> Promise
142
+ const loadingScripts = new Map() // URL -> Promise (正在加载中)
143
+
144
+ /**
145
+ * 动态加载单个脚本
146
+ * @param {string} url - 脚本 URL
147
+ * @param {object} options - 配置
148
+ * @param {string} options.charset - 字符集,默认 'utf-8'
149
+ * @param {boolean} options.async - 是否异步,默认 true
150
+ * @param {number} options.timeout - 超时时间(ms),默认 30000
151
+ * @returns {Promise<HTMLScriptElement>}
152
+ */
153
+ const loadScript = (url, options = {}) => {
154
+ if (typeof window === 'undefined') {
155
+ return Promise.reject(new Error('[XtMap] 非浏览器环境'))
156
+ }
157
+
158
+ const { charset = 'utf-8', async = true, timeout = 30000 } = options
159
+
160
+ if (loadedScripts.has(url)) {
161
+ return loadedScripts.get(url)
162
+ }
163
+
164
+ if (loadingScripts.has(url)) {
165
+ return loadingScripts.get(url)
166
+ }
167
+
168
+ const promise = new Promise((resolve, reject) => {
169
+ const script = document.createElement('script')
170
+ script.type = 'text/javascript'
171
+ script.src = url
172
+ script.charset = charset
173
+ script.async = async
174
+
175
+ let timer = null
176
+ let done = false
177
+
178
+ const cleanup = () => {
179
+ done = true
180
+ if (timer) clearTimeout(timer)
181
+ script.onload = null
182
+ script.onerror = null
183
+ }
184
+
185
+ script.onload = () => {
186
+ if (done) return
187
+ cleanup()
188
+ loadingScripts.delete(url)
189
+ loadedScripts.set(url, Promise.resolve(script))
190
+ resolve(script)
191
+ }
192
+
193
+ script.onerror = (err) => {
194
+ if (done) return
195
+ cleanup()
196
+ loadingScripts.delete(url)
197
+ reject(new Error(`[XtMap] 脚本加载失败: ${url}`))
198
+ }
199
+
200
+ if (timeout > 0) {
201
+ timer = setTimeout(() => {
202
+ if (done) return
203
+ cleanup()
204
+ loadingScripts.delete(url)
205
+ reject(new Error(`[XtMap] 脚本加载超时: ${url}`))
206
+ }, timeout)
207
+ }
208
+
209
+ document.head.appendChild(script)
210
+ })
211
+
212
+ loadingScripts.set(url, promise)
213
+ return promise
214
+ }
215
+
216
+ /**
217
+ * 批量加载脚本(按顺序)
218
+ * @param {string[]} urls
219
+ * @param {object} options
220
+ */
221
+ const loadScripts = async (urls, options = {}) => {
222
+ for (const url of urls) {
223
+ await loadScript(url, options)
224
+ }
225
+ }
226
+
227
+ /**
228
+ * 清除加载缓存(切换密钥等场景使用)
229
+ */
230
+ const clearScriptCache = () => {
231
+ loadedScripts.clear()
232
+ loadingScripts.clear()
233
+ }
234
+
235
+ /**
236
+ * 检查全局对象是否存在
237
+ */
238
+ const hasGlobal = (name) => {
239
+ if (typeof window === 'undefined') return false
240
+ return window[name] !== undefined
241
+ }
242
+
243
+ /* harmony default export */ var script_loader = ({
244
+ loadScript,
245
+ loadScripts,
246
+ clearScriptCache,
247
+ hasGlobal
248
+ });
249
+
250
+ // CONCATENATED MODULE: ./src/components/xt-map/adapters/base.js
251
+ /**
252
+ * 地图适配器基类
253
+ * 定义统一的 API 接口,各地图引擎(高德/天地图/百度)通过继承/实现该接口完成适配
254
+ *
255
+ * 统一坐标系统:WGS84 (lng, lat) 作为输入输出标准,各适配器内部处理转换
256
+ * 统一地图类型:standard | satellite | hybrid | traffic
257
+ * 统一主题:light | dark
258
+ */
259
+
260
+
261
+
262
+ // 地图类型 -> 内部常量(各适配器可覆盖转换)
263
+ const DEFAULT_MAP_TYPE_MAP = {
264
+ standard: 'standard',
265
+ satellite: 'satellite',
266
+ hybrid: 'hybrid',
267
+ traffic: 'traffic'
268
+ }
269
+
270
+ class base_MapAdapterBase {
271
+ constructor(container, options = {}) {
272
+ this.container = container
273
+ this.options = options
274
+ this.mapInstance = null
275
+ this.mapType = options.mapType || 'standard'
276
+ this.theme = options.theme || 'light'
277
+ this.center = options.center || [116.397428, 39.90923]
278
+ this.zoom = options.zoom || 11
279
+ this.apiKey = options.apiKey || ''
280
+ this.apiUrl = options.apiUrl || null
281
+ this.plugins = options.plugins || []
282
+ this.eventHandlers = new Map()
283
+ this.ready = false
284
+ this._mapTypeMap = { ...DEFAULT_MAP_TYPE_MAP }
285
+ }
286
+
287
+ /**
288
+ * 获取 SDK 脚本 URL(各适配器必须实现)
289
+ * @returns {string}
290
+ */
291
+ getScriptUrl() {
292
+ throw new Error('[XtMap] 子类必须实现 getScriptUrl()')
293
+ }
294
+
295
+ /**
296
+ * 检查 SDK 是否已加载
297
+ */
298
+ isSdkLoaded() {
299
+ throw new Error('[XtMap] 子类必须实现 isSdkLoaded()')
300
+ }
301
+
302
+ /**
303
+ * 在脚本加载前执行(可选覆盖)
304
+ * 用于设置 securityJsCode、注册全局 callback 等前置准备
305
+ */
306
+ beforeLoadScript() {
307
+ // 可选实现 - 各适配器可覆盖
308
+ }
309
+
310
+ /**
311
+ * 创建地图实例(各适配器必须实现)
312
+ */
313
+ async createMap() {
314
+ throw new Error('[XtMap] 子类必须实现 createMap()')
315
+ }
316
+
317
+ /**
318
+ * 加载 SDK 并初始化地图
319
+ */
320
+ async init() {
321
+ if (!this.container) {
322
+ throw new Error('[XtMap] 缺少容器元素')
323
+ }
324
+
325
+ if (!this.isSdkLoaded()) {
326
+ // 1. 脚本加载前执行钩子(设置安全密钥等)
327
+ this.beforeLoadScript()
328
+
329
+ // 2. 获取脚本 URL
330
+ const url = this.getScriptUrl()
331
+ if (!url) {
332
+ throw new Error('[XtMap] 缺少 API URL,请配置 apiKey 或 apiUrl')
333
+ }
334
+
335
+ // 3. 动态加载脚本
336
+ await loadScript(url)
337
+
338
+ // 4. 等待 SDK 初始化全局对象(部分 SDK 需要等待 callback 或脚本内部初始化完成)
339
+ await this._waitForSdkReady()
340
+ }
341
+
342
+ // 5. 创建地图实例
343
+ await this.createMap()
344
+ this.ready = true
345
+ return this.mapInstance
346
+ }
347
+
348
+ /**
349
+ * 等待 SDK 准备好(部分地图 SDK 需要等待 callback 执行)
350
+ */
351
+ async _waitForSdkReady() {
352
+ return new Promise((resolve) => {
353
+ let attempts = 0
354
+ const maxAttempts = 100
355
+ const check = () => {
356
+ if (this.isSdkLoaded() || attempts >= maxAttempts) {
357
+ resolve()
358
+ } else {
359
+ attempts++
360
+ setTimeout(check, 100)
361
+ }
362
+ }
363
+ check()
364
+ })
365
+ }
366
+
367
+ /**
368
+ * 统一地图类型转换:xt-map 枚举 -> 引擎内部值
369
+ */
370
+ getNativeMapType(xtType) {
371
+ return this._mapTypeMap[xtType] || this._mapTypeMap.standard
372
+ }
373
+
374
+ /**
375
+ * 设置地图类型
376
+ */
377
+ setMapType(type) {
378
+ this.mapType = type
379
+ if (this.ready && this.mapInstance) {
380
+ this._applyMapType(type)
381
+ }
382
+ }
383
+
384
+ /**
385
+ * 应用地图类型到引擎(各适配器实现)
386
+ */
387
+ _applyMapType(type) {
388
+ // 可选实现
389
+ }
390
+
391
+ /**
392
+ * 设置主题
393
+ */
394
+ setTheme(theme) {
395
+ this.theme = theme
396
+ if (this.ready && this.mapInstance) {
397
+ this._applyTheme(theme)
398
+ }
399
+ }
400
+
401
+ /**
402
+ * 应用主题到引擎(各适配器实现)
403
+ */
404
+ _applyTheme(theme) {
405
+ // 可选实现
406
+ }
407
+
408
+ /**
409
+ * 设置中心坐标 [lng, lat]
410
+ */
411
+ setCenter(center) {
412
+ this.center = center
413
+ if (this.ready && this.mapInstance) {
414
+ this._applyCenter(center)
415
+ }
416
+ }
417
+
418
+ _applyCenter(center) {
419
+ // 各适配器实现
420
+ }
421
+
422
+ /**
423
+ * 设置缩放级别
424
+ */
425
+ setZoom(zoom) {
426
+ this.zoom = zoom
427
+ if (this.ready && this.mapInstance) {
428
+ this._applyZoom(zoom)
429
+ }
430
+ }
431
+
432
+ _applyZoom(zoom) {
433
+ // 各适配器实现
434
+ }
435
+
436
+ /**
437
+ * 获取当前中心坐标
438
+ */
439
+ getCenter() {
440
+ return this.center
441
+ }
442
+
443
+ /**
444
+ * 获取当前缩放级别
445
+ */
446
+ getZoom() {
447
+ return this.zoom
448
+ }
449
+
450
+ /**
451
+ * 获取原始地图实例(用于高级自定义操作)
452
+ */
453
+ getNativeMap() {
454
+ return this.mapInstance
455
+ }
456
+
457
+ /**
458
+ * 绑定事件(统一事件名:click, moveend, zoomend, ready 等)
459
+ */
460
+ on(eventName, handler) {
461
+ if (typeof handler !== 'function') return
462
+ this.eventHandlers.set(eventName, handler)
463
+ if (this.ready && this.mapInstance) {
464
+ this._bindEvent(eventName, handler)
465
+ }
466
+ }
467
+
468
+ _bindEvent(eventName, handler) {
469
+ // 各适配器实现具体事件绑定
470
+ }
471
+
472
+ /**
473
+ * 解绑事件
474
+ */
475
+ off(eventName) {
476
+ const handler = this.eventHandlers.get(eventName)
477
+ if (handler && this.ready && this.mapInstance) {
478
+ this._unbindEvent(eventName, handler)
479
+ }
480
+ this.eventHandlers.delete(eventName)
481
+ }
482
+
483
+ _unbindEvent(eventName, handler) {
484
+ // 各适配器实现
485
+ }
486
+
487
+ /**
488
+ * 调整地图大小(容器尺寸变化后调用)
489
+ */
490
+ resize() {
491
+ if (this.ready && this.mapInstance) {
492
+ this._applyResize()
493
+ }
494
+ }
495
+
496
+ _applyResize() {
497
+ // 各适配器实现
498
+ }
499
+
500
+ /**
501
+ * 销毁地图
502
+ */
503
+ destroy() {
504
+ this.eventHandlers.clear()
505
+ if (this.mapInstance && typeof this.mapInstance.destroy === 'function') {
506
+ try {
507
+ this.mapInstance.destroy()
508
+ } catch (e) {
509
+ // 忽略销毁错误
510
+ }
511
+ }
512
+ this.mapInstance = null
513
+ this.ready = false
514
+ }
515
+ }
516
+
517
+ /* harmony default export */ var base = (base_MapAdapterBase);
518
+
519
+ // CONCATENATED MODULE: ./src/components/xt-map/adapters/amap.js
520
+ /**
521
+ * 高德地图适配器 (AMap)
522
+ * 以高德为基准,所有 xt-map 枚举直接映射
523
+ */
524
+
525
+
526
+
527
+
528
+ const A_MAP_MAP_TYPES = {
529
+ standard: 'amap', // 标准/矢量
530
+ satellite: 'satellite', // 卫星
531
+ hybrid: 'satellite', // 混合(卫星+路网,用卫星+路网图层组合实现)
532
+ traffic: 'traffic' // 实时路况(叠加在 standard 上)
533
+ }
534
+
535
+ // 高德地图样式 ID(主题映射)
536
+ const A_MAP_STYLES = {
537
+ light: 'amap://styles/normal',
538
+ dark: 'amap://styles/dark'
539
+ }
540
+
541
+ class amap_AMapAdapter extends base_MapAdapterBase {
542
+ constructor(container, options = {}) {
543
+ super(container, options)
544
+ this._mapTypeMap = { ...A_MAP_MAP_TYPES }
545
+ this._trafficLayer = null // 路况图层引用
546
+ this._satelliteLayer = null // 卫星图层
547
+ this._roadnetLayer = null // 路网图层(用于 hybrid)
548
+ this._currentLayers = [] // 当前叠加图层
549
+ }
550
+
551
+ getScriptUrl() {
552
+ if (this.apiUrl) return this.apiUrl
553
+ if (!this.apiKey) {
554
+ console.warn('[XtMap] 高德地图需要配置 apiKey')
555
+ return ''
556
+ }
557
+ // 高德 2.0 Web API
558
+ return `https://webapi.amap.com/maps?v=2.0&key=${encodeURIComponent(this.apiKey)}&plugin=AMap.Scale,AMap.ToolBar`
559
+ }
560
+
561
+ /**
562
+ * 脚本加载前设置高德 2.0 安全密钥
563
+ */
564
+ beforeLoadScript() {
565
+ const securityJsCode = this.options.securityJsCode || (typeof window !== 'undefined' && window._AMapSecurityConfig && window._AMapSecurityConfig.securityJsCode) || ''
566
+ if (securityJsCode && typeof window !== 'undefined') {
567
+ window._AMapSecurityConfig = {
568
+ securityJsCode: securityJsCode
569
+ }
570
+ }
571
+ }
572
+
573
+ isSdkLoaded() {
574
+ return hasGlobal('AMap') && typeof window.AMap === 'function'
575
+ }
576
+
577
+ async createMap() {
578
+ const AMap = window.AMap
579
+ if (!AMap) throw new Error('[XtMap] 高德地图 SDK 未加载')
580
+
581
+ const mapOptions = {
582
+ center: this.center,
583
+ zoom: this.zoom,
584
+ mapStyle: A_MAP_STYLES[this.theme] || A_MAP_STYLES.light,
585
+ viewMode: '2D',
586
+ resizeEnable: true
587
+ }
588
+
589
+ this.mapInstance = new AMap.Map(this.container, mapOptions)
590
+
591
+ // 应用地图类型
592
+ this._applyMapType(this.mapType)
593
+
594
+ // 绑定事件(延迟到地图就绪后)
595
+ await new Promise((resolve) => {
596
+ this.mapInstance.on('complete', () => resolve())
597
+ // 兜底:1秒后强制 resolve
598
+ setTimeout(resolve, 1500)
599
+ })
600
+
601
+ // 重新绑定已注册事件
602
+ for (const [eventName, handler] of this.eventHandlers.entries()) {
603
+ this._bindEvent(eventName, handler)
604
+ }
605
+ }
606
+
607
+ _applyMapType(type) {
608
+ if (!this.mapInstance) return
609
+ const AMap = window.AMap
610
+ if (!AMap) return
611
+
612
+ // 清除所有叠加图层
613
+ this._clearLayers()
614
+
615
+ try {
616
+ // 设置底图样式
617
+ this.mapInstance.setMapStyle(A_MAP_STYLES[this.theme] || A_MAP_STYLES.light)
618
+
619
+ if (type === 'satellite') {
620
+ this._satelliteLayer = new AMap.TileLayer.Satellite()
621
+ this.mapInstance.add(this._satelliteLayer)
622
+ this._currentLayers.push(this._satelliteLayer)
623
+ } else if (type === 'hybrid') {
624
+ // 卫星 + 路网
625
+ this._satelliteLayer = new AMap.TileLayer.Satellite()
626
+ this._roadnetLayer = new AMap.TileLayer.RoadNet()
627
+ this.mapInstance.add([this._satelliteLayer, this._roadnetLayer])
628
+ this._currentLayers.push(this._satelliteLayer, this._roadnetLayer)
629
+ } else if (type === 'traffic') {
630
+ // 路况图层叠加在 standard 上
631
+ this._trafficLayer = new AMap.TileLayer.Traffic({
632
+ autoRefresh: true,
633
+ interval: 180
634
+ })
635
+ this.mapInstance.add(this._trafficLayer)
636
+ this._currentLayers.push(this._trafficLayer)
637
+ }
638
+ } catch (e) {
639
+ console.warn('[XtMap] 设置地图类型失败:', e)
640
+ }
641
+ }
642
+
643
+ _clearLayers() {
644
+ if (!this.mapInstance) return
645
+ try {
646
+ if (this._currentLayers.length > 0) {
647
+ this.mapInstance.remove(this._currentLayers)
648
+ }
649
+ } catch (e) {
650
+ // 忽略
651
+ }
652
+ this._currentLayers = []
653
+ this._trafficLayer = null
654
+ this._satelliteLayer = null
655
+ this._roadnetLayer = null
656
+ }
657
+
658
+ _applyTheme(theme) {
659
+ if (!this.mapInstance) return
660
+ try {
661
+ this.mapInstance.setMapStyle(A_MAP_STYLES[theme] || A_MAP_STYLES.light)
662
+ // 主题变更可能影响图层显示,重新应用地图类型
663
+ this._applyMapType(this.mapType)
664
+ } catch (e) {
665
+ console.warn('[XtMap] 设置主题失败:', e)
666
+ }
667
+ }
668
+
669
+ _applyCenter(center) {
670
+ if (!this.mapInstance) return
671
+ try {
672
+ this.mapInstance.setCenter(center)
673
+ } catch (e) {
674
+ // 忽略
675
+ }
676
+ }
677
+
678
+ _applyZoom(zoom) {
679
+ if (!this.mapInstance) return
680
+ try {
681
+ this.mapInstance.setZoom(zoom)
682
+ } catch (e) {
683
+ // 忽略
684
+ }
685
+ }
686
+
687
+ getCenter() {
688
+ if (this.mapInstance && this.mapInstance.getCenter) {
689
+ const c = this.mapInstance.getCenter()
690
+ return [c.lng, c.lat]
691
+ }
692
+ return this.center
693
+ }
694
+
695
+ getZoom() {
696
+ if (this.mapInstance && this.mapInstance.getZoom) {
697
+ return this.mapInstance.getZoom()
698
+ }
699
+ return this.zoom
700
+ }
701
+
702
+ _bindEvent(eventName, handler) {
703
+ if (!this.mapInstance) return
704
+ try {
705
+ // 统一事件名映射
706
+ const eventMap = {
707
+ click: 'click',
708
+ moveend: 'moveend',
709
+ zoomend: 'zoomend',
710
+ zoomchange: 'zoomchange',
711
+ mapmove: 'mapmove',
712
+ complete: 'complete',
713
+ resize: 'resize'
714
+ }
715
+ const nativeEvent = eventMap[eventName] || eventName
716
+ this.mapInstance.on(nativeEvent, (e) => {
717
+ // 统一事件参数格式
718
+ const normalized = {
719
+ originalEvent: e,
720
+ lnglat: e && e.lnglat ? [e.lnglat.lng, e.lnglat.lat] : null
721
+ }
722
+ handler(normalized)
723
+ })
724
+ } catch (err) {
725
+ console.warn('[XtMap] 事件绑定失败:', eventName, err)
726
+ }
727
+ }
728
+
729
+ _unbindEvent(eventName, handler) {
730
+ if (!this.mapInstance) return
731
+ try {
732
+ this.mapInstance.off(eventName, handler)
733
+ } catch (e) {
734
+ // 忽略
735
+ }
736
+ }
737
+
738
+ _applyResize() {
739
+ if (this.mapInstance && this.mapInstance.resize) {
740
+ try {
741
+ this.mapInstance.resize()
742
+ } catch (e) {
743
+ // 忽略
744
+ }
745
+ }
746
+ }
747
+
748
+ destroy() {
749
+ this._clearLayers()
750
+ super.destroy()
751
+ }
752
+ }
753
+
754
+ /* harmony default export */ var amap = (amap_AMapAdapter);
755
+
756
+ // CONCATENATED MODULE: ./src/components/xt-map/adapters/tianditu.js
757
+ /**
758
+ * 天地图适配器 (Tianditu)
759
+ * 天地图使用 WMTS 切片服务,不支持原生主题切换,
760
+ * dark/light 通过图层样式参数模拟(部分图层可调整色调)
761
+ */
762
+
763
+
764
+
765
+
766
+ // 天地图地图类型映射
767
+ const TIANDITU_MAP_TYPES = {
768
+ standard: 'vec', // 矢量地图
769
+ satellite: 'img', // 影像地图
770
+ hybrid: 'img', // 混合(影像 + 注记)
771
+ traffic: 'vec' // 天地图不支持原生路况,降级为矢量
772
+ }
773
+
774
+ // 天地图主题色模拟:通过调整图层透明度/色调CSS滤镜
775
+ const TIANDITU_THEME_FILTER = {
776
+ light: 'none',
777
+ dark: 'invert(1) hue-rotate(180deg) saturate(1.2) brightness(0.95)'
778
+ }
779
+
780
+ class tianditu_TiandituAdapter extends base_MapAdapterBase {
781
+ constructor(container, options = {}) {
782
+ super(container, options)
783
+ this._mapTypeMap = { ...TIANDITU_MAP_TYPES }
784
+ this._layerType = options.tiandituLayerType || 'vec'
785
+ this._currentLayer = null
786
+ this._annotationLayer = null
787
+ }
788
+
789
+ getScriptUrl() {
790
+ if (this.apiUrl) return this.apiUrl
791
+ if (!this.apiKey) {
792
+ console.warn('[XtMap] 天地图需要配置 apiKey (tk)')
793
+ return ''
794
+ }
795
+ return `https://api.tianditu.gov.cn/api?v=4.0&tk=${encodeURIComponent(this.apiKey)}`
796
+ }
797
+
798
+ isSdkLoaded() {
799
+ return hasGlobal('T') && typeof window.T === 'object' && window.T.Map
800
+ }
801
+
802
+ async createMap() {
803
+ const T = window.T
804
+ if (!T || !T.Map) throw new Error('[XtMap] 天地图 SDK 未加载')
805
+
806
+ const mapOptions = {
807
+ center: new T.LngLat(this.center[0], this.center[1]),
808
+ zoom: this.zoom
809
+ }
810
+
811
+ this.mapInstance = new T.Map(this.container, mapOptions)
812
+
813
+ // 应用地图类型
814
+ this._applyMapType(this.mapType)
815
+
816
+ // 应用主题
817
+ this._applyTheme(this.theme)
818
+
819
+ // 等待地图就绪
820
+ await new Promise((resolve) => {
821
+ setTimeout(resolve, 500)
822
+ })
823
+
824
+ // 绑定事件
825
+ for (const [eventName, handler] of this.eventHandlers.entries()) {
826
+ this._bindEvent(eventName, handler)
827
+ }
828
+ }
829
+
830
+ _applyMapType(type) {
831
+ if (!this.mapInstance) return
832
+ const T = window.T
833
+ if (!T) return
834
+
835
+ try {
836
+ // 天地图通过 switchTo 方法切换图层
837
+ const layerType = this._mapTypeMap[type] || 'vec'
838
+
839
+ if (type === 'standard') {
840
+ // 矢量地图
841
+ this.mapInstance.setMapType(window.TMAP_NORMAL_MAP || 1)
842
+ } else if (type === 'satellite') {
843
+ // 影像地图
844
+ this.mapInstance.setMapType(window.TMAP_SATELLITE_MAP || 2)
845
+ } else if (type === 'hybrid') {
846
+ // 混合(影像+注记)
847
+ this.mapInstance.setMapType(window.TMAP_HYBRID_MAP || 3)
848
+ } else {
849
+ // 路况等特殊类型,天地图无原生支持
850
+ this.mapInstance.setMapType(window.TMAP_NORMAL_MAP || 1)
851
+ }
852
+ } catch (e) {
853
+ console.warn('[XtMap] 天地图切换地图类型失败:', e)
854
+ }
855
+ }
856
+
857
+ _applyTheme(theme) {
858
+ if (!this.container) return
859
+ // 天地图不支持原生 dark 主题,通过 CSS 滤镜模拟
860
+ const filter = TIANDITU_THEME_FILTER[theme] || 'none'
861
+ const imgElements = this.container.querySelectorAll('img')
862
+ imgElements.forEach((img) => {
863
+ img.style.filter = filter
864
+ img.style.webkitFilter = filter
865
+ })
866
+ // 同时设置容器级 CSS 变量,方便样式覆盖
867
+ this.container.setAttribute('data-map-theme', theme)
868
+ // 监听后续新增的 tile 图片(通过 MutationObserver)
869
+ this._setupThemeObserver(theme)
870
+ }
871
+
872
+ _setupThemeObserver(theme) {
873
+ if (this._themeObserver) {
874
+ this._themeObserver.disconnect()
875
+ }
876
+ if (theme !== 'dark') return
877
+ const filter = TIANDITU_THEME_FILTER[theme]
878
+ this._themeObserver = new MutationObserver((mutations) => {
879
+ mutations.forEach((mutation) => {
880
+ mutation.addedNodes.forEach((node) => {
881
+ if (node.nodeType === 1) {
882
+ if (node.tagName === 'IMG') {
883
+ node.style.filter = filter
884
+ node.style.webkitFilter = filter
885
+ } else if (node.querySelectorAll) {
886
+ const imgs = node.querySelectorAll('img')
887
+ imgs.forEach((img) => {
888
+ img.style.filter = filter
889
+ img.style.webkitFilter = filter
890
+ })
891
+ }
892
+ }
893
+ })
894
+ })
895
+ })
896
+ try {
897
+ this._themeObserver.observe(this.container, {
898
+ childList: true,
899
+ subtree: true
900
+ })
901
+ } catch (e) {
902
+ // 忽略
903
+ }
904
+ }
905
+
906
+ _applyCenter(center) {
907
+ if (!this.mapInstance || !window.T) return
908
+ try {
909
+ this.mapInstance.centerAndZoom(new window.T.LngLat(center[0], center[1]), this.zoom)
910
+ } catch (e) {
911
+ // 忽略
912
+ }
913
+ }
914
+
915
+ _applyZoom(zoom) {
916
+ if (!this.mapInstance) return
917
+ try {
918
+ this.mapInstance.setZoom(zoom)
919
+ } catch (e) {
920
+ // 忽略
921
+ }
922
+ }
923
+
924
+ getCenter() {
925
+ if (this.mapInstance && this.mapInstance.getCenter) {
926
+ const c = this.mapInstance.getCenter()
927
+ if (c && c.getLng !== undefined) {
928
+ return [c.getLng(), c.getLat()]
929
+ }
930
+ }
931
+ return this.center
932
+ }
933
+
934
+ getZoom() {
935
+ if (this.mapInstance && this.mapInstance.getZoom) {
936
+ return this.mapInstance.getZoom()
937
+ }
938
+ return this.zoom
939
+ }
940
+
941
+ _bindEvent(eventName, handler) {
942
+ if (!this.mapInstance) return
943
+ try {
944
+ const eventMap = {
945
+ click: 'click',
946
+ moveend: 'moveend',
947
+ zoomend: 'zoomend',
948
+ zoomchange: 'zoomend'
949
+ }
950
+ const nativeEvent = eventMap[eventName] || eventName
951
+ this.mapInstance.addEventListener(nativeEvent, (e) => {
952
+ const normalized = {
953
+ originalEvent: e,
954
+ lnglat: e && e.lnglat ? [e.lnglat.getLng(), e.lnglat.getLat()] : null
955
+ }
956
+ handler(normalized)
957
+ })
958
+ } catch (err) {
959
+ console.warn('[XtMap] 天地图事件绑定失败:', eventName, err)
960
+ }
961
+ }
962
+
963
+ _unbindEvent(eventName, handler) {
964
+ if (!this.mapInstance) return
965
+ try {
966
+ this.mapInstance.removeEventListener(eventName, handler)
967
+ } catch (e) {
968
+ // 忽略
969
+ }
970
+ }
971
+
972
+ _applyResize() {
973
+ if (this.mapInstance && this.mapInstance.checkResize) {
974
+ try {
975
+ this.mapInstance.checkResize()
976
+ } catch (e) {
977
+ // 忽略
978
+ }
979
+ }
980
+ }
981
+
982
+ destroy() {
983
+ if (this._themeObserver) {
984
+ this._themeObserver.disconnect()
985
+ this._themeObserver = null
986
+ }
987
+ if (this.mapInstance && typeof this.mapInstance.clearOverLays === 'function') {
988
+ try {
989
+ this.mapInstance.clearOverLays()
990
+ } catch (e) {
991
+ // 忽略
992
+ }
993
+ }
994
+ super.destroy()
995
+ }
996
+ }
997
+
998
+ /* harmony default export */ var tianditu = (tianditu_TiandituAdapter);
999
+
1000
+ // CONCATENATED MODULE: ./src/components/xt-map/adapters/baidu.js
1001
+ /**
1002
+ * 百度地图适配器 (BMap / Baidu)
1003
+ * 百度地图 JS API 3.0 支持自定义样式
1004
+ */
1005
+
1006
+
1007
+
1008
+
1009
+ // 百度地图类型映射
1010
+ const BAIDU_MAP_TYPES = {
1011
+ standard: 'BMAP_NORMAL_MAP',
1012
+ satellite: 'BMAP_SATELLITE_MAP',
1013
+ hybrid: 'BMAP_HYBRID_MAP',
1014
+ traffic: 'BMAP_NORMAL_MAP' // 路况通过图层叠加
1015
+ }
1016
+
1017
+ // 百度地图自定义样式 ID(主题)
1018
+ // light: 官方 normal 样式
1019
+ // dark: 午夜蓝 dark 样式
1020
+ const BAIDU_STYLES = {
1021
+ light: { style: 'normal' },
1022
+ dark: { style: 'dark' }
1023
+ }
1024
+
1025
+ class baidu_BaiduAdapter extends base_MapAdapterBase {
1026
+ constructor(container, options = {}) {
1027
+ super(container, options)
1028
+ this._mapTypeMap = { ...BAIDU_MAP_TYPES }
1029
+ this._coordType = options.baiduCoordType || 'bd09ll'
1030
+ this._trafficLayer = null
1031
+ this._callbackName = null
1032
+ }
1033
+
1034
+ getScriptUrl() {
1035
+ if (this.apiUrl) return this.apiUrl
1036
+ if (!this.apiKey) {
1037
+ console.warn('[XtMap] 百度地图需要配置 apiKey (ak)')
1038
+ return ''
1039
+ }
1040
+ // 注意:_callbackName 在 beforeLoadScript 中已注册
1041
+ return `https://api.map.baidu.com/api?v=3.0&ak=${encodeURIComponent(this.apiKey)}&callback=${this._callbackName}`
1042
+ }
1043
+
1044
+ /**
1045
+ * 脚本加载前注册百度 SDK 回调函数
1046
+ */
1047
+ beforeLoadScript() {
1048
+ // 生成唯一 callback 名称,支持多实例
1049
+ this._callbackName = `__xt_map_baidu_${Date.now()}_${Math.floor(Math.random() * 100000)}`
1050
+ // 注册全局 callback(百度地图 SDK 加载完成后调用)
1051
+ if (typeof window !== 'undefined') {
1052
+ window[this._callbackName] = () => {
1053
+ // 空实现,仅用于触发 Promise resolve
1054
+ }
1055
+ }
1056
+ }
1057
+
1058
+ isSdkLoaded() {
1059
+ return hasGlobal('BMap') && typeof window.BMap === 'function'
1060
+ }
1061
+
1062
+ async createMap() {
1063
+ const BMap = window.BMap
1064
+ if (!BMap) throw new Error('[XtMap] 百度地图 SDK 未加载')
1065
+
1066
+ const mapOptions = {
1067
+ enableMapClick: false
1068
+ }
1069
+
1070
+ this.mapInstance = new BMap.Map(this.container, mapOptions)
1071
+ this.mapInstance.centerAndZoom(new BMap.Point(this.center[0], this.center[1]), this.zoom)
1072
+ this.mapInstance.enableScrollWheelZoom(true)
1073
+
1074
+ // 应用地图类型
1075
+ this._applyMapType(this.mapType)
1076
+
1077
+ // 应用主题
1078
+ this._applyTheme(this.theme)
1079
+
1080
+ // 等待地图就绪
1081
+ await new Promise((resolve) => setTimeout(resolve, 500))
1082
+
1083
+ for (const [eventName, handler] of this.eventHandlers.entries()) {
1084
+ this._bindEvent(eventName, handler)
1085
+ }
1086
+ }
1087
+
1088
+ _applyMapType(type) {
1089
+ if (!this.mapInstance || !window.BMap) return
1090
+
1091
+ try {
1092
+ // 清除路况图层
1093
+ if (this._trafficLayer) {
1094
+ try {
1095
+ this.mapInstance.removeTileLayer(this._trafficLayer)
1096
+ } catch (e) {}
1097
+ this._trafficLayer = null
1098
+ }
1099
+
1100
+ if (type === 'satellite') {
1101
+ this.mapInstance.setMapType(window.BMAP_SATELLITE_MAP || 1)
1102
+ } else if (type === 'hybrid') {
1103
+ this.mapInstance.setMapType(window.BMAP_HYBRID_MAP || 2)
1104
+ } else if (type === 'traffic') {
1105
+ this.mapInstance.setMapType(window.BMAP_NORMAL_MAP || 0)
1106
+ // 叠加路况图层
1107
+ try {
1108
+ const BMap = window.BMap
1109
+ this._trafficLayer = new BMap.TrafficLayer()
1110
+ this.mapInstance.addTileLayer(this._trafficLayer)
1111
+ } catch (e) {
1112
+ console.warn('[XtMap] 百度地图加载路况图层失败:', e)
1113
+ }
1114
+ } else {
1115
+ this.mapInstance.setMapType(window.BMAP_NORMAL_MAP || 0)
1116
+ }
1117
+ } catch (e) {
1118
+ console.warn('[XtMap] 百度地图切换地图类型失败:', e)
1119
+ }
1120
+ }
1121
+
1122
+ _applyTheme(theme) {
1123
+ if (!this.mapInstance || !window.BMap) return
1124
+ try {
1125
+ // 百度 3.0 通过 setMapStyle 设置主题样式
1126
+ const styleConfig = BAIDU_STYLES[theme] || BAIDU_STYLES.light
1127
+ if (this.mapInstance.setMapStyleV2) {
1128
+ // 新版 API
1129
+ this.mapInstance.setMapStyleV2({ styleId: styleConfig.style === 'dark' ? 'midnight' : '' })
1130
+ } else if (this.mapInstance.setMapStyle) {
1131
+ // 旧版 API
1132
+ const styleJson = theme === 'dark' ? this._getDarkStyleJson() : null
1133
+ if (styleJson) {
1134
+ this.mapInstance.setMapStyle({ styleJson: styleJson })
1135
+ }
1136
+ }
1137
+ } catch (e) {
1138
+ console.warn('[XtMap] 百度地图设置主题失败:', e)
1139
+ }
1140
+ }
1141
+
1142
+ /**
1143
+ * 简易百度地图 dark 样式 JSON 配置
1144
+ */
1145
+ _getDarkStyleJson() {
1146
+ return [
1147
+ { featureType: 'land', elementType: 'geometry', stylers: { color: '#1a1a1a' } },
1148
+ { featureType: 'water', elementType: 'geometry', stylers: { color: '#0a1a2a' } },
1149
+ { featureType: 'green', elementType: 'geometry', stylers: { color: '#0a2a1a' } },
1150
+ { featureType: 'building', elementType: 'geometry', stylers: { color: '#2a2a2a' } },
1151
+ { featureType: 'highway', elementType: 'geometry', stylers: { color: '#3a3a3a' } },
1152
+ { featureType: 'highway', elementType: 'geometry.stroke', stylers: { color: '#4a4a4a' } },
1153
+ { featureType: 'arterial', elementType: 'geometry', stylers: { color: '#333333' } },
1154
+ { featureType: 'arterial', elementType: 'geometry.stroke', stylers: { color: '#3d3d3d' } },
1155
+ { featureType: 'local', elementType: 'geometry', stylers: { color: '#2a2a2a' } },
1156
+ { featureType: 'railway', elementType: 'geometry', stylers: { color: '#3a3a3a' } },
1157
+ { featureType: 'subway', elementType: 'geometry', stylers: { color: '#3a3a3a' } },
1158
+ { featureType: 'boundary', elementType: 'geometry', stylers: { color: '#666666' } },
1159
+ { featureType: 'district', elementType: 'labels.text.fill', stylers: { color: '#888888' } },
1160
+ { featureType: 'poi', elementType: 'labels', stylers: { visibility: 'off' } }
1161
+ ]
1162
+ }
1163
+
1164
+ _applyCenter(center) {
1165
+ if (!this.mapInstance || !window.BMap) return
1166
+ try {
1167
+ this.mapInstance.centerAndZoom(new window.BMap.Point(center[0], center[1]), this.zoom)
1168
+ } catch (e) {
1169
+ // 忽略
1170
+ }
1171
+ }
1172
+
1173
+ _applyZoom(zoom) {
1174
+ if (!this.mapInstance) return
1175
+ try {
1176
+ this.mapInstance.setZoom(zoom)
1177
+ } catch (e) {
1178
+ // 忽略
1179
+ }
1180
+ }
1181
+
1182
+ getCenter() {
1183
+ if (this.mapInstance && this.mapInstance.getCenter) {
1184
+ const c = this.mapInstance.getCenter()
1185
+ if (c) return [c.lng, c.lat]
1186
+ }
1187
+ return this.center
1188
+ }
1189
+
1190
+ getZoom() {
1191
+ if (this.mapInstance && this.mapInstance.getZoom) {
1192
+ return this.mapInstance.getZoom()
1193
+ }
1194
+ return this.zoom
1195
+ }
1196
+
1197
+ _bindEvent(eventName, handler) {
1198
+ if (!this.mapInstance) return
1199
+ try {
1200
+ const eventMap = {
1201
+ click: 'click',
1202
+ moveend: 'moveend',
1203
+ zoomend: 'zoomend',
1204
+ zoomchange: 'zoomend',
1205
+ mapmove: 'movestart'
1206
+ }
1207
+ const nativeEvent = eventMap[eventName] || eventName
1208
+ this.mapInstance.addEventListener(nativeEvent, (e) => {
1209
+ const normalized = {
1210
+ originalEvent: e,
1211
+ lnglat: e && e.point ? [e.point.lng, e.point.lat] : null
1212
+ }
1213
+ handler(normalized)
1214
+ })
1215
+ } catch (err) {
1216
+ console.warn('[XtMap] 百度地图事件绑定失败:', eventName, err)
1217
+ }
1218
+ }
1219
+
1220
+ _unbindEvent(eventName, handler) {
1221
+ if (!this.mapInstance) return
1222
+ try {
1223
+ this.mapInstance.removeEventListener(eventName, handler)
1224
+ } catch (e) {
1225
+ // 忽略
1226
+ }
1227
+ }
1228
+
1229
+ _applyResize() {
1230
+ if (this.mapInstance && this.mapInstance.enableResize) {
1231
+ try {
1232
+ // 百度地图默认启用 resize,无需手动调用
1233
+ if (typeof this.mapInstance.checkResize === 'function') {
1234
+ this.mapInstance.checkResize()
1235
+ }
1236
+ } catch (e) {
1237
+ // 忽略
1238
+ }
1239
+ }
1240
+ }
1241
+
1242
+ destroy() {
1243
+ if (this._callbackName && typeof window !== 'undefined') {
1244
+ try {
1245
+ delete window[this._callbackName]
1246
+ } catch (e) {
1247
+ // 忽略
1248
+ }
1249
+ }
1250
+ super.destroy()
1251
+ }
1252
+ }
1253
+
1254
+ /* harmony default export */ var baidu = (baidu_BaiduAdapter);
1255
+
1256
+ // CONCATENATED MODULE: ./src/components/xt-map/adapters/index.js
1257
+ /**
1258
+ * 地图适配器索引
1259
+ * 根据 provider 字符串返回对应的适配器构造函数
1260
+ */
1261
+
1262
+
1263
+
1264
+
1265
+
1266
+ const adapters = {
1267
+ amap: amap_AMapAdapter,
1268
+ tianditu: tianditu_TiandituAdapter,
1269
+ baidu: baidu_BaiduAdapter
1270
+ }
1271
+
1272
+ const getAdapterClass = (provider) => {
1273
+ return adapters[provider] || amap_AMapAdapter
1274
+ }
1275
+
1276
+
1277
+
1278
+
1279
+ /* harmony default export */ var xt_map_adapters = ({
1280
+ adapters,
1281
+ getAdapterClass,
1282
+ AMapAdapter: amap_AMapAdapter,
1283
+ TiandituAdapter: tianditu_TiandituAdapter,
1284
+ BaiduAdapter: baidu_BaiduAdapter
1285
+ });
1286
+
1287
+ // CONCATENATED MODULE: ./src/components/xt-map/config/xt-map-config.js
1288
+ /**
1289
+ * XtMap 全局配置管理
1290
+ * 支持通过 Vue.use 配置或运行时动态设置地图提供商、密钥、URL、主题等
1291
+ */
1292
+
1293
+ // 支持的地图提供商
1294
+ const MAP_PROVIDERS = ['amap', 'tianditu', 'baidu']
1295
+
1296
+ // 支持的地图类型(统一枚举,各适配器会转成对应引擎的类型)
1297
+ const MAP_TYPES = ['standard', 'satellite', 'hybrid', 'traffic']
1298
+
1299
+ // 支持的主题
1300
+ const MAP_THEMES = ['light', 'dark']
1301
+
1302
+ // 默认配置 - 以高德地图为基准
1303
+ const defaultConfig = {
1304
+ provider: 'amap',
1305
+ apiKey: '',
1306
+ apiUrl: null,
1307
+ mapType: 'standard',
1308
+ theme: 'light',
1309
+ center: [116.397428, 39.90923],
1310
+ zoom: 11,
1311
+ plugins: [],
1312
+ securityJsCode: null,
1313
+ // 天地图专用:图层类型(vec:矢量, img:影像, ter:地形)
1314
+ tiandituLayerType: 'vec',
1315
+ // 百度地图专用:坐标系(bd09ll:百度经纬度, bd09mc:百度墨卡托)
1316
+ baiduCoordType: 'bd09ll'
1317
+ }
1318
+
1319
+ // 当前配置
1320
+ let currentConfig = { ...defaultConfig }
1321
+
1322
+ // 配置变更监听器
1323
+ const configChangeListeners = []
1324
+
1325
+ const emitConfigChange = (key, value) => {
1326
+ configChangeListeners.forEach(listener => {
1327
+ try {
1328
+ listener(key, value)
1329
+ } catch (e) {
1330
+ console.warn('[XtMap] 配置变更监听异常:', e)
1331
+ }
1332
+ })
1333
+ }
1334
+
1335
+ // 获取完整配置
1336
+ const getMapConfig = () => ({ ...currentConfig })
1337
+
1338
+ // 设置完整配置
1339
+ const setMapConfig = (config) => {
1340
+ if (typeof config !== 'object' || config === null) {
1341
+ console.warn('[XtMap] setMapConfig 必须传入对象参数')
1342
+ return
1343
+ }
1344
+
1345
+ if (config.provider !== undefined) setMapProvider(config.provider)
1346
+ if (config.apiKey !== undefined) setMapApiKey(config.apiKey)
1347
+ if (config.apiUrl !== undefined) setMapApiUrl(config.apiUrl)
1348
+ if (config.mapType !== undefined) setMapType(config.mapType)
1349
+ if (config.theme !== undefined) setMapTheme(config.theme)
1350
+ if (config.center !== undefined) setMapCenter(config.center)
1351
+ if (config.zoom !== undefined) setMapZoom(config.zoom)
1352
+ if (config.plugins !== undefined) setMapPlugins(config.plugins)
1353
+ if (config.securityJsCode !== undefined) setSecurityJsCode(config.securityJsCode)
1354
+ }
1355
+
1356
+ const setMapProvider = (provider) => {
1357
+ if (!MAP_PROVIDERS.includes(provider)) {
1358
+ console.warn(`[XtMap] 无效的地图提供商: ${provider},可选: ${MAP_PROVIDERS.join(', ')}`)
1359
+ return
1360
+ }
1361
+ currentConfig.provider = provider
1362
+ emitConfigChange('provider', provider)
1363
+ }
1364
+
1365
+ const setMapApiKey = (key) => {
1366
+ currentConfig.apiKey = key
1367
+ emitConfigChange('apiKey', key)
1368
+ }
1369
+
1370
+ const setMapApiUrl = (url) => {
1371
+ currentConfig.apiUrl = url
1372
+ emitConfigChange('apiUrl', url)
1373
+ }
1374
+
1375
+ const setMapType = (type) => {
1376
+ if (!MAP_TYPES.includes(type)) {
1377
+ console.warn(`[XtMap] 无效的地图类型: ${type},可选: ${MAP_TYPES.join(', ')}`)
1378
+ return
1379
+ }
1380
+ currentConfig.mapType = type
1381
+ emitConfigChange('mapType', type)
1382
+ }
1383
+
1384
+ const setMapTheme = (theme) => {
1385
+ if (!MAP_THEMES.includes(theme)) {
1386
+ console.warn(`[XtMap] 无效的主题: ${theme},可选: ${MAP_THEMES.join(', ')}`)
1387
+ return
1388
+ }
1389
+ currentConfig.theme = theme
1390
+ emitConfigChange('theme', theme)
1391
+ }
1392
+
1393
+ const setMapCenter = (center) => {
1394
+ if (!Array.isArray(center) || center.length !== 2) {
1395
+ console.warn('[XtMap] center 必须是 [lng, lat] 数组')
1396
+ return
1397
+ }
1398
+ currentConfig.center = center
1399
+ emitConfigChange('center', center)
1400
+ }
1401
+
1402
+ const setMapZoom = (zoom) => {
1403
+ const z = Number(zoom)
1404
+ if (isNaN(z)) {
1405
+ console.warn('[XtMap] zoom 必须是数字')
1406
+ return
1407
+ }
1408
+ currentConfig.zoom = z
1409
+ emitConfigChange('zoom', z)
1410
+ }
1411
+
1412
+ const setMapPlugins = (plugins) => {
1413
+ if (!Array.isArray(plugins)) {
1414
+ console.warn('[XtMap] plugins 必须是数组')
1415
+ return
1416
+ }
1417
+ currentConfig.plugins = plugins
1418
+ emitConfigChange('plugins', plugins)
1419
+ }
1420
+
1421
+ const setSecurityJsCode = (code) => {
1422
+ currentConfig.securityJsCode = code
1423
+ // 高德地图安全密钥:设置 window._AMapSecurityConfig
1424
+ if (typeof window !== 'undefined' && code) {
1425
+ window._AMapSecurityConfig = {
1426
+ securityJsCode: code,
1427
+ ...(window._AMapSecurityConfig || {})
1428
+ }
1429
+ }
1430
+ emitConfigChange('securityJsCode', code)
1431
+ }
1432
+
1433
+ // 获取当前配置的快捷方法
1434
+ const getMapProvider = () => currentConfig.provider
1435
+ const getMapApiKey = () => currentConfig.apiKey
1436
+ const getMapApiUrl = () => currentConfig.apiUrl
1437
+ const getMapType = () => currentConfig.mapType
1438
+ const getMapTheme = () => currentConfig.theme
1439
+ const getMapCenter = () => currentConfig.center
1440
+ const getMapZoom = () => currentConfig.zoom
1441
+ const getMapPlugins = () => currentConfig.plugins
1442
+
1443
+ // 监听配置变更
1444
+ const onMapConfigChange = (listener) => {
1445
+ if (typeof listener === 'function') {
1446
+ configChangeListeners.push(listener)
1447
+ return () => {
1448
+ const index = configChangeListeners.indexOf(listener)
1449
+ if (index > -1) configChangeListeners.splice(index, 1)
1450
+ }
1451
+ }
1452
+ }
1453
+
1454
+ // 重置为默认配置
1455
+ const resetMapConfig = () => {
1456
+ setMapConfig(defaultConfig)
1457
+ }
1458
+
1459
+ /* harmony default export */ var xt_map_config = ({
1460
+ MAP_PROVIDERS,
1461
+ MAP_TYPES,
1462
+ MAP_THEMES,
1463
+ getMapConfig,
1464
+ setMapConfig,
1465
+ setMapProvider,
1466
+ setMapApiKey,
1467
+ setMapApiUrl,
1468
+ setMapType,
1469
+ setMapTheme,
1470
+ setMapCenter,
1471
+ setMapZoom,
1472
+ setMapPlugins,
1473
+ setSecurityJsCode,
1474
+ getMapProvider,
1475
+ getMapApiKey,
1476
+ getMapApiUrl,
1477
+ getMapType,
1478
+ getMapTheme,
1479
+ getMapCenter,
1480
+ getMapZoom,
1481
+ getMapPlugins,
1482
+ onMapConfigChange,
1483
+ resetMapConfig
1484
+ });
1485
+
1486
+ // CONCATENATED MODULE: ./node_modules/cache-loader/dist/cjs.js??ref--1-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/xt-map/index.vue?vue&type=script&lang=js
1487
+
1488
+
1489
+
1490
+
1491
+
1492
+ /* harmony default export */ var xt_mapvue_type_script_lang_js = ({
1493
+ name: 'XtMap',
1494
+
1495
+ props: {
1496
+ provider: {
1497
+ type: String,
1498
+ default: '',
1499
+ validator: (val) => val === '' || MAP_PROVIDERS.includes(val)
1500
+ },
1501
+ apiKey: {
1502
+ type: String,
1503
+ default: ''
1504
+ },
1505
+ apiUrl: {
1506
+ type: String,
1507
+ default: ''
1508
+ },
1509
+ mapType: {
1510
+ type: String,
1511
+ default: '',
1512
+ validator: (val) => val === '' || MAP_TYPES.includes(val)
1513
+ },
1514
+ theme: {
1515
+ type: String,
1516
+ default: '',
1517
+ validator: (val) => val === '' || MAP_THEMES.includes(val)
1518
+ },
1519
+ center: {
1520
+ type: Array,
1521
+ default: () => null
1522
+ },
1523
+ zoom: {
1524
+ type: Number,
1525
+ default: null
1526
+ },
1527
+ plugins: {
1528
+ type: Array,
1529
+ default: () => []
1530
+ },
1531
+ width: {
1532
+ type: String,
1533
+ default: '100%'
1534
+ },
1535
+ height: {
1536
+ type: String,
1537
+ default: '400px'
1538
+ },
1539
+ securityJsCode: {
1540
+ type: String,
1541
+ default: ''
1542
+ },
1543
+ tiandituLayerType: {
1544
+ type: String,
1545
+ default: 'vec'
1546
+ },
1547
+ baiduCoordType: {
1548
+ type: String,
1549
+ default: 'bd09ll'
1550
+ }
1551
+ },
1552
+
1553
+ data() {
1554
+ return {
1555
+ loading: true,
1556
+ errorMessage: '',
1557
+ adapter: null,
1558
+ _unsubscribeConfig: null
1559
+ }
1560
+ },
1561
+
1562
+ computed: {
1563
+ mergedProvider() {
1564
+ return this.provider || getMapProvider() || 'amap'
1565
+ },
1566
+ mergedApiKey() {
1567
+ return this.apiKey || getMapApiKey() || ''
1568
+ },
1569
+ mergedApiUrl() {
1570
+ return this.apiUrl || getMapApiUrl() || ''
1571
+ },
1572
+ mergedMapType() {
1573
+ return this.mapType || getMapType() || 'standard'
1574
+ },
1575
+ mergedTheme() {
1576
+ return this.theme || getMapTheme() || 'light'
1577
+ },
1578
+ mergedCenter() {
1579
+ return this.center || getMapCenter() || [116.397428, 39.90923]
1580
+ },
1581
+ mergedZoom() {
1582
+ return this.zoom !== null ? this.zoom : getMapZoom()
1583
+ },
1584
+ mergedSecurityJsCode() {
1585
+ return this.securityJsCode || (getMapConfig().securityJsCode) || ''
1586
+ },
1587
+ mergedPlugins() {
1588
+ return this.plugins.length > 0 ? this.plugins : getMapConfig().plugins || []
1589
+ }
1590
+ },
1591
+
1592
+ watch: {
1593
+ mergedProvider: {
1594
+ handler() {
1595
+ this.$nextTick(() => this.rebuildMap())
1596
+ }
1597
+ },
1598
+ mergedApiKey: {
1599
+ handler() {
1600
+ this.$nextTick(() => this.rebuildMap())
1601
+ }
1602
+ },
1603
+ mergedMapType: {
1604
+ handler(newVal) {
1605
+ if (this.adapter) this.adapter.setMapType(newVal)
1606
+ }
1607
+ },
1608
+ mergedTheme: {
1609
+ handler(newVal) {
1610
+ if (this.adapter) this.adapter.setTheme(newVal)
1611
+ if (this.$refs.mapContainer) {
1612
+ this.$refs.mapContainer.setAttribute('data-theme', newVal)
1613
+ }
1614
+ }
1615
+ },
1616
+ mergedCenter: {
1617
+ handler(newVal) {
1618
+ if (this.adapter) this.adapter.setCenter(newVal)
1619
+ }
1620
+ },
1621
+ mergedZoom: {
1622
+ handler(newVal) {
1623
+ if (this.adapter) this.adapter.setZoom(newVal)
1624
+ }
1625
+ },
1626
+ width: {
1627
+ handler() {
1628
+ this.$nextTick(() => {
1629
+ if (this.adapter) this.adapter.resize()
1630
+ })
1631
+ }
1632
+ },
1633
+ height: {
1634
+ handler() {
1635
+ this.$nextTick(() => {
1636
+ if (this.adapter) this.adapter.resize()
1637
+ })
1638
+ }
1639
+ },
1640
+ securityJsCode: {
1641
+ handler(newVal) {
1642
+ if (newVal) {
1643
+ setSecurityJsCode(newVal)
1644
+ // 高德 2.0:SDK 已加载后再设置 securityJsCode 无效,需要重建地图
1645
+ if (this.mergedProvider === 'amap' && this.adapter && this.adapter.ready) {
1646
+ this.$nextTick(() => this.rebuildMap())
1647
+ }
1648
+ }
1649
+ }
1650
+ }
1651
+ },
1652
+
1653
+ mounted() {
1654
+ // 监听全局配置变更
1655
+ this._unsubscribeConfig = onMapConfigChange((key, value) => {
1656
+ if (!this.provider && (key === 'provider')) this.$nextTick(() => this.rebuildMap())
1657
+ if (!this.apiKey && (key === 'apiKey')) this.$nextTick(() => this.rebuildMap())
1658
+ if (!this.apiUrl && (key === 'apiUrl')) this.$nextTick(() => this.rebuildMap())
1659
+ if (!this.theme && key === 'theme' && this.adapter) this.adapter.setTheme(value)
1660
+ if (!this.mapType && key === 'mapType' && this.adapter) this.adapter.setMapType(value)
1661
+ if (!this.center && key === 'center' && this.adapter) this.adapter.setCenter(value)
1662
+ if (this.zoom === null && key === 'zoom' && this.adapter) this.adapter.setZoom(value)
1663
+ })
1664
+
1665
+ // 设置高德安全密钥
1666
+ if (this.securityJsCode) setSecurityJsCode(this.securityJsCode)
1667
+
1668
+ this.$nextTick(() => this.initMap())
1669
+
1670
+ // 监听窗口尺寸变化
1671
+ this._onWindowResize = () => {
1672
+ if (this.adapter) this.adapter.resize()
1673
+ }
1674
+ if (typeof window !== 'undefined') {
1675
+ window.addEventListener('resize', this._onWindowResize)
1676
+ }
1677
+ },
1678
+
1679
+ beforeDestroy() {
1680
+ this.destroyMap()
1681
+ if (this._unsubscribeConfig) this._unsubscribeConfig()
1682
+ if (this._onWindowResize && typeof window !== 'undefined') {
1683
+ window.removeEventListener('resize', this._onWindowResize)
1684
+ }
1685
+ },
1686
+
1687
+ methods: {
1688
+ async initMap() {
1689
+ const container = this.$refs.mapContainer
1690
+ if (!container) return
1691
+
1692
+ // 设置容器尺寸
1693
+ container.style.width = this.width
1694
+ container.style.height = this.height
1695
+
1696
+ // 设置安全密钥(高德需要)
1697
+ if (this.securityJsCode) setSecurityJsCode(this.securityJsCode)
1698
+
1699
+ this.loading = true
1700
+ this.errorMessage = ''
1701
+
1702
+ const AdapterClass = getAdapterClass(this.mergedProvider)
1703
+
1704
+ this.adapter = new AdapterClass(container, {
1705
+ apiKey: this.mergedApiKey,
1706
+ apiUrl: this.mergedApiUrl,
1707
+ mapType: this.mergedMapType,
1708
+ theme: this.mergedTheme,
1709
+ center: this.mergedCenter,
1710
+ zoom: this.mergedZoom,
1711
+ plugins: this.mergedPlugins,
1712
+ securityJsCode: this.mergedSecurityJsCode,
1713
+ tiandituLayerType: this.tiandituLayerType,
1714
+ baiduCoordType: this.baiduCoordType
1715
+ })
1716
+
1717
+ try {
1718
+ await this.adapter.init()
1719
+ this.loading = false
1720
+
1721
+ // 绑定事件
1722
+ this._bindAdapterEvents()
1723
+
1724
+ // 向父组件发出 ready 事件
1725
+ this.$emit('ready', {
1726
+ provider: this.mergedProvider,
1727
+ map: this.adapter.getNativeMap(),
1728
+ adapter: this.adapter
1729
+ })
1730
+ } catch (err) {
1731
+ this.loading = false
1732
+ this.errorMessage = err.message || '地图初始化失败'
1733
+ this.$emit('error', err)
1734
+ }
1735
+ },
1736
+
1737
+ rebuildMap() {
1738
+ this.destroyMap()
1739
+ // 清理脚本缓存,确保新配置能生效(例如切换密钥后重新加载)
1740
+ if (typeof clearScriptCache === 'function') {
1741
+ clearScriptCache()
1742
+ }
1743
+ this.$nextTick(() => this.initMap())
1744
+ },
1745
+
1746
+ destroyMap() {
1747
+ if (this.adapter) {
1748
+ this.adapter.destroy()
1749
+ this.adapter = null
1750
+ }
1751
+ },
1752
+
1753
+ _bindAdapterEvents() {
1754
+ if (!this.adapter) return
1755
+
1756
+ const events = ['click', 'moveend', 'zoomend', 'zoomchange', 'mapmove']
1757
+ events.forEach((evt) => {
1758
+ this.adapter.on(evt, (data) => {
1759
+ this.$emit(evt, data)
1760
+ })
1761
+ })
1762
+ },
1763
+
1764
+ // 对外暴露的统一 API
1765
+ setCenter(center) {
1766
+ if (this.adapter) this.adapter.setCenter(center)
1767
+ },
1768
+
1769
+ setZoom(zoom) {
1770
+ if (this.adapter) this.adapter.setZoom(zoom)
1771
+ },
1772
+
1773
+ setMapType(type) {
1774
+ if (this.adapter) this.adapter.setMapType(type)
1775
+ },
1776
+
1777
+ setTheme(theme) {
1778
+ if (this.adapter) this.adapter.setTheme(theme)
1779
+ },
1780
+
1781
+ getCenter() {
1782
+ return this.adapter ? this.adapter.getCenter() : this.mergedCenter
1783
+ },
1784
+
1785
+ getZoom() {
1786
+ return this.adapter ? this.adapter.getZoom() : this.mergedZoom
1787
+ },
1788
+
1789
+ getNativeMap() {
1790
+ return this.adapter ? this.adapter.getNativeMap() : null
1791
+ },
1792
+
1793
+ resize() {
1794
+ if (this.adapter) this.adapter.resize()
1795
+ },
1796
+
1797
+ on(eventName, handler) {
1798
+ if (this.adapter) this.adapter.on(eventName, handler)
1799
+ },
1800
+
1801
+ off(eventName) {
1802
+ if (this.adapter) this.adapter.off(eventName)
1803
+ },
1804
+
1805
+ rebuild() {
1806
+ this.rebuildMap()
1807
+ }
1808
+ }
1809
+ });
1810
+
1811
+ // CONCATENATED MODULE: ./src/components/xt-map/index.vue?vue&type=script&lang=js
1812
+ /* harmony default export */ var components_xt_mapvue_type_script_lang_js = (xt_mapvue_type_script_lang_js);
1813
+ // CONCATENATED MODULE: ./node_modules/vue-loader/lib/runtime/componentNormalizer.js
1814
+ /* globals __VUE_SSR_CONTEXT__ */
1815
+
1816
+ // IMPORTANT: Do NOT use ES2015 features in this file (except for modules).
1817
+ // This module is a runtime utility for cleaner component module output and will
1818
+ // be included in the final webpack user bundle.
1819
+
1820
+ function normalizeComponent(
1821
+ scriptExports,
1822
+ render,
1823
+ staticRenderFns,
1824
+ functionalTemplate,
1825
+ injectStyles,
1826
+ scopeId,
1827
+ moduleIdentifier /* server only */,
1828
+ shadowMode /* vue-cli only */
1829
+ ) {
1830
+ // Vue.extend constructor export interop
1831
+ var options =
1832
+ typeof scriptExports === 'function' ? scriptExports.options : scriptExports
1833
+
1834
+ // render functions
1835
+ if (render) {
1836
+ options.render = render
1837
+ options.staticRenderFns = staticRenderFns
1838
+ options._compiled = true
1839
+ }
1840
+
1841
+ // functional template
1842
+ if (functionalTemplate) {
1843
+ options.functional = true
1844
+ }
1845
+
1846
+ // scopedId
1847
+ if (scopeId) {
1848
+ options._scopeId = 'data-v-' + scopeId
1849
+ }
1850
+
1851
+ var hook
1852
+ if (moduleIdentifier) {
1853
+ // server build
1854
+ hook = function (context) {
1855
+ // 2.3 injection
1856
+ context =
1857
+ context || // cached call
1858
+ (this.$vnode && this.$vnode.ssrContext) || // stateful
1859
+ (this.parent && this.parent.$vnode && this.parent.$vnode.ssrContext) // functional
1860
+ // 2.2 with runInNewContext: true
1861
+ if (!context && typeof __VUE_SSR_CONTEXT__ !== 'undefined') {
1862
+ context = __VUE_SSR_CONTEXT__
1863
+ }
1864
+ // inject component styles
1865
+ if (injectStyles) {
1866
+ injectStyles.call(this, context)
1867
+ }
1868
+ // register component module identifier for async chunk inferrence
1869
+ if (context && context._registeredComponents) {
1870
+ context._registeredComponents.add(moduleIdentifier)
1871
+ }
1872
+ }
1873
+ // used by ssr in case component is cached and beforeCreate
1874
+ // never gets called
1875
+ options._ssrRegister = hook
1876
+ } else if (injectStyles) {
1877
+ hook = shadowMode
1878
+ ? function () {
1879
+ injectStyles.call(
1880
+ this,
1881
+ (options.functional ? this.parent : this).$root.$options.shadowRoot
1882
+ )
1883
+ }
1884
+ : injectStyles
1885
+ }
1886
+
1887
+ if (hook) {
1888
+ if (options.functional) {
1889
+ // for template-only hot-reload because in that case the render fn doesn't
1890
+ // go through the normalizer
1891
+ options._injectStyles = hook
1892
+ // register for functional component in vue file
1893
+ var originalRender = options.render
1894
+ options.render = function renderWithStyleInjection(h, context) {
1895
+ hook.call(context)
1896
+ return originalRender(h, context)
1897
+ }
1898
+ } else {
1899
+ // inject component registration as beforeCreate hook
1900
+ var existing = options.beforeCreate
1901
+ options.beforeCreate = existing ? [].concat(existing, hook) : [hook]
1902
+ }
1903
+ }
1904
+
1905
+ return {
1906
+ exports: scriptExports,
1907
+ options: options
1908
+ }
1909
+ }
1910
+
1911
+ // CONCATENATED MODULE: ./src/components/xt-map/index.vue
1912
+
1913
+
1914
+
1915
+
1916
+
1917
+ /* normalize component */
1918
+
1919
+ var component = normalizeComponent(
1920
+ components_xt_mapvue_type_script_lang_js,
1921
+ render,
1922
+ staticRenderFns,
1923
+ false,
1924
+ null,
1925
+ null,
1926
+ null
1927
+
1928
+ )
1929
+
1930
+ /* harmony default export */ var xt_map = (component.exports);
1931
+ // CONCATENATED MODULE: ./src/components/xt-map/index.js
1932
+
1933
+
1934
+
1935
+ xt_map.install = function (Vue) {
1936
+ Vue.component(xt_map.name, xt_map)
1937
+ }
1938
+
1939
+ /* harmony default export */ var components_xt_map = (xt_map);
1940
+
1941
+
1942
+ // CONCATENATED MODULE: ./node_modules/@vue/cli-service/lib/commands/build/entry-lib.js
1943
+
1944
+
1945
+ /* harmony default export */ var entry_lib = __webpack_exports__["default"] = (components_xt_map);
1946
+
1947
+
1948
+
1949
+ /***/ })
1950
+
1951
+ /******/ });