web-component-gallery 1.2.4 → 1.2.6

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.
package/dist/amap.umd.js CHANGED
@@ -8714,7 +8714,7 @@ eval("/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source cod
8714
8714
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
8715
8715
 
8716
8716
  "use strict";
8717
- eval("__webpack_require__.a(module, async function (__webpack_handle_async_dependencies__, __webpack_async_result__) { try {\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AmapDrawProps: function() { return /* binding */ AmapDrawProps; }\n/* harmony export */ });\n/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.array.push.js */ \"./node_modules/core-js/modules/es.array.push.js\");\n/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.iterator.constructor.js */ \"./node_modules/core-js/modules/es.iterator.constructor.js\");\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var core_js_modules_es_iterator_every_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/es.iterator.every.js */ \"./node_modules/core-js/modules/es.iterator.every.js\");\n/* harmony import */ var core_js_modules_es_iterator_every_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_every_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var core_js_modules_es_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/es.iterator.for-each.js */ \"./node_modules/core-js/modules/es.iterator.for-each.js\");\n/* harmony import */ var core_js_modules_es_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var core_js_modules_es_iterator_map_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/es.iterator.map.js */ \"./node_modules/core-js/modules/es.iterator.map.js\");\n/* harmony import */ var core_js_modules_es_iterator_map_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_map_js__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/AmapSearch/index.jsx */ \"./plugins/lib/amap/components/AmapSearch/index.jsx\");\n/* harmony import */ var ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ant-design-vue/es/_util/vue-types */ \"./node_modules/ant-design-vue/es/_util/vue-types/index.js\");\n/* harmony import */ var _method_AMap_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/method/AMap.js */ \"./plugins/method/AMap.js\");\n/* harmony import */ var _AmapDraw_less__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./AmapDraw.less */ \"./plugins/lib/amap/AmapDraw.less\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__]);\n_components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];\n\n\n\n\n\n\n\n\nconst amap = await (0,_method_AMap_js__WEBPACK_IMPORTED_MODULE_6__.getAMapInstance)();\nconst {\n AMap,\n methods,\n layers\n} = amap;\n\nconst AmapDrawProps = {\n /** drawEl为地图容器实例名称 */\n drawEl: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].string.def('AmapDraw'),\n /** drawType为绘制类型\r\n * 可选值(point点 | line线 | polygon面)\r\n */\n drawType: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].string.def('point'),\n /** 绘制图标 (只在point类型下生效 */\n drawIcon: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].any.def('http://api.qxfnkj.com:8090/poi/poi-marker-default.png'),\n /** drawCount为绘制物绘制个数 */\n drawCount: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].number.def(1),\n /** drawOptions为绘制物配置项 */\n drawOptions: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object.def({}),\n /** drawInfo为绘制物信息 */\n drawInfo: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].oneOfType([ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object, ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].array]),\n /** drawInfoAll为所有不同类型绘制物信息(用于回显地图图层)\r\n * 格式: { point: ([]||{}), line: ([]||{}) }\r\n */\n drawInfoAll: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object,\n /** 限制区域 */\n drawLimitArea: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].oneOfType([ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object, ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].string]),\n /** 限制区域样式配置 */\n drawLimitAreaOptions: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object.def({}),\n /** 是否为纯地图展示数据 */\n isExhibition: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].bool.def(false)\n};\nconst AmapDraw = {\n name: 'AmapDraw',\n props: AmapDrawProps,\n data() {\n return {\n amap: null,\n drawArea: null,\n drawLayers: null,\n drawMouseTool: null,\n buttonProps: [],\n drawButtonProps: [{\n type: 'primary',\n text: '绘制',\n event: {\n click: this.AmapDraw\n }\n }, {\n text: '清除',\n event: {\n click: this.AmapDrawClear\n }\n }],\n saveButtonProps: [{\n type: 'primary',\n text: '保存',\n event: {\n click: this.AmapDrawSave\n }\n }, {\n text: '取消',\n event: {\n click: this.AmapDrawReset\n }\n }]\n };\n },\n computed: {\n drawLayersInfo: {\n get() {\n return this.drawInfo;\n },\n set(newValue) {\n this.$emit('getAMapLayersInfo', newValue);\n }\n }\n },\n watch: {\n drawInfo: {\n handler(newVal, oldVal) {\n const newValue = this.drawLayersInfo;\n newVal && this.echoDrawLayers(this.drawType);\n },\n deep: true\n },\n drawInfoAll(newValue) {\n newValue && this.echoDrawLayers();\n },\n drawOptions(newValue) {\n /** 检测options覆盖物配置是否更改,更改后要同步到地图上 */\n Object.keys(newValue).length && this.setOverlayOptions(newValue);\n },\n drawLimitArea(newValue) {\n newValue && this.setDrawLimitArea();\n }\n },\n mounted() {\n this.amap = amap.initMap({\n el: this.drawEl\n });\n this.buttonProps = [].concat(this.drawButtonProps);\n this.echoDrawLayers(this.drawType);\n /** 如果有限制区域,则描绘在地图上 */\n this.drawLimitArea && this.setDrawLimitArea();\n },\n destroyed() {\n this.AmapDrawClear();\n },\n methods: {\n /** 绘制 */\n AmapDraw() {\n this.buttonProps = [].concat(this.saveButtonProps);\n this.drawMouseTool = new AMap.MouseTool(this.amap);\n this.AmapDrawClear();\n this.setDrawLayers(this.drawType);\n this.drawMouseTool.on('draw', ({\n obj\n }) => {\n if (this.drawArea && !this[`is${this.drawType}InRing`](obj)) return this.amap.remove(obj), this.$message.error('未在范围内描绘!');\n /** 暂未支持一次性绘制多个 */\n this.drawCount > 1 ? (this.drawLayers = this.drawLayers || [], this.drawLayers.push(obj)) : this.drawLayers = obj;\n if (this.drawLayers && (this.drawLayers.length == this.drawCount || this.drawCount == 1)) {\n return this.drawMouseTool.close();\n }\n });\n },\n /** 清空绘制 / 清空搜索 */\n AmapDrawClear() {\n this.amap.getAllOverlays().forEach(layerItem => layerItem.getExtData() != 'Area' && this.amap.remove(layerItem));\n // this.amap.clearMap()\n this.drawLayers = null;\n this.drawLayersInfo = {};\n },\n /** 保存当前绘制 */\n AmapDrawSave() {\n this.assignDrawLayers(this.drawType);\n this.buttonProps = [].concat(this.drawButtonProps);\n },\n /** 取消当前绘制 */\n AmapDrawReset() {\n this.buttonProps = [].concat(this.drawButtonProps);\n this.AmapDrawClear();\n },\n /** 搜索地址 */\n searchChoose(searchMarker, searchInfo) {\n this.AmapDrawClear();\n searchMarker.setMap(this.amap);\n this.amap.setZoomAndCenter(15, searchMarker.getPosition());\n this.drawType == 'point' && (this.drawLayersInfo = searchInfo);\n // this.$emit('getAMapLayersInfo', this.drawLayersInfo)\n },\n /** 检测覆盖物配置信息并同步 */\n setOverlayOptions(options) {\n if (!this.drawLayers) return;\n this.drawCount > 1 ? this.drawLayers.forEach(drawItem => drawItem.setOptions(options)) : this.drawLayers.setOptions(options);\n },\n /** 绘制限定区域 */\n setDrawLimitArea() {\n let areaRange = [];\n try {\n areaRange = JSON.parse(this.drawLimitArea);\n } catch {\n areaRange = this.drawLimitArea;\n }\n this.drawArea && this.amap.remove(this.drawArea);\n /** 判断目前地图上存在的所绘制覆盖物是否在限制范围内 */\n this.setMapArea(areaRange);\n this.judgeOverlays();\n },\n /** 绘制地图区域范围 */\n setMapArea(jurisdictionRange) {\n this.drawArea = new AMap.Polygon({\n map: this.amap,\n path: jurisdictionRange,\n extData: 'Area',\n strokeWeight: 6,\n ...this.drawLimitAreaOptions\n });\n const {\n lng,\n lat\n } = this.drawArea.getBounds().getCenter();\n this.amap.setZoomAndCenter(15, [lng, lat]);\n },\n /** 判断一个线段是否在面内 */\n islineInRing(polyline) {\n const paths = polyline.getPath();\n return paths.every(pointItem => this.ispointInRing(pointItem));\n },\n /** 判断一个点是否在面内 */\n ispointInRing(point) {\n let position;\n try {\n position = point.getPosition();\n } catch {\n position = point;\n }\n return AMap.GeometryUtil.isPointInRing(position, this.drawArea.getPath());\n },\n /** 判断地图上所覆盖物是否在限制范围内 */\n judgeOverlays() {\n this.amap.getAllOverlays().forEach(layerItem => layerItem.getExtData() != 'Area' && !this[`is${this.drawType}InRing`](layerItem) && this.removeOverlay(layerItem));\n },\n /** 清除单个覆盖物(或 不符合区域范围的覆盖物 */\n removeOverlay(layerItem) {\n this.amap.remove(layerItem);\n this.$message.error('未在区域范围内,请重新描绘!');\n try {\n const i = this.drawLayers.findIndex(layer => layer.getExtData() == layerItem.getExtData());\n this.drawLayers.splice(i, 1);\n } catch {\n this.drawLayers = null;\n this.drawLayersInfo = {};\n }\n },\n /** 根据类型处理不同数据 */\n setDrawLayers(drawType) {\n const type = {\n point: 'marker',\n line: 'polyline',\n polygon: 'polygon'\n };\n\n /** 图层基础配置 */\n const drawOptions = drawType == 'point' ? {\n anchor: 'bottom-center',\n icon: layers.setIcon(this.drawIcon)\n } : {\n strokeWeight: 8\n };\n this.drawMouseTool[type[drawType]]({\n ...drawOptions,\n ...this.drawOptions\n });\n },\n /** 赋值不同图层数据 */\n assignDrawLayers(drawType) {\n if (drawType == 'point') {\n const {\n lng,\n lat\n } = this.drawLayers.getPosition();\n const position = {\n longitude: lng,\n latitude: lat\n };\n methods.getMapAddress(position, address => {\n this.drawLayersInfo = {\n ...position,\n ...address\n };\n });\n return;\n }\n const range = this.drawLayers.getPath().map(({\n lng,\n lat\n }) => [lng, lat]);\n this.drawLayersInfo = {\n range\n };\n },\n /** 回显不同类型图层 */\n echoDrawLayers(drawType) {\n const drawLayersItem = (drawItem, type, i = 0) => {\n // && drawItem.latitude && drawItem.longitude 忘记当时为什么加这个了 后续在想\n if (drawItem && this.amap) {\n let layersItem = null;\n const {\n longitude,\n latitude,\n range\n } = drawItem;\n const setOptions = {\n extData: `draw${type}${i}`,\n ...this.drawOptions\n };\n if (type == 'point') {\n layersItem = layers.setMarker(this.drawIcon, {\n position: [longitude, latitude],\n ...setOptions\n });\n } else {\n const options = {\n path: range,\n strokeWeight: 8,\n ...setOptions\n };\n layersItem = type == 'line' ? new AMap.Polyline(options) : new AMap.Polygon(options);\n }\n layersItem.setMap(this.amap);\n this.amap.setFitView();\n }\n };\n if (!this.isExhibition) {\n drawLayersItem(this.drawLayersInfo, drawType);\n return;\n }\n if (this.drawInfoAll) {\n for (let key in this.drawInfoAll) {\n const isArray = Array.isArray(this.drawInfoAll[key]);\n isArray ? this.drawInfoAll[key].forEach((drawItem, i) => {\n drawLayersItem(drawItem, key, i);\n }) : drawLayersItem(this.drawInfoAll[key], key);\n }\n return;\n }\n drawLayersItem(this.drawLayersInfo, drawType);\n }\n },\n render(h) {\n const {\n drawEl,\n drawIcon,\n buttonProps,\n isExhibition,\n AmapDrawClear,\n searchChoose\n } = this;\n return h(\"div\", {\n \"class\": \"AmapDraw\"\n }, [!isExhibition && h(_components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n \"props\": {\n ...{\n drawIcon,\n buttonProps\n }\n },\n \"on\": {\n ...{\n searchReset: AmapDrawClear,\n searchChoose\n }\n }\n }), h(\"div\", {\n \"attrs\": {\n \"id\": drawEl\n }\n })]);\n }\n};\nAmapDraw.install = function (Vue) {\n Vue.component('AmapDraw', AmapDraw);\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = (AmapDraw);\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } }, 1);\n\n//# sourceURL=webpack://mui/./plugins/lib/amap/AmapDraw.jsx?");
8717
+ eval("__webpack_require__.a(module, async function (__webpack_handle_async_dependencies__, __webpack_async_result__) { try {\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AmapDrawProps: function() { return /* binding */ AmapDrawProps; }\n/* harmony export */ });\n/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.array.push.js */ \"./node_modules/core-js/modules/es.array.push.js\");\n/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.iterator.constructor.js */ \"./node_modules/core-js/modules/es.iterator.constructor.js\");\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var core_js_modules_es_iterator_every_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/es.iterator.every.js */ \"./node_modules/core-js/modules/es.iterator.every.js\");\n/* harmony import */ var core_js_modules_es_iterator_every_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_every_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var core_js_modules_es_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/es.iterator.for-each.js */ \"./node_modules/core-js/modules/es.iterator.for-each.js\");\n/* harmony import */ var core_js_modules_es_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var core_js_modules_es_iterator_map_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/es.iterator.map.js */ \"./node_modules/core-js/modules/es.iterator.map.js\");\n/* harmony import */ var core_js_modules_es_iterator_map_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_map_js__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/AmapSearch/index.jsx */ \"./plugins/lib/amap/components/AmapSearch/index.jsx\");\n/* harmony import */ var ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ant-design-vue/es/_util/vue-types */ \"./node_modules/ant-design-vue/es/_util/vue-types/index.js\");\n/* harmony import */ var _method_AMap_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../method/AMap.js */ \"./plugins/method/AMap.js\");\n/* harmony import */ var _AmapDraw_less__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./AmapDraw.less */ \"./plugins/lib/amap/AmapDraw.less\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__]);\n_components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];\n\n\n\n\n\n\n\n\nconst amap = await (0,_method_AMap_js__WEBPACK_IMPORTED_MODULE_6__.getAMapInstance)();\nconst {\n AMap,\n methods,\n layers\n} = amap;\n\nconst AmapDrawProps = {\n /** drawEl为地图容器实例名称 */\n drawEl: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].string.def('AmapDraw'),\n /** drawType为绘制类型\r\n * 可选值(point点 | line线 | polygon面)\r\n */\n drawType: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].string.def('point'),\n /** 绘制图标 (只在point类型下生效 */\n drawIcon: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].any.def('http://api.qxfnkj.com:8090/poi/poi-marker-default.png'),\n /** drawCount为绘制物绘制个数 */\n drawCount: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].number.def(1),\n /** drawOptions为绘制物配置项 */\n drawOptions: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object.def({}),\n /** drawInfo为绘制物信息 */\n drawInfo: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].oneOfType([ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object, ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].array]),\n /** drawInfoAll为所有不同类型绘制物信息(用于回显地图图层)\r\n * 格式: { point: ([]||{}), line: ([]||{}) }\r\n */\n drawInfoAll: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object,\n /** 限制区域 */\n drawLimitArea: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].oneOfType([ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object, ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].string]),\n /** 限制区域样式配置 */\n drawLimitAreaOptions: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object.def({}),\n /** 是否为纯地图展示数据 */\n isExhibition: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].bool.def(false)\n};\nconst AmapDraw = {\n name: 'AmapDraw',\n props: AmapDrawProps,\n data() {\n return {\n amap: null,\n drawArea: null,\n drawLayers: null,\n drawMouseTool: null,\n buttonProps: [],\n drawButtonProps: [{\n type: 'primary',\n text: '绘制',\n event: {\n click: this.AmapDraw\n }\n }, {\n text: '清除',\n event: {\n click: this.AmapDrawClear\n }\n }],\n saveButtonProps: [{\n type: 'primary',\n text: '保存',\n event: {\n click: this.AmapDrawSave\n }\n }, {\n text: '取消',\n event: {\n click: this.AmapDrawReset\n }\n }]\n };\n },\n computed: {\n drawLayersInfo: {\n get() {\n return this.drawInfo;\n },\n set(newValue) {\n this.$emit('getAMapLayersInfo', newValue);\n }\n }\n },\n watch: {\n drawInfo: {\n handler(newVal, oldVal) {\n const newValue = this.drawLayersInfo;\n newVal && this.echoDrawLayers(this.drawType);\n },\n deep: true\n },\n drawInfoAll(newValue) {\n newValue && this.echoDrawLayers();\n },\n drawOptions(newValue) {\n /** 检测options覆盖物配置是否更改,更改后要同步到地图上 */\n Object.keys(newValue).length && this.setOverlayOptions(newValue);\n },\n drawLimitArea(newValue) {\n newValue && this.setDrawLimitArea();\n }\n },\n mounted() {\n this.amap = amap.initMap({\n el: this.drawEl\n });\n this.buttonProps = [].concat(this.drawButtonProps);\n this.echoDrawLayers(this.drawType);\n /** 如果有限制区域,则描绘在地图上 */\n this.drawLimitArea && this.setDrawLimitArea();\n },\n destroyed() {\n this.AmapDrawClear();\n },\n methods: {\n /** 绘制 */\n AmapDraw() {\n this.buttonProps = [].concat(this.saveButtonProps);\n this.drawMouseTool = new AMap.MouseTool(this.amap);\n this.AmapDrawClear();\n this.setDrawLayers(this.drawType);\n this.drawMouseTool.on('draw', ({\n obj\n }) => {\n if (this.drawArea && !this[`is${this.drawType}InRing`](obj)) return this.amap.remove(obj), this.$message.error('未在范围内描绘!');\n /** 暂未支持一次性绘制多个 */\n this.drawCount > 1 ? (this.drawLayers = this.drawLayers || [], this.drawLayers.push(obj)) : this.drawLayers = obj;\n if (this.drawLayers && (this.drawLayers.length == this.drawCount || this.drawCount == 1)) {\n return this.drawMouseTool.close();\n }\n });\n },\n /** 清空绘制 / 清空搜索 */\n AmapDrawClear() {\n this.amap.getAllOverlays().forEach(layerItem => layerItem.getExtData() != 'Area' && this.amap.remove(layerItem));\n // this.amap.clearMap()\n this.drawLayers = null;\n this.drawLayersInfo = {};\n },\n /** 保存当前绘制 */\n AmapDrawSave() {\n this.assignDrawLayers(this.drawType);\n this.buttonProps = [].concat(this.drawButtonProps);\n },\n /** 取消当前绘制 */\n AmapDrawReset() {\n this.buttonProps = [].concat(this.drawButtonProps);\n this.AmapDrawClear();\n },\n /** 搜索地址 */\n searchChoose(searchMarker, searchInfo) {\n this.AmapDrawClear();\n searchMarker.setMap(this.amap);\n this.amap.setZoomAndCenter(15, searchMarker.getPosition());\n this.drawType == 'point' && (this.drawLayersInfo = searchInfo);\n // this.$emit('getAMapLayersInfo', this.drawLayersInfo)\n },\n /** 检测覆盖物配置信息并同步 */\n setOverlayOptions(options) {\n if (!this.drawLayers) return;\n this.drawCount > 1 ? this.drawLayers.forEach(drawItem => drawItem.setOptions(options)) : this.drawLayers.setOptions(options);\n },\n /** 绘制限定区域 */\n setDrawLimitArea() {\n let areaRange = [];\n try {\n areaRange = JSON.parse(this.drawLimitArea);\n } catch {\n areaRange = this.drawLimitArea;\n }\n this.drawArea && this.amap.remove(this.drawArea);\n /** 判断目前地图上存在的所绘制覆盖物是否在限制范围内 */\n this.setMapArea(areaRange);\n this.judgeOverlays();\n },\n /** 绘制地图区域范围 */\n setMapArea(jurisdictionRange) {\n this.drawArea = new AMap.Polygon({\n map: this.amap,\n path: jurisdictionRange,\n extData: 'Area',\n strokeWeight: 6,\n ...this.drawLimitAreaOptions\n });\n const {\n lng,\n lat\n } = this.drawArea.getBounds().getCenter();\n this.amap.setZoomAndCenter(15, [lng, lat]);\n },\n /** 判断一个线段是否在面内 */\n islineInRing(polyline) {\n const paths = polyline.getPath();\n return paths.every(pointItem => this.ispointInRing(pointItem));\n },\n /** 判断一个点是否在面内 */\n ispointInRing(point) {\n let position;\n try {\n position = point.getPosition();\n } catch {\n position = point;\n }\n return AMap.GeometryUtil.isPointInRing(position, this.drawArea.getPath());\n },\n /** 判断地图上所覆盖物是否在限制范围内 */\n judgeOverlays() {\n this.amap.getAllOverlays().forEach(layerItem => layerItem.getExtData() != 'Area' && !this[`is${this.drawType}InRing`](layerItem) && this.removeOverlay(layerItem));\n },\n /** 清除单个覆盖物(或 不符合区域范围的覆盖物 */\n removeOverlay(layerItem) {\n this.amap.remove(layerItem);\n this.$message.error('未在区域范围内,请重新描绘!');\n try {\n const i = this.drawLayers.findIndex(layer => layer.getExtData() == layerItem.getExtData());\n this.drawLayers.splice(i, 1);\n } catch {\n this.drawLayers = null;\n this.drawLayersInfo = {};\n }\n },\n /** 根据类型处理不同数据 */\n setDrawLayers(drawType) {\n const type = {\n point: 'marker',\n line: 'polyline',\n polygon: 'polygon'\n };\n\n /** 图层基础配置 */\n const drawOptions = drawType == 'point' ? {\n anchor: 'bottom-center',\n icon: layers.setIcon(this.drawIcon)\n } : {\n strokeWeight: 8\n };\n this.drawMouseTool[type[drawType]]({\n ...drawOptions,\n ...this.drawOptions\n });\n },\n /** 赋值不同图层数据 */\n assignDrawLayers(drawType) {\n if (drawType == 'point') {\n const {\n lng,\n lat\n } = this.drawLayers.getPosition();\n const position = {\n longitude: lng,\n latitude: lat\n };\n methods.getMapAddress(position, address => {\n this.drawLayersInfo = {\n ...position,\n ...address\n };\n });\n return;\n }\n const range = this.drawLayers.getPath().map(({\n lng,\n lat\n }) => [lng, lat]);\n this.drawLayersInfo = {\n range\n };\n },\n /** 回显不同类型图层 */\n echoDrawLayers(drawType) {\n const drawLayersItem = (drawItem, type, i = 0) => {\n // && drawItem.latitude && drawItem.longitude 忘记当时为什么加这个了 后续在想\n if (drawItem && this.amap) {\n let layersItem = null;\n const {\n longitude,\n latitude,\n range\n } = drawItem;\n const setOptions = {\n extData: `draw${type}${i}`,\n ...this.drawOptions\n };\n if (type == 'point') {\n layersItem = layers.setMarker(this.drawIcon, {\n position: [longitude, latitude],\n ...setOptions\n });\n } else {\n const options = {\n path: range,\n strokeWeight: 8,\n ...setOptions\n };\n layersItem = type == 'line' ? new AMap.Polyline(options) : new AMap.Polygon(options);\n }\n layersItem.setMap(this.amap);\n this.amap.setFitView();\n }\n };\n if (!this.isExhibition) {\n drawLayersItem(this.drawLayersInfo, drawType);\n return;\n }\n if (this.drawInfoAll) {\n for (let key in this.drawInfoAll) {\n const isArray = Array.isArray(this.drawInfoAll[key]);\n isArray ? this.drawInfoAll[key].forEach((drawItem, i) => {\n drawLayersItem(drawItem, key, i);\n }) : drawLayersItem(this.drawInfoAll[key], key);\n }\n return;\n }\n drawLayersItem(this.drawLayersInfo, drawType);\n }\n },\n render(h) {\n const {\n drawEl,\n drawIcon,\n buttonProps,\n isExhibition,\n AmapDrawClear,\n searchChoose\n } = this;\n return h(\"div\", {\n \"class\": \"AmapDraw\"\n }, [!isExhibition && h(_components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n \"props\": {\n ...{\n drawIcon,\n buttonProps\n }\n },\n \"on\": {\n ...{\n searchReset: AmapDrawClear,\n searchChoose\n }\n }\n }), h(\"div\", {\n \"attrs\": {\n \"id\": drawEl\n }\n })]);\n }\n};\nAmapDraw.install = function (Vue) {\n Vue.component('AmapDraw', AmapDraw);\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = (AmapDraw);\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } }, 1);\n\n//# sourceURL=webpack://mui/./plugins/lib/amap/AmapDraw.jsx?");
8718
8718
 
8719
8719
  /***/ }),
8720
8720
 
@@ -8725,7 +8725,7 @@ eval("__webpack_require__.a(module, async function (__webpack_handle_async_depen
8725
8725
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
8726
8726
 
8727
8727
  "use strict";
8728
- eval("__webpack_require__.a(module, async function (__webpack_handle_async_dependencies__, __webpack_async_result__) { try {\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AmapSearchProps: function() { return /* binding */ AmapSearchProps; }\n/* harmony export */ });\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.iterator.constructor.js */ \"./node_modules/core-js/modules/es.iterator.constructor.js\");\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var core_js_modules_es_iterator_find_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.iterator.find.js */ \"./node_modules/core-js/modules/es.iterator.find.js\");\n/* harmony import */ var core_js_modules_es_iterator_find_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_find_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ant-design-vue/es/_util/vue-types */ \"./node_modules/ant-design-vue/es/_util/vue-types/index.js\");\n/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../index */ \"./plugins/lib/index.js\");\n/* harmony import */ var _method_AMap_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/method/AMap.js */ \"./plugins/method/AMap.js\");\n/* harmony import */ var _index_less__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./index.less */ \"./plugins/lib/amap/components/AmapSearch/index.less\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_index__WEBPACK_IMPORTED_MODULE_2__]);\n_index__WEBPACK_IMPORTED_MODULE_2__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];\n\n\n\n\n\n\nconst {\n ASelectCustom\n} = _index__WEBPACK_IMPORTED_MODULE_2__.FormComp;\nconst {\n methods,\n layers\n} = await (0,_method_AMap_js__WEBPACK_IMPORTED_MODULE_3__.getAMapInstance)();\nconst AmapSearchProps = {\n /** 搜索后绘制图标 */\n drawIcon: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_5__[\"default\"].any,\n buttonProps: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_5__[\"default\"].array.def([])\n};\nconst AmapSearch = {\n name: 'AmapSearch',\n props: AmapSearchProps,\n data() {\n return {\n searchMarker: null,\n addressValue: undefined,\n selectOptions: []\n };\n },\n methods: {\n /** 选择地址 */\n changeHandle() {\n if (!this.addressValue) return this.$emit('searchReset', this.searchMarker), this.searchMarker = null;\n const {\n label,\n location\n } = this.selectOptions.find(({\n id\n }) => id == this.addressValue);\n const searchInfo = {\n longitude: location.lng,\n latitude: location.lat,\n address: label\n };\n this.searchMarker = layers.setMarker(this.drawIcon, {\n position: [location.lng, location.lat]\n });\n this.$emit('searchChoose', this.searchMarker, searchInfo);\n },\n /** 根据搜索框搜索地址 */\n searchHandle(keyword) {\n methods.getMapSearch(keyword, addressOptions => {\n this.selectOptions = addressOptions;\n });\n }\n },\n render(h) {\n const {\n selectOptions,\n changeHandle,\n searchHandle,\n buttonProps\n } = this;\n const props = {\n valueKey: 'id',\n labelKey: 'label',\n options: selectOptions,\n placeholder: '请输入目的地进行搜索'\n };\n return h(\"div\", {\n \"class\": \"AmapDraw__Search\"\n }, [h(ASelectCustom, {\n \"props\": {\n ...props\n },\n \"on\": {\n ...{\n change: changeHandle,\n search: searchHandle\n }\n },\n \"model\": {\n value: this.addressValue,\n callback: $$v => {\n this.addressValue = $$v;\n }\n }\n }), buttonProps && h(_index__WEBPACK_IMPORTED_MODULE_2__.Button, {\n \"attrs\": {\n \"buttonProps\": buttonProps\n },\n \"class\": \"AmapDraw__Search__Button\"\n })]);\n }\n};\nAmapSearch.install = function (Vue) {\n Vue.component('AmapSearch', AmapSearch);\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = (AmapSearch);\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } }, 1);\n\n//# sourceURL=webpack://mui/./plugins/lib/amap/components/AmapSearch/index.jsx?");
8728
+ eval("__webpack_require__.a(module, async function (__webpack_handle_async_dependencies__, __webpack_async_result__) { try {\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AmapSearchProps: function() { return /* binding */ AmapSearchProps; }\n/* harmony export */ });\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.iterator.constructor.js */ \"./node_modules/core-js/modules/es.iterator.constructor.js\");\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var core_js_modules_es_iterator_find_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.iterator.find.js */ \"./node_modules/core-js/modules/es.iterator.find.js\");\n/* harmony import */ var core_js_modules_es_iterator_find_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_find_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ant-design-vue/es/_util/vue-types */ \"./node_modules/ant-design-vue/es/_util/vue-types/index.js\");\n/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../index */ \"./plugins/lib/index.js\");\n/* harmony import */ var _method_AMap_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../../method/AMap.js */ \"./plugins/method/AMap.js\");\n/* harmony import */ var _index_less__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./index.less */ \"./plugins/lib/amap/components/AmapSearch/index.less\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_index__WEBPACK_IMPORTED_MODULE_2__]);\n_index__WEBPACK_IMPORTED_MODULE_2__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];\n\n\n\n\n\n\nconst {\n ASelectCustom\n} = _index__WEBPACK_IMPORTED_MODULE_2__.FormComp;\nconst {\n methods,\n layers\n} = await (0,_method_AMap_js__WEBPACK_IMPORTED_MODULE_3__.getAMapInstance)();\nconst AmapSearchProps = {\n /** 搜索后绘制图标 */\n drawIcon: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_5__[\"default\"].any,\n buttonProps: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_5__[\"default\"].array.def([])\n};\nconst AmapSearch = {\n name: 'AmapSearch',\n props: AmapSearchProps,\n data() {\n return {\n searchMarker: null,\n addressValue: undefined,\n selectOptions: []\n };\n },\n methods: {\n /** 选择地址 */\n changeHandle() {\n if (!this.addressValue) return this.$emit('searchReset', this.searchMarker), this.searchMarker = null;\n const {\n label,\n location\n } = this.selectOptions.find(({\n id\n }) => id == this.addressValue);\n const searchInfo = {\n longitude: location.lng,\n latitude: location.lat,\n address: label\n };\n this.searchMarker = layers.setMarker(this.drawIcon, {\n position: [location.lng, location.lat]\n });\n this.$emit('searchChoose', this.searchMarker, searchInfo);\n },\n /** 根据搜索框搜索地址 */\n searchHandle(keyword) {\n methods.getMapSearch(keyword, addressOptions => {\n this.selectOptions = addressOptions;\n });\n }\n },\n render(h) {\n const {\n selectOptions,\n changeHandle,\n searchHandle,\n buttonProps\n } = this;\n const props = {\n valueKey: 'id',\n labelKey: 'label',\n options: selectOptions,\n placeholder: '请输入目的地进行搜索'\n };\n return h(\"div\", {\n \"class\": \"AmapDraw__Search\"\n }, [h(ASelectCustom, {\n \"props\": {\n ...props\n },\n \"on\": {\n ...{\n change: changeHandle,\n search: searchHandle\n }\n },\n \"model\": {\n value: this.addressValue,\n callback: $$v => {\n this.addressValue = $$v;\n }\n }\n }), buttonProps && h(_index__WEBPACK_IMPORTED_MODULE_2__.Button, {\n \"attrs\": {\n \"buttonProps\": buttonProps\n },\n \"class\": \"AmapDraw__Search__Button\"\n })]);\n }\n};\nAmapSearch.install = function (Vue) {\n Vue.component('AmapSearch', AmapSearch);\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = (AmapSearch);\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } }, 1);\n\n//# sourceURL=webpack://mui/./plugins/lib/amap/components/AmapSearch/index.jsx?");
8729
8729
 
8730
8730
  /***/ }),
8731
8731
 
package/dist/index.umd.js CHANGED
@@ -8714,7 +8714,7 @@ eval("/**\n * Copyright (c) 2014-present, Facebook, Inc.\n *\n * This source cod
8714
8714
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
8715
8715
 
8716
8716
  "use strict";
8717
- eval("__webpack_require__.a(module, async function (__webpack_handle_async_dependencies__, __webpack_async_result__) { try {\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AmapDrawProps: function() { return /* binding */ AmapDrawProps; }\n/* harmony export */ });\n/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.array.push.js */ \"./node_modules/core-js/modules/es.array.push.js\");\n/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.iterator.constructor.js */ \"./node_modules/core-js/modules/es.iterator.constructor.js\");\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var core_js_modules_es_iterator_every_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/es.iterator.every.js */ \"./node_modules/core-js/modules/es.iterator.every.js\");\n/* harmony import */ var core_js_modules_es_iterator_every_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_every_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var core_js_modules_es_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/es.iterator.for-each.js */ \"./node_modules/core-js/modules/es.iterator.for-each.js\");\n/* harmony import */ var core_js_modules_es_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var core_js_modules_es_iterator_map_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/es.iterator.map.js */ \"./node_modules/core-js/modules/es.iterator.map.js\");\n/* harmony import */ var core_js_modules_es_iterator_map_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_map_js__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/AmapSearch/index.jsx */ \"./plugins/lib/amap/components/AmapSearch/index.jsx\");\n/* harmony import */ var ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ant-design-vue/es/_util/vue-types */ \"./node_modules/ant-design-vue/es/_util/vue-types/index.js\");\n/* harmony import */ var _method_AMap_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @/method/AMap.js */ \"./plugins/method/AMap.js\");\n/* harmony import */ var _AmapDraw_less__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./AmapDraw.less */ \"./plugins/lib/amap/AmapDraw.less\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__]);\n_components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];\n\n\n\n\n\n\n\n\nconst amap = await (0,_method_AMap_js__WEBPACK_IMPORTED_MODULE_6__.getAMapInstance)();\nconst {\n AMap,\n methods,\n layers\n} = amap;\n\nconst AmapDrawProps = {\n /** drawEl为地图容器实例名称 */\n drawEl: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].string.def('AmapDraw'),\n /** drawType为绘制类型\r\n * 可选值(point点 | line线 | polygon面)\r\n */\n drawType: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].string.def('point'),\n /** 绘制图标 (只在point类型下生效 */\n drawIcon: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].any.def('http://api.qxfnkj.com:8090/poi/poi-marker-default.png'),\n /** drawCount为绘制物绘制个数 */\n drawCount: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].number.def(1),\n /** drawOptions为绘制物配置项 */\n drawOptions: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object.def({}),\n /** drawInfo为绘制物信息 */\n drawInfo: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].oneOfType([ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object, ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].array]),\n /** drawInfoAll为所有不同类型绘制物信息(用于回显地图图层)\r\n * 格式: { point: ([]||{}), line: ([]||{}) }\r\n */\n drawInfoAll: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object,\n /** 限制区域 */\n drawLimitArea: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].oneOfType([ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object, ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].string]),\n /** 限制区域样式配置 */\n drawLimitAreaOptions: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object.def({}),\n /** 是否为纯地图展示数据 */\n isExhibition: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].bool.def(false)\n};\nconst AmapDraw = {\n name: 'AmapDraw',\n props: AmapDrawProps,\n data() {\n return {\n amap: null,\n drawArea: null,\n drawLayers: null,\n drawMouseTool: null,\n buttonProps: [],\n drawButtonProps: [{\n type: 'primary',\n text: '绘制',\n event: {\n click: this.AmapDraw\n }\n }, {\n text: '清除',\n event: {\n click: this.AmapDrawClear\n }\n }],\n saveButtonProps: [{\n type: 'primary',\n text: '保存',\n event: {\n click: this.AmapDrawSave\n }\n }, {\n text: '取消',\n event: {\n click: this.AmapDrawReset\n }\n }]\n };\n },\n computed: {\n drawLayersInfo: {\n get() {\n return this.drawInfo;\n },\n set(newValue) {\n this.$emit('getAMapLayersInfo', newValue);\n }\n }\n },\n watch: {\n drawInfo: {\n handler(newVal, oldVal) {\n const newValue = this.drawLayersInfo;\n newVal && this.echoDrawLayers(this.drawType);\n },\n deep: true\n },\n drawInfoAll(newValue) {\n newValue && this.echoDrawLayers();\n },\n drawOptions(newValue) {\n /** 检测options覆盖物配置是否更改,更改后要同步到地图上 */\n Object.keys(newValue).length && this.setOverlayOptions(newValue);\n },\n drawLimitArea(newValue) {\n newValue && this.setDrawLimitArea();\n }\n },\n mounted() {\n this.amap = amap.initMap({\n el: this.drawEl\n });\n this.buttonProps = [].concat(this.drawButtonProps);\n this.echoDrawLayers(this.drawType);\n /** 如果有限制区域,则描绘在地图上 */\n this.drawLimitArea && this.setDrawLimitArea();\n },\n destroyed() {\n this.AmapDrawClear();\n },\n methods: {\n /** 绘制 */\n AmapDraw() {\n this.buttonProps = [].concat(this.saveButtonProps);\n this.drawMouseTool = new AMap.MouseTool(this.amap);\n this.AmapDrawClear();\n this.setDrawLayers(this.drawType);\n this.drawMouseTool.on('draw', ({\n obj\n }) => {\n if (this.drawArea && !this[`is${this.drawType}InRing`](obj)) return this.amap.remove(obj), this.$message.error('未在范围内描绘!');\n /** 暂未支持一次性绘制多个 */\n this.drawCount > 1 ? (this.drawLayers = this.drawLayers || [], this.drawLayers.push(obj)) : this.drawLayers = obj;\n if (this.drawLayers && (this.drawLayers.length == this.drawCount || this.drawCount == 1)) {\n return this.drawMouseTool.close();\n }\n });\n },\n /** 清空绘制 / 清空搜索 */\n AmapDrawClear() {\n this.amap.getAllOverlays().forEach(layerItem => layerItem.getExtData() != 'Area' && this.amap.remove(layerItem));\n // this.amap.clearMap()\n this.drawLayers = null;\n this.drawLayersInfo = {};\n },\n /** 保存当前绘制 */\n AmapDrawSave() {\n this.assignDrawLayers(this.drawType);\n this.buttonProps = [].concat(this.drawButtonProps);\n },\n /** 取消当前绘制 */\n AmapDrawReset() {\n this.buttonProps = [].concat(this.drawButtonProps);\n this.AmapDrawClear();\n },\n /** 搜索地址 */\n searchChoose(searchMarker, searchInfo) {\n this.AmapDrawClear();\n searchMarker.setMap(this.amap);\n this.amap.setZoomAndCenter(15, searchMarker.getPosition());\n this.drawType == 'point' && (this.drawLayersInfo = searchInfo);\n // this.$emit('getAMapLayersInfo', this.drawLayersInfo)\n },\n /** 检测覆盖物配置信息并同步 */\n setOverlayOptions(options) {\n if (!this.drawLayers) return;\n this.drawCount > 1 ? this.drawLayers.forEach(drawItem => drawItem.setOptions(options)) : this.drawLayers.setOptions(options);\n },\n /** 绘制限定区域 */\n setDrawLimitArea() {\n let areaRange = [];\n try {\n areaRange = JSON.parse(this.drawLimitArea);\n } catch {\n areaRange = this.drawLimitArea;\n }\n this.drawArea && this.amap.remove(this.drawArea);\n /** 判断目前地图上存在的所绘制覆盖物是否在限制范围内 */\n this.setMapArea(areaRange);\n this.judgeOverlays();\n },\n /** 绘制地图区域范围 */\n setMapArea(jurisdictionRange) {\n this.drawArea = new AMap.Polygon({\n map: this.amap,\n path: jurisdictionRange,\n extData: 'Area',\n strokeWeight: 6,\n ...this.drawLimitAreaOptions\n });\n const {\n lng,\n lat\n } = this.drawArea.getBounds().getCenter();\n this.amap.setZoomAndCenter(15, [lng, lat]);\n },\n /** 判断一个线段是否在面内 */\n islineInRing(polyline) {\n const paths = polyline.getPath();\n return paths.every(pointItem => this.ispointInRing(pointItem));\n },\n /** 判断一个点是否在面内 */\n ispointInRing(point) {\n let position;\n try {\n position = point.getPosition();\n } catch {\n position = point;\n }\n return AMap.GeometryUtil.isPointInRing(position, this.drawArea.getPath());\n },\n /** 判断地图上所覆盖物是否在限制范围内 */\n judgeOverlays() {\n this.amap.getAllOverlays().forEach(layerItem => layerItem.getExtData() != 'Area' && !this[`is${this.drawType}InRing`](layerItem) && this.removeOverlay(layerItem));\n },\n /** 清除单个覆盖物(或 不符合区域范围的覆盖物 */\n removeOverlay(layerItem) {\n this.amap.remove(layerItem);\n this.$message.error('未在区域范围内,请重新描绘!');\n try {\n const i = this.drawLayers.findIndex(layer => layer.getExtData() == layerItem.getExtData());\n this.drawLayers.splice(i, 1);\n } catch {\n this.drawLayers = null;\n this.drawLayersInfo = {};\n }\n },\n /** 根据类型处理不同数据 */\n setDrawLayers(drawType) {\n const type = {\n point: 'marker',\n line: 'polyline',\n polygon: 'polygon'\n };\n\n /** 图层基础配置 */\n const drawOptions = drawType == 'point' ? {\n anchor: 'bottom-center',\n icon: layers.setIcon(this.drawIcon)\n } : {\n strokeWeight: 8\n };\n this.drawMouseTool[type[drawType]]({\n ...drawOptions,\n ...this.drawOptions\n });\n },\n /** 赋值不同图层数据 */\n assignDrawLayers(drawType) {\n if (drawType == 'point') {\n const {\n lng,\n lat\n } = this.drawLayers.getPosition();\n const position = {\n longitude: lng,\n latitude: lat\n };\n methods.getMapAddress(position, address => {\n this.drawLayersInfo = {\n ...position,\n ...address\n };\n });\n return;\n }\n const range = this.drawLayers.getPath().map(({\n lng,\n lat\n }) => [lng, lat]);\n this.drawLayersInfo = {\n range\n };\n },\n /** 回显不同类型图层 */\n echoDrawLayers(drawType) {\n const drawLayersItem = (drawItem, type, i = 0) => {\n // && drawItem.latitude && drawItem.longitude 忘记当时为什么加这个了 后续在想\n if (drawItem && this.amap) {\n let layersItem = null;\n const {\n longitude,\n latitude,\n range\n } = drawItem;\n const setOptions = {\n extData: `draw${type}${i}`,\n ...this.drawOptions\n };\n if (type == 'point') {\n layersItem = layers.setMarker(this.drawIcon, {\n position: [longitude, latitude],\n ...setOptions\n });\n } else {\n const options = {\n path: range,\n strokeWeight: 8,\n ...setOptions\n };\n layersItem = type == 'line' ? new AMap.Polyline(options) : new AMap.Polygon(options);\n }\n layersItem.setMap(this.amap);\n this.amap.setFitView();\n }\n };\n if (!this.isExhibition) {\n drawLayersItem(this.drawLayersInfo, drawType);\n return;\n }\n if (this.drawInfoAll) {\n for (let key in this.drawInfoAll) {\n const isArray = Array.isArray(this.drawInfoAll[key]);\n isArray ? this.drawInfoAll[key].forEach((drawItem, i) => {\n drawLayersItem(drawItem, key, i);\n }) : drawLayersItem(this.drawInfoAll[key], key);\n }\n return;\n }\n drawLayersItem(this.drawLayersInfo, drawType);\n }\n },\n render(h) {\n const {\n drawEl,\n drawIcon,\n buttonProps,\n isExhibition,\n AmapDrawClear,\n searchChoose\n } = this;\n return h(\"div\", {\n \"class\": \"AmapDraw\"\n }, [!isExhibition && h(_components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n \"props\": {\n ...{\n drawIcon,\n buttonProps\n }\n },\n \"on\": {\n ...{\n searchReset: AmapDrawClear,\n searchChoose\n }\n }\n }), h(\"div\", {\n \"attrs\": {\n \"id\": drawEl\n }\n })]);\n }\n};\nAmapDraw.install = function (Vue) {\n Vue.component('AmapDraw', AmapDraw);\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = (AmapDraw);\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } }, 1);\n\n//# sourceURL=webpack://mui/./plugins/lib/amap/AmapDraw.jsx?");
8717
+ eval("__webpack_require__.a(module, async function (__webpack_handle_async_dependencies__, __webpack_async_result__) { try {\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AmapDrawProps: function() { return /* binding */ AmapDrawProps; }\n/* harmony export */ });\n/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.array.push.js */ \"./node_modules/core-js/modules/es.array.push.js\");\n/* harmony import */ var core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_array_push_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.iterator.constructor.js */ \"./node_modules/core-js/modules/es.iterator.constructor.js\");\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var core_js_modules_es_iterator_every_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! core-js/modules/es.iterator.every.js */ \"./node_modules/core-js/modules/es.iterator.every.js\");\n/* harmony import */ var core_js_modules_es_iterator_every_js__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_every_js__WEBPACK_IMPORTED_MODULE_2__);\n/* harmony import */ var core_js_modules_es_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! core-js/modules/es.iterator.for-each.js */ \"./node_modules/core-js/modules/es.iterator.for-each.js\");\n/* harmony import */ var core_js_modules_es_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_for_each_js__WEBPACK_IMPORTED_MODULE_3__);\n/* harmony import */ var core_js_modules_es_iterator_map_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! core-js/modules/es.iterator.map.js */ \"./node_modules/core-js/modules/es.iterator.map.js\");\n/* harmony import */ var core_js_modules_es_iterator_map_js__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_map_js__WEBPACK_IMPORTED_MODULE_4__);\n/* harmony import */ var _components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./components/AmapSearch/index.jsx */ \"./plugins/lib/amap/components/AmapSearch/index.jsx\");\n/* harmony import */ var ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ant-design-vue/es/_util/vue-types */ \"./node_modules/ant-design-vue/es/_util/vue-types/index.js\");\n/* harmony import */ var _method_AMap_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../method/AMap.js */ \"./plugins/method/AMap.js\");\n/* harmony import */ var _AmapDraw_less__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./AmapDraw.less */ \"./plugins/lib/amap/AmapDraw.less\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__]);\n_components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];\n\n\n\n\n\n\n\n\nconst amap = await (0,_method_AMap_js__WEBPACK_IMPORTED_MODULE_6__.getAMapInstance)();\nconst {\n AMap,\n methods,\n layers\n} = amap;\n\nconst AmapDrawProps = {\n /** drawEl为地图容器实例名称 */\n drawEl: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].string.def('AmapDraw'),\n /** drawType为绘制类型\r\n * 可选值(point点 | line线 | polygon面)\r\n */\n drawType: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].string.def('point'),\n /** 绘制图标 (只在point类型下生效 */\n drawIcon: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].any.def('http://api.qxfnkj.com:8090/poi/poi-marker-default.png'),\n /** drawCount为绘制物绘制个数 */\n drawCount: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].number.def(1),\n /** drawOptions为绘制物配置项 */\n drawOptions: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object.def({}),\n /** drawInfo为绘制物信息 */\n drawInfo: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].oneOfType([ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object, ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].array]),\n /** drawInfoAll为所有不同类型绘制物信息(用于回显地图图层)\r\n * 格式: { point: ([]||{}), line: ([]||{}) }\r\n */\n drawInfoAll: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object,\n /** 限制区域 */\n drawLimitArea: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].oneOfType([ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object, ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].string]),\n /** 限制区域样式配置 */\n drawLimitAreaOptions: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].object.def({}),\n /** 是否为纯地图展示数据 */\n isExhibition: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_8__[\"default\"].bool.def(false)\n};\nconst AmapDraw = {\n name: 'AmapDraw',\n props: AmapDrawProps,\n data() {\n return {\n amap: null,\n drawArea: null,\n drawLayers: null,\n drawMouseTool: null,\n buttonProps: [],\n drawButtonProps: [{\n type: 'primary',\n text: '绘制',\n event: {\n click: this.AmapDraw\n }\n }, {\n text: '清除',\n event: {\n click: this.AmapDrawClear\n }\n }],\n saveButtonProps: [{\n type: 'primary',\n text: '保存',\n event: {\n click: this.AmapDrawSave\n }\n }, {\n text: '取消',\n event: {\n click: this.AmapDrawReset\n }\n }]\n };\n },\n computed: {\n drawLayersInfo: {\n get() {\n return this.drawInfo;\n },\n set(newValue) {\n this.$emit('getAMapLayersInfo', newValue);\n }\n }\n },\n watch: {\n drawInfo: {\n handler(newVal, oldVal) {\n const newValue = this.drawLayersInfo;\n newVal && this.echoDrawLayers(this.drawType);\n },\n deep: true\n },\n drawInfoAll(newValue) {\n newValue && this.echoDrawLayers();\n },\n drawOptions(newValue) {\n /** 检测options覆盖物配置是否更改,更改后要同步到地图上 */\n Object.keys(newValue).length && this.setOverlayOptions(newValue);\n },\n drawLimitArea(newValue) {\n newValue && this.setDrawLimitArea();\n }\n },\n mounted() {\n this.amap = amap.initMap({\n el: this.drawEl\n });\n this.buttonProps = [].concat(this.drawButtonProps);\n this.echoDrawLayers(this.drawType);\n /** 如果有限制区域,则描绘在地图上 */\n this.drawLimitArea && this.setDrawLimitArea();\n },\n destroyed() {\n this.AmapDrawClear();\n },\n methods: {\n /** 绘制 */\n AmapDraw() {\n this.buttonProps = [].concat(this.saveButtonProps);\n this.drawMouseTool = new AMap.MouseTool(this.amap);\n this.AmapDrawClear();\n this.setDrawLayers(this.drawType);\n this.drawMouseTool.on('draw', ({\n obj\n }) => {\n if (this.drawArea && !this[`is${this.drawType}InRing`](obj)) return this.amap.remove(obj), this.$message.error('未在范围内描绘!');\n /** 暂未支持一次性绘制多个 */\n this.drawCount > 1 ? (this.drawLayers = this.drawLayers || [], this.drawLayers.push(obj)) : this.drawLayers = obj;\n if (this.drawLayers && (this.drawLayers.length == this.drawCount || this.drawCount == 1)) {\n return this.drawMouseTool.close();\n }\n });\n },\n /** 清空绘制 / 清空搜索 */\n AmapDrawClear() {\n this.amap.getAllOverlays().forEach(layerItem => layerItem.getExtData() != 'Area' && this.amap.remove(layerItem));\n // this.amap.clearMap()\n this.drawLayers = null;\n this.drawLayersInfo = {};\n },\n /** 保存当前绘制 */\n AmapDrawSave() {\n this.assignDrawLayers(this.drawType);\n this.buttonProps = [].concat(this.drawButtonProps);\n },\n /** 取消当前绘制 */\n AmapDrawReset() {\n this.buttonProps = [].concat(this.drawButtonProps);\n this.AmapDrawClear();\n },\n /** 搜索地址 */\n searchChoose(searchMarker, searchInfo) {\n this.AmapDrawClear();\n searchMarker.setMap(this.amap);\n this.amap.setZoomAndCenter(15, searchMarker.getPosition());\n this.drawType == 'point' && (this.drawLayersInfo = searchInfo);\n // this.$emit('getAMapLayersInfo', this.drawLayersInfo)\n },\n /** 检测覆盖物配置信息并同步 */\n setOverlayOptions(options) {\n if (!this.drawLayers) return;\n this.drawCount > 1 ? this.drawLayers.forEach(drawItem => drawItem.setOptions(options)) : this.drawLayers.setOptions(options);\n },\n /** 绘制限定区域 */\n setDrawLimitArea() {\n let areaRange = [];\n try {\n areaRange = JSON.parse(this.drawLimitArea);\n } catch {\n areaRange = this.drawLimitArea;\n }\n this.drawArea && this.amap.remove(this.drawArea);\n /** 判断目前地图上存在的所绘制覆盖物是否在限制范围内 */\n this.setMapArea(areaRange);\n this.judgeOverlays();\n },\n /** 绘制地图区域范围 */\n setMapArea(jurisdictionRange) {\n this.drawArea = new AMap.Polygon({\n map: this.amap,\n path: jurisdictionRange,\n extData: 'Area',\n strokeWeight: 6,\n ...this.drawLimitAreaOptions\n });\n const {\n lng,\n lat\n } = this.drawArea.getBounds().getCenter();\n this.amap.setZoomAndCenter(15, [lng, lat]);\n },\n /** 判断一个线段是否在面内 */\n islineInRing(polyline) {\n const paths = polyline.getPath();\n return paths.every(pointItem => this.ispointInRing(pointItem));\n },\n /** 判断一个点是否在面内 */\n ispointInRing(point) {\n let position;\n try {\n position = point.getPosition();\n } catch {\n position = point;\n }\n return AMap.GeometryUtil.isPointInRing(position, this.drawArea.getPath());\n },\n /** 判断地图上所覆盖物是否在限制范围内 */\n judgeOverlays() {\n this.amap.getAllOverlays().forEach(layerItem => layerItem.getExtData() != 'Area' && !this[`is${this.drawType}InRing`](layerItem) && this.removeOverlay(layerItem));\n },\n /** 清除单个覆盖物(或 不符合区域范围的覆盖物 */\n removeOverlay(layerItem) {\n this.amap.remove(layerItem);\n this.$message.error('未在区域范围内,请重新描绘!');\n try {\n const i = this.drawLayers.findIndex(layer => layer.getExtData() == layerItem.getExtData());\n this.drawLayers.splice(i, 1);\n } catch {\n this.drawLayers = null;\n this.drawLayersInfo = {};\n }\n },\n /** 根据类型处理不同数据 */\n setDrawLayers(drawType) {\n const type = {\n point: 'marker',\n line: 'polyline',\n polygon: 'polygon'\n };\n\n /** 图层基础配置 */\n const drawOptions = drawType == 'point' ? {\n anchor: 'bottom-center',\n icon: layers.setIcon(this.drawIcon)\n } : {\n strokeWeight: 8\n };\n this.drawMouseTool[type[drawType]]({\n ...drawOptions,\n ...this.drawOptions\n });\n },\n /** 赋值不同图层数据 */\n assignDrawLayers(drawType) {\n if (drawType == 'point') {\n const {\n lng,\n lat\n } = this.drawLayers.getPosition();\n const position = {\n longitude: lng,\n latitude: lat\n };\n methods.getMapAddress(position, address => {\n this.drawLayersInfo = {\n ...position,\n ...address\n };\n });\n return;\n }\n const range = this.drawLayers.getPath().map(({\n lng,\n lat\n }) => [lng, lat]);\n this.drawLayersInfo = {\n range\n };\n },\n /** 回显不同类型图层 */\n echoDrawLayers(drawType) {\n const drawLayersItem = (drawItem, type, i = 0) => {\n // && drawItem.latitude && drawItem.longitude 忘记当时为什么加这个了 后续在想\n if (drawItem && this.amap) {\n let layersItem = null;\n const {\n longitude,\n latitude,\n range\n } = drawItem;\n const setOptions = {\n extData: `draw${type}${i}`,\n ...this.drawOptions\n };\n if (type == 'point') {\n layersItem = layers.setMarker(this.drawIcon, {\n position: [longitude, latitude],\n ...setOptions\n });\n } else {\n const options = {\n path: range,\n strokeWeight: 8,\n ...setOptions\n };\n layersItem = type == 'line' ? new AMap.Polyline(options) : new AMap.Polygon(options);\n }\n layersItem.setMap(this.amap);\n this.amap.setFitView();\n }\n };\n if (!this.isExhibition) {\n drawLayersItem(this.drawLayersInfo, drawType);\n return;\n }\n if (this.drawInfoAll) {\n for (let key in this.drawInfoAll) {\n const isArray = Array.isArray(this.drawInfoAll[key]);\n isArray ? this.drawInfoAll[key].forEach((drawItem, i) => {\n drawLayersItem(drawItem, key, i);\n }) : drawLayersItem(this.drawInfoAll[key], key);\n }\n return;\n }\n drawLayersItem(this.drawLayersInfo, drawType);\n }\n },\n render(h) {\n const {\n drawEl,\n drawIcon,\n buttonProps,\n isExhibition,\n AmapDrawClear,\n searchChoose\n } = this;\n return h(\"div\", {\n \"class\": \"AmapDraw\"\n }, [!isExhibition && h(_components_AmapSearch_index_jsx__WEBPACK_IMPORTED_MODULE_5__[\"default\"], {\n \"props\": {\n ...{\n drawIcon,\n buttonProps\n }\n },\n \"on\": {\n ...{\n searchReset: AmapDrawClear,\n searchChoose\n }\n }\n }), h(\"div\", {\n \"attrs\": {\n \"id\": drawEl\n }\n })]);\n }\n};\nAmapDraw.install = function (Vue) {\n Vue.component('AmapDraw', AmapDraw);\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = (AmapDraw);\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } }, 1);\n\n//# sourceURL=webpack://mui/./plugins/lib/amap/AmapDraw.jsx?");
8718
8718
 
8719
8719
  /***/ }),
8720
8720
 
@@ -8725,7 +8725,7 @@ eval("__webpack_require__.a(module, async function (__webpack_handle_async_depen
8725
8725
  /***/ (function(module, __webpack_exports__, __webpack_require__) {
8726
8726
 
8727
8727
  "use strict";
8728
- eval("__webpack_require__.a(module, async function (__webpack_handle_async_dependencies__, __webpack_async_result__) { try {\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AmapSearchProps: function() { return /* binding */ AmapSearchProps; }\n/* harmony export */ });\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.iterator.constructor.js */ \"./node_modules/core-js/modules/es.iterator.constructor.js\");\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var core_js_modules_es_iterator_find_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.iterator.find.js */ \"./node_modules/core-js/modules/es.iterator.find.js\");\n/* harmony import */ var core_js_modules_es_iterator_find_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_find_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ant-design-vue/es/_util/vue-types */ \"./node_modules/ant-design-vue/es/_util/vue-types/index.js\");\n/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../index */ \"./plugins/lib/index.js\");\n/* harmony import */ var _method_AMap_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @/method/AMap.js */ \"./plugins/method/AMap.js\");\n/* harmony import */ var _index_less__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./index.less */ \"./plugins/lib/amap/components/AmapSearch/index.less\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_index__WEBPACK_IMPORTED_MODULE_2__]);\n_index__WEBPACK_IMPORTED_MODULE_2__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];\n\n\n\n\n\n\nconst {\n ASelectCustom\n} = _index__WEBPACK_IMPORTED_MODULE_2__.FormComp;\nconst {\n methods,\n layers\n} = await (0,_method_AMap_js__WEBPACK_IMPORTED_MODULE_3__.getAMapInstance)();\nconst AmapSearchProps = {\n /** 搜索后绘制图标 */\n drawIcon: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_5__[\"default\"].any,\n buttonProps: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_5__[\"default\"].array.def([])\n};\nconst AmapSearch = {\n name: 'AmapSearch',\n props: AmapSearchProps,\n data() {\n return {\n searchMarker: null,\n addressValue: undefined,\n selectOptions: []\n };\n },\n methods: {\n /** 选择地址 */\n changeHandle() {\n if (!this.addressValue) return this.$emit('searchReset', this.searchMarker), this.searchMarker = null;\n const {\n label,\n location\n } = this.selectOptions.find(({\n id\n }) => id == this.addressValue);\n const searchInfo = {\n longitude: location.lng,\n latitude: location.lat,\n address: label\n };\n this.searchMarker = layers.setMarker(this.drawIcon, {\n position: [location.lng, location.lat]\n });\n this.$emit('searchChoose', this.searchMarker, searchInfo);\n },\n /** 根据搜索框搜索地址 */\n searchHandle(keyword) {\n methods.getMapSearch(keyword, addressOptions => {\n this.selectOptions = addressOptions;\n });\n }\n },\n render(h) {\n const {\n selectOptions,\n changeHandle,\n searchHandle,\n buttonProps\n } = this;\n const props = {\n valueKey: 'id',\n labelKey: 'label',\n options: selectOptions,\n placeholder: '请输入目的地进行搜索'\n };\n return h(\"div\", {\n \"class\": \"AmapDraw__Search\"\n }, [h(ASelectCustom, {\n \"props\": {\n ...props\n },\n \"on\": {\n ...{\n change: changeHandle,\n search: searchHandle\n }\n },\n \"model\": {\n value: this.addressValue,\n callback: $$v => {\n this.addressValue = $$v;\n }\n }\n }), buttonProps && h(_index__WEBPACK_IMPORTED_MODULE_2__.Button, {\n \"attrs\": {\n \"buttonProps\": buttonProps\n },\n \"class\": \"AmapDraw__Search__Button\"\n })]);\n }\n};\nAmapSearch.install = function (Vue) {\n Vue.component('AmapSearch', AmapSearch);\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = (AmapSearch);\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } }, 1);\n\n//# sourceURL=webpack://mui/./plugins/lib/amap/components/AmapSearch/index.jsx?");
8728
+ eval("__webpack_require__.a(module, async function (__webpack_handle_async_dependencies__, __webpack_async_result__) { try {\n__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ AmapSearchProps: function() { return /* binding */ AmapSearchProps; }\n/* harmony export */ });\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! core-js/modules/es.iterator.constructor.js */ \"./node_modules/core-js/modules/es.iterator.constructor.js\");\n/* harmony import */ var core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_constructor_js__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var core_js_modules_es_iterator_find_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! core-js/modules/es.iterator.find.js */ \"./node_modules/core-js/modules/es.iterator.find.js\");\n/* harmony import */ var core_js_modules_es_iterator_find_js__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(core_js_modules_es_iterator_find_js__WEBPACK_IMPORTED_MODULE_1__);\n/* harmony import */ var ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ant-design-vue/es/_util/vue-types */ \"./node_modules/ant-design-vue/es/_util/vue-types/index.js\");\n/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../index */ \"./plugins/lib/index.js\");\n/* harmony import */ var _method_AMap_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../../method/AMap.js */ \"./plugins/method/AMap.js\");\n/* harmony import */ var _index_less__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./index.less */ \"./plugins/lib/amap/components/AmapSearch/index.less\");\nvar __webpack_async_dependencies__ = __webpack_handle_async_dependencies__([_index__WEBPACK_IMPORTED_MODULE_2__]);\n_index__WEBPACK_IMPORTED_MODULE_2__ = (__webpack_async_dependencies__.then ? (await __webpack_async_dependencies__)() : __webpack_async_dependencies__)[0];\n\n\n\n\n\n\nconst {\n ASelectCustom\n} = _index__WEBPACK_IMPORTED_MODULE_2__.FormComp;\nconst {\n methods,\n layers\n} = await (0,_method_AMap_js__WEBPACK_IMPORTED_MODULE_3__.getAMapInstance)();\nconst AmapSearchProps = {\n /** 搜索后绘制图标 */\n drawIcon: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_5__[\"default\"].any,\n buttonProps: ant_design_vue_es_util_vue_types__WEBPACK_IMPORTED_MODULE_5__[\"default\"].array.def([])\n};\nconst AmapSearch = {\n name: 'AmapSearch',\n props: AmapSearchProps,\n data() {\n return {\n searchMarker: null,\n addressValue: undefined,\n selectOptions: []\n };\n },\n methods: {\n /** 选择地址 */\n changeHandle() {\n if (!this.addressValue) return this.$emit('searchReset', this.searchMarker), this.searchMarker = null;\n const {\n label,\n location\n } = this.selectOptions.find(({\n id\n }) => id == this.addressValue);\n const searchInfo = {\n longitude: location.lng,\n latitude: location.lat,\n address: label\n };\n this.searchMarker = layers.setMarker(this.drawIcon, {\n position: [location.lng, location.lat]\n });\n this.$emit('searchChoose', this.searchMarker, searchInfo);\n },\n /** 根据搜索框搜索地址 */\n searchHandle(keyword) {\n methods.getMapSearch(keyword, addressOptions => {\n this.selectOptions = addressOptions;\n });\n }\n },\n render(h) {\n const {\n selectOptions,\n changeHandle,\n searchHandle,\n buttonProps\n } = this;\n const props = {\n valueKey: 'id',\n labelKey: 'label',\n options: selectOptions,\n placeholder: '请输入目的地进行搜索'\n };\n return h(\"div\", {\n \"class\": \"AmapDraw__Search\"\n }, [h(ASelectCustom, {\n \"props\": {\n ...props\n },\n \"on\": {\n ...{\n change: changeHandle,\n search: searchHandle\n }\n },\n \"model\": {\n value: this.addressValue,\n callback: $$v => {\n this.addressValue = $$v;\n }\n }\n }), buttonProps && h(_index__WEBPACK_IMPORTED_MODULE_2__.Button, {\n \"attrs\": {\n \"buttonProps\": buttonProps\n },\n \"class\": \"AmapDraw__Search__Button\"\n })]);\n }\n};\nAmapSearch.install = function (Vue) {\n Vue.component('AmapSearch', AmapSearch);\n};\n/* harmony default export */ __webpack_exports__[\"default\"] = (AmapSearch);\n__webpack_async_result__();\n} catch(e) { __webpack_async_result__(e); } }, 1);\n\n//# sourceURL=webpack://mui/./plugins/lib/amap/components/AmapSearch/index.jsx?");
8729
8729
 
8730
8730
  /***/ }),
8731
8731
 
package/method/AMap.js ADDED
@@ -0,0 +1,347 @@
1
+ // amap-plugin.js
2
+ import AMapLoader from '@amap/amap-jsapi-loader'
3
+
4
+ let AMapKey = null
5
+ let AMapStyle = null
6
+ let AMapInstance = null
7
+
8
+ // 安全配置 / 地图样式配置
9
+ export const setAMapSecurity = ({key, style, securityJsCode}) => {
10
+ AMapKey = key
11
+ AMapStyle = style
12
+ /** 设置高德地图密钥 */
13
+ window.forceWebGL = true
14
+ window._AMapSecurityConfig = { securityJsCode }
15
+ }
16
+
17
+ // 核心地图服务类
18
+ class AMapService {
19
+ constructor(AMap) {
20
+ this.AMap = AMap
21
+ this._iconCache = new Map() // 图标缓存
22
+
23
+ /** 常用覆盖物 */
24
+ this.layers = {
25
+ setIcon: this.setIcon.bind(this),
26
+ setMarker: this.setMarker.bind(this),
27
+ setInfoWindow: this._createInfoWindowHandler()
28
+ }
29
+
30
+ /** 抛出地图常用方法 */
31
+ this.methods = {
32
+ getMapAddress: this.getMapAddress.bind(this),
33
+ getMapSearch: this.getMapSearch.bind(this),
34
+ setMapDriving: this.setMapDriving.bind(this),
35
+ drawMapAnimation,
36
+ parseRouteToPath,
37
+ getOverlayPos
38
+ }
39
+
40
+ }
41
+
42
+ /** 初始化地图 */
43
+ initMap(container, options = {}) {
44
+ const map = new this.AMap.Map(container, {
45
+ zoom: 13,
46
+ zooms: [3, 20],
47
+ pitch: 30,
48
+ rotation: -15,
49
+ viewMode: '3D',
50
+ mapStyle: AMapStyle,
51
+ ...options
52
+ })
53
+
54
+ options.zoomTool && map.addControl(new this.AMap.ToolBar())
55
+ options.directionTool && map.addControl(new this.AMap.ControlBar())
56
+
57
+ return map
58
+ }
59
+
60
+ /** 格式化地图经纬度 */
61
+ setLngLat(position) {
62
+ return new this.AMap.LngLat(position[0], position[1])
63
+ }
64
+
65
+ /** 创建信息窗口处理器(柯里化函数) */
66
+ _createInfoWindowHandler() {
67
+ return (Vue) => {
68
+ if (!Vue || !Vue.extend) {
69
+ throw new Error('必须传入有效的Vue构造函数')
70
+ }
71
+
72
+ return ({component, props, options = {}}) => {
73
+ if (!component) throw new Error('component参数必填')
74
+
75
+ const InfoWindowComponent = Vue.extend(component)
76
+ const instance = new InfoWindowComponent({
77
+ propsData: props
78
+ }).$mount(document.createElement('div'))
79
+
80
+ return new this.AMap.InfoWindow({
81
+ isCustom: true,
82
+ content: instance.$el,
83
+ ...options
84
+ })
85
+ }
86
+ }
87
+ }
88
+
89
+ /** 带缓存的图标创建方法 */
90
+ async setIcon(iconUrl) {
91
+ if (this._iconCache.has(iconUrl)) {
92
+ return this._iconCache.get(iconUrl)
93
+ }
94
+
95
+ return new Promise((resolve, reject) => {
96
+ const icon = new this.AMap.Icon({
97
+ image: iconUrl,
98
+ imageOffset: new this.AMap.Pixel(0, 0)
99
+ })
100
+
101
+ const img = new Image()
102
+ img.onload = () => {
103
+ const size = new this.AMap.Size(img.width, img.height)
104
+ icon.setSize(size)
105
+ icon.setImageSize(size)
106
+ this._iconCache.set(iconUrl, icon)
107
+ resolve(icon)
108
+ }
109
+ img.onerror = () => reject(new Error(`图标加载失败: ${iconUrl}`))
110
+ img.src = iconUrl
111
+ })
112
+ }
113
+
114
+ /** 增强的标记点创建方法 */
115
+ async setMarker(iconUrl, options = {}) {
116
+ try {
117
+ const icon = await this.setIcon(iconUrl)
118
+ const marker = new this.AMap.Marker({
119
+ anchor: 'bottom-center',
120
+ ...options,
121
+ icon
122
+ })
123
+ return marker
124
+ } catch (error) {
125
+ console.error('创建标记点失败:', error)
126
+ throw error
127
+ }
128
+ }
129
+
130
+ /** 地图逆地理编码 */
131
+ getMapAddress({longitude, latitude}, callBack) {
132
+ return new Promise((resolve, reject) => {
133
+ const geocoder = new this.AMap.Geocoder({
134
+ city: '全国',
135
+ extensions: 'all'
136
+ })
137
+
138
+ geocoder.getAddress([longitude, latitude], (status, result) => {
139
+ if (status === 'complete' && result.info === 'OK') {
140
+ const { formattedAddress, pois } = result.regeocode
141
+ const { district, township } = result.regeocode.addressComponent
142
+ const division = township && formattedAddress.includes(township)
143
+ ? formattedAddress.indexOf(township) + township.length
144
+ : formattedAddress.indexOf(district) + district.length
145
+
146
+ const addressMsg = {
147
+ address: formattedAddress.slice(0, division) + (pois[0]?.address || ''),
148
+ addressInfo: result.regeocode.addressComponent
149
+ }
150
+
151
+ callBack?.(addressMsg)
152
+ resolve(addressMsg)
153
+ } else {
154
+ reject(new Error('转换失败'))
155
+ }
156
+ })
157
+ })
158
+ }
159
+
160
+ /** 根据地址搜索地图poi点及其他信息 */
161
+ /**
162
+ *
163
+ * @param {*} keywords 根据关键字搜索
164
+ * @param {*} callBack 查询成功后过滤信息及转换格式 传递回调函数 兼容老版本代码
165
+ */
166
+ getMapSearch(keywords, callBack) {
167
+ return new Promise((resolve) => {
168
+ const placeSearch = new this.AMap.PlaceSearch()
169
+ placeSearch.search(keywords, (status, searchList) => {
170
+ const options = searchList?.poiList?.pois?.map(node => ({
171
+ ...node,
172
+ label: `${node.name}(${node.address})`
173
+ })) || []
174
+ callBack?.(options)
175
+ resolve(options)
176
+ })
177
+ })
178
+ }
179
+
180
+ /** 道路规划 */
181
+ /**
182
+ *
183
+ * @param {*} AMapInit 当前地图实例
184
+ * @param {*} paths 需查询的路径起始点及途径点集合
185
+ * @param {*} roadOptions 路线规划的其他参数
186
+ * { paths: 需查询的路径起始点及途径点集合, options: 为查询路线配置项 }
187
+ * @param {*} callBack 查询成功后回调函数 兼容老版本代码
188
+ */
189
+ async setMapDriving(mapInstance, roadOptions, callBack) {
190
+ const { paths, options = {} } = roadOptions
191
+ return new Promise((resolve) => {
192
+ mapInstance.plugin("AMap.Driving", () => {
193
+ const driving = new this.AMap.Driving({
194
+ map: mapInstance,
195
+ ...options
196
+ })
197
+
198
+ driving.search(
199
+ this.setLngLat(paths[0]),
200
+ this.setLngLat(paths[paths.length - 1]),
201
+ {
202
+ waypoints: paths.slice(1, -1).map(path => this.setLngLat(path))
203
+ },
204
+ (status, {routes}) => status === 'complete' && (
205
+ callBack?.(roadDriving, routes),
206
+ resolve({ driving, routes })
207
+ )
208
+ )
209
+ })
210
+ })
211
+ }
212
+
213
+ // 其他方法保持类似改造...
214
+ }
215
+
216
+ // 获取AMap实例(组件内使用)
217
+ export const getAMapInstance = async (options = {}) => {
218
+ if (AMapInstance) return AMapInstance
219
+
220
+ try {
221
+ const AMap = await AMapLoader.load({
222
+ key: AMapKey,
223
+ version: '2.0',
224
+ plugins: [
225
+ 'AMap.Geocoder',
226
+ 'AMap.PlaceSearch', // 搜索
227
+ 'AMap.MouseTool', // 鼠标
228
+ 'AMap.ControlBar', // 方向盘
229
+ 'AMap.ToolBar', // 缩放
230
+ ...(options.plugins || [])
231
+ ]
232
+ })
233
+ AMapInstance = new AMapService(AMap)
234
+ return AMapInstance
235
+ } catch (e) {
236
+ throw new Error(`高德地图加载失败: ${e.message}`)
237
+ }
238
+ }
239
+
240
+ // 在 Vue 插件中封装高德地图的初始化和常用方法
241
+ export default {
242
+ async install(Vue, options = {}) {
243
+
244
+ const amap = await getAMapInstance(options)
245
+
246
+ const { AMap, methods, layers } = amap
247
+
248
+ Vue.prototype.$amap = AMap
249
+
250
+ /** 初始化地图 */
251
+ Vue.prototype.$initAMap = (mapOptions, callBack) => {
252
+ const amapInit = amap.initMap(
253
+ mapOptions.el,
254
+ mapOptions.options || {}
255
+ )
256
+ /** 兼容之前版本代码 */
257
+ callBack?.(amapInit)
258
+ return amapInit
259
+ }
260
+
261
+ /** 地图加载完成 */
262
+ Vue.prototype.$amapBus.$emit('onAMapMounted')
263
+
264
+ /** 常用覆盖物 */
265
+ Vue.prototype.$amapLayers = {
266
+ ...layers,
267
+ setInfoWindow: layers.setInfoWindow(Vue)
268
+ }
269
+
270
+ /** 抛出地图常用方法 */
271
+ Vue.prototype.$amapMethods = methods || {}
272
+
273
+ }
274
+ }
275
+
276
+ /**
277
+ * 安全获取覆盖物坐标信息
278
+ * @param {AMap.Overlay} overlay 地图覆盖物实例
279
+ * @returns {Array<Array<number>>} 坐标点数组
280
+ */
281
+ function getOverlayPos(overlay) {
282
+ if (!overlay) throw new Error('覆盖物实例不存在')
283
+
284
+ try {
285
+ return overlay.type === 'AMap.Marker'
286
+ ? [overlay.getPosition().lng, overlay.getPosition().lat]
287
+ : overlay.getPath().map(({lng, lat}) => [lng, lat])
288
+ } catch (e) {
289
+ console.error('转换失败', e)
290
+ return []
291
+ }
292
+ }
293
+
294
+ /**
295
+ * 轨迹动画执行器
296
+ * @param {AMap.Map} AMapInit 地图实例
297
+ * @param {AMap.Marker} animationMarker 动画标记物
298
+ * @param {Array<Array<number>>} paths 路径坐标数组
299
+ * @param {Object} [options] 动画配置
300
+ * @param {Function} [callBack] 动画完成回调
301
+ */
302
+ function drawMapAnimation(AMapInit, animationMarker, paths, options = {}, callBack) {
303
+ if (!AMapInit || !animationMarker || !paths?.length) {
304
+ return console.error('缺少参数信息')
305
+ }
306
+
307
+ AMapInit.plugin('AMap.MoveAnimation', () => {
308
+ const defaultOptions = {
309
+ duration: 500,
310
+ autoRotation: true,
311
+ ...options
312
+ }
313
+
314
+ animationMarker.moveAlong(paths, defaultOptions)
315
+ callBack?.(animationMarker)
316
+ })
317
+ }
318
+
319
+ /**
320
+ * 转换导航路线为可绘制路径
321
+ * @param {AMap.DrivingRoute} route 导航路线对象
322
+ * @returns {{
323
+ * path: Array<Array<number>>,
324
+ * approachPoints: Array<number>
325
+ * }}
326
+ */
327
+ function parseRouteToPath(route) {
328
+ if (!route?.steps) return { path: [], approachPoints: [] }
329
+
330
+ const result = {
331
+ path: [],
332
+ approachPoints: []
333
+ }
334
+
335
+ route.steps.forEach((step, stepIndex) => {
336
+ step.path.forEach((point, pointIndex) => {
337
+ result.path.push([point.lng, point.lat])
338
+
339
+ if (step.assistant_action === "到达途经地" &&
340
+ pointIndex === step.path.length - 1) {
341
+ result.approachPoints.push(result.path.length - 1)
342
+ }
343
+ })
344
+ })
345
+
346
+ return result
347
+ }
@@ -0,0 +1,134 @@
1
+ import Modal from 'ant-design-vue/es/modal'
2
+ import {Brower} from './lib/index.js'
3
+
4
+ const defaultComponents = {
5
+ Brower
6
+ }
7
+
8
+ export default Vue => {
9
+ function dialog(component, componentProps, modalProps) {
10
+ const _vm = this
11
+ if (!_vm || !_vm._isVue) {
12
+ return
13
+ }
14
+ let dialogDiv = document.querySelector('body>div[type=dialog]')
15
+ if (!dialogDiv) {
16
+ dialogDiv = document.createElement('div')
17
+ dialogDiv.setAttribute('type', 'dialog')
18
+ document.body.appendChild(dialogDiv)
19
+ }
20
+
21
+ const handle = function (checkFunction, afterHandel) {
22
+ if (checkFunction instanceof Function) {
23
+ const res = checkFunction()
24
+ if (res instanceof Promise) {
25
+ res.then(c => {
26
+ c && afterHandel()
27
+ })
28
+ } else {
29
+ res && afterHandel()
30
+ }
31
+ } else {
32
+ // checkFunction && afterHandel()
33
+ checkFunction || afterHandel()
34
+ }
35
+ }
36
+
37
+ const dialogInstance = new Vue({
38
+ data() {
39
+ return {
40
+ visible: true
41
+ }
42
+ },
43
+ router: _vm.$router,
44
+ store: _vm.$store,
45
+ mounted() {
46
+ this.$on('close', () => {
47
+ this.handleClose()
48
+ })
49
+ },
50
+ methods: {
51
+ handleClose() {
52
+ handle(this.$refs._component.onCancel, () => {
53
+ this.visible = false
54
+ this.$refs._component.$emit('close')
55
+ this.$refs._component.$emit('cancel')
56
+ dialogInstance.$destroy()
57
+ })
58
+ },
59
+ handleOk() {
60
+ handle(this.$refs._component.onOK || this.$refs._component.onOk, () => {
61
+ this.visible = false
62
+ this.$refs._component.$emit('close')
63
+ this.$refs._component.$emit('ok')
64
+ dialogInstance.$destroy()
65
+ })
66
+ }
67
+ },
68
+ render: function (h) {
69
+ const that = this
70
+ const modalModel = modalProps && modalProps.model
71
+ if (modalModel) {
72
+ delete modalProps.model
73
+ }
74
+ const ModalProps = Object.assign({}, (modalModel && { model: modalModel }) || {}, {
75
+ attrs: Object.assign(
76
+ {},
77
+ {
78
+ ...(modalProps.attrs || modalProps)
79
+ },
80
+ {
81
+ visible: this.visible
82
+ }
83
+ ),
84
+ on: Object.assign(
85
+ {},
86
+ {
87
+ ...(modalProps.on || modalProps)
88
+ },
89
+ {
90
+ ok: () => {
91
+ that.handleOk()
92
+ },
93
+ cancel: () => {
94
+ that.handleClose()
95
+ }
96
+ }
97
+ )
98
+ })
99
+
100
+ const componentModel = componentProps && componentProps.model
101
+ if (componentModel) {
102
+ delete componentProps.model
103
+ }
104
+ const ComponentProps = Object.assign({}, (componentModel && { model: componentModel }) || {}, {
105
+ ref: '_component',
106
+ attrs: Object.assign(
107
+ {},
108
+ {
109
+ ...((componentProps && componentProps.attrs) || componentProps)
110
+ }
111
+ ),
112
+ on: Object.assign(
113
+ {},
114
+ {
115
+ ...((componentProps && componentProps.on) || componentProps)
116
+ }
117
+ )
118
+ })
119
+
120
+ const componentContent = component instanceof String ? defaultComponents[ component ] : component
121
+
122
+ return h(Modal, ModalProps, [h(componentContent, ComponentProps)])
123
+ }
124
+ }).$mount(dialogDiv)
125
+ }
126
+
127
+ Object.defineProperty(Vue.prototype, '$dialog', {
128
+ get: () => {
129
+ return function () {
130
+ dialog.apply(this, arguments)
131
+ }
132
+ }
133
+ })
134
+ }
@@ -0,0 +1,106 @@
1
+ import { Spin } from 'ant-design-vue'
2
+
3
+ export const PageLoading = {
4
+ name: 'PageLoading',
5
+ props: {
6
+ tip: {
7
+ type: String,
8
+ default: 'Loading..'
9
+ },
10
+ size: {
11
+ type: String,
12
+ default: 'large'
13
+ }
14
+ },
15
+ render () {
16
+ const style = {
17
+ textAlign: 'center',
18
+ background: 'rgba(0,0,0,0.6)',
19
+ position: 'fixed',
20
+ top: 0,
21
+ bottom: 0,
22
+ left: 0,
23
+ right: 0,
24
+ zIndex: 1100
25
+ }
26
+ const spinStyle = {
27
+ position: 'absolute',
28
+ left: '50%',
29
+ top: '40%',
30
+ transform: 'translate(-50%, -50%)'
31
+ }
32
+ return (<div style={style}>
33
+ <Spin size={this.size} style={spinStyle} tip={this.tip} />
34
+ </div>)
35
+ }
36
+ }
37
+
38
+ const version = '0.0.1'
39
+ const loading = {}
40
+
41
+ loading.newInstance = (Vue, options) => {
42
+ let loadingElement = document.querySelector('body>div[type=loading]')
43
+ if (!loadingElement) {
44
+ loadingElement = document.createElement('div')
45
+ loadingElement.setAttribute('type', 'loading')
46
+ loadingElement.setAttribute('class', 'ant-loading-wrapper')
47
+ document.body.appendChild(loadingElement)
48
+ }
49
+
50
+ const cdProps = Object.assign({ visible: false, size: 'large', tip: 'Loading...' }, options)
51
+
52
+ const instance = new Vue({
53
+ data () {
54
+ return {
55
+ ...cdProps
56
+ }
57
+ },
58
+ render () {
59
+ const { tip } = this
60
+ const props = {}
61
+ this.tip && (props.tip = tip)
62
+ if (this.visible) {
63
+ return <PageLoading { ...{ props } } />
64
+ }
65
+ return null
66
+ }
67
+ }).$mount(loadingElement)
68
+
69
+ function update (config) {
70
+ const { visible, size, tip } = { ...cdProps, ...config }
71
+ instance.$set(instance, 'visible', visible)
72
+ if (tip) {
73
+ instance.$set(instance, 'tip', tip)
74
+ }
75
+ if (size) {
76
+ instance.$set(instance, 'size', size)
77
+ }
78
+ }
79
+
80
+ return {
81
+ instance,
82
+ update
83
+ }
84
+ }
85
+
86
+ const api = {
87
+ show: function (options) {
88
+ this.instance.update({ ...options, visible: true })
89
+ },
90
+ hide: function () {
91
+ this.instance.update({ visible: false })
92
+ }
93
+ }
94
+
95
+ const install = function (Vue, options) {
96
+ if (Vue.prototype.$loading) {
97
+ return
98
+ }
99
+ api.instance = loading.newInstance(Vue, options)
100
+ Vue.prototype.$loading = api
101
+ }
102
+
103
+ export default {
104
+ version,
105
+ install
106
+ }
@@ -0,0 +1,88 @@
1
+ import {toggleTheme} from "@zougt/theme-css-extract-webpack-plugin/dist/toggleTheme"
2
+
3
+ import message from 'ant-design-vue/es/message'
4
+
5
+ const watchTheme = {
6
+ created() {
7
+ /** 全局添加标志变量来控制是否已经添加过监听器 */
8
+ if (!window._storageListenerAdded) {
9
+ /** 监听storage变化 */
10
+ window.addEventListener('storage', this.handleStorageChange)
11
+ window._storageListenerAdded = true
12
+ }
13
+ },
14
+ methods: {
15
+ handleStorageChange(event) {
16
+ // console.log('Storage changed:', event.newValue)
17
+ /** 判断是否为主题key更改并执行资源切换 */
18
+ event.key === 'projectTheme' && this.$setTheme(event.newValue)
19
+ }
20
+ },
21
+ beforeDestroy() {
22
+ /** 销毁标志变量及监听器 */
23
+ if (window._storageListenerAdded) {
24
+ window.removeEventListener('storage', this.handleStorageChange)
25
+ window._storageListenerAdded = false
26
+ }
27
+ }
28
+ }
29
+
30
+ export default {
31
+ install(Vue) {
32
+ /** 判断是否属于内嵌项目 */
33
+ const isHas = window.parent !== window
34
+
35
+ Vue.prototype.$setTheme = function(theme) {
36
+ /** 子项目则只需切换主题资源 */
37
+ if(isHas) {
38
+ return ToggleThemeSource(theme)
39
+ }
40
+ ToggleTheme(theme)
41
+ }
42
+ /** 子项目需挂载监听主题变化自动执行切换 */
43
+ isHas && Vue.mixin(watchTheme)
44
+
45
+ /** 切换当前主题 */
46
+ function ToggleTheme(scopeName) {
47
+ /** 切换主题loading */
48
+ const hideMessage = message.loading('正在切换主题!', 0)
49
+
50
+ ToggleThemeSource(scopeName)
51
+
52
+ const loadingTimer=setTimeout(() => {
53
+ hideMessage()
54
+ clearTimeout(loadingTimer)
55
+ }, 10)
56
+
57
+ Vue.prototype.$store.commit('SET_THEME',scopeName)
58
+ }
59
+
60
+ /** 切换主题资源 */
61
+ function ToggleThemeSource(scopeName) {
62
+ /** 获取初始配置项 */
63
+ // env.themeConfig 来源 vue.config.js define (webpack的DefinePlugin)
64
+ const themeConfig = env.themeConfig
65
+ /** 主题配置
66
+ * @scopeName 名称
67
+ * @multipleScopeVars 主题项
68
+ * @extract 是否提取
69
+ * @publicPath 资源输出路径
70
+ * @outputDir 提取的 css 文件存放目录
71
+ */
72
+ toggleTheme({
73
+ scopeName: `theme-${scopeName}`,
74
+ multipleScopeVars: themeConfig.multipleScopeVars,
75
+ extract: themeConfig.extract,
76
+ publicPath: themeConfig.publicPath,
77
+ outputDir: themeConfig.extractCssOutputDir
78
+ })
79
+
80
+ /** 加载主题对应样式文件 */
81
+ // const requireLess = require.context('@/theme/styles', false, /\.less$/)
82
+ // requireLess(`./${scopeName}.less`)
83
+ let themeLink = document.getElementById('theme-stylesheet')
84
+ themeLink.href = `${process.env.BASE_URL}static/style/${scopeName}.css`
85
+ }
86
+
87
+ }
88
+ }
@@ -0,0 +1,12 @@
1
+ /** 全局便捷弹出框 */
2
+ import Dialog from "./Dialog"
3
+ /** 全局页面加载框 */
4
+ import PageLoading from "./PageLoading"
5
+
6
+ /** 加载便捷弹窗等 */
7
+ export default {
8
+ install(Vue) {
9
+ Vue.use(Dialog)
10
+ Vue.use(PageLoading)
11
+ }
12
+ }
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "web-component-gallery",
3
- "version": "1.2.4",
3
+ "version": "1.2.6",
4
4
  "description": "vue-library-ui组件库",
5
5
  "main": "dist/index.umd.js",
6
6
  "files": [
7
7
  "dist",
8
8
  "plugins",
9
9
  "lib",
10
- "utils"
10
+ "utils",
11
+ "method"
11
12
  ],
12
13
  "scripts": {
13
14
  "serve": "vue-cli-service serve",
@@ -1,6 +1,6 @@
1
1
  import AmapSearch from './components/AmapSearch/index.jsx'
2
2
  import PropTypes from 'ant-design-vue/es/_util/vue-types'
3
- import { getAMapInstance } from '@/method/AMap.js'
3
+ import { getAMapInstance } from '../../method/AMap.js'
4
4
 
5
5
  const amap = await getAMapInstance()
6
6
  const { AMap, methods, layers } = amap
@@ -1,6 +1,6 @@
1
1
  import PropTypes from 'ant-design-vue/es/_util/vue-types'
2
2
  import {FormComp, Button} from '../../../index'
3
- import {getAMapInstance} from '@/method/AMap.js'
3
+ import {getAMapInstance} from '../../../../method/AMap.js'
4
4
 
5
5
  import './index.less'
6
6