From 8a596e551468e3ad949d9437e9c85d955bdab64a Mon Sep 17 00:00:00 2001 From: wangxiang <1827945911@qq.com> Date: Thu, 1 Sep 2022 06:31:02 +0800 Subject: [PATCH] =?UTF-8?q?:rocket:=20=E5=9C=B0=E5=9B=BE=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E8=B0=83=E6=95=B4=E5=AE=8C=E6=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AMap/src/AMapDesigner/index.vue | 45 ++++++++++++------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/src/components/AMap/src/AMapDesigner/index.vue b/src/components/AMap/src/AMapDesigner/index.vue index 845a021..65ff78c 100644 --- a/src/components/AMap/src/AMapDesigner/index.vue +++ b/src/components/AMap/src/AMapDesigner/index.vue @@ -12,7 +12,7 @@ @reset="handleMapReset" />
-
+
@@ -124,6 +124,11 @@ }, toolbarHeight: propTypes.number.def(48), toolbarControl: propTypes.bool.def(true), + mapControl: { + type: Array as PropType, + default: () => ['toolBar', 'controlBar', 'scale', 'mapType'] + }, + navigatePanel: propTypes.bool.def(true) }); let map; @@ -248,21 +253,29 @@ // 创建地图实例 map = new AMap.Map(instance.refs.mapview, mapState.mapConfig.options); map.plugin(['AMap.ToolBar', 'AMap.MapType', 'AMap.ControlBar', 'AMap.Scale'], () => { - // 地图操作工具条插件 - map.addControl(new AMap.ToolBar()); - // 组合了旋转,倾斜,复位,缩放插件 - map.addControl(new AMap.ControlBar()); - // 比例尺插件 - const scale = new AMap.Scale(); - scale.show(); - map.addControl(scale); - // 地图类型切换插件 - map.addControl( - new AMap.MapType({ - defaultType: 0, - showRoad: true - }) - ); + if (mapProps.mapControl?.includes('toolBar')) { + // 地图操作工具条插件 + map.addControl(new AMap.ToolBar()); + } + if (mapProps.mapControl?.includes('controlBar')) { + // 组合了旋转,倾斜,复位,缩放插件 + map.addControl(new AMap.ControlBar()); + } + if (mapProps.mapControl?.includes('scale')) { + // 比例尺插件 + const scale = new AMap.Scale(); + scale.show(); + map.addControl(scale); + } + if (mapProps.mapControl?.includes('mapType')) { + // 地图类型切换插件 + map.addControl( + new AMap.MapType({ + defaultType: 0, + showRoad: true + }) + ); + } }); map.on('zoomchange', ctx => { mapState.defaultZoom = subtract(divide(map.getZoom(),2), 1);