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