From 2c2bc8614c8ea0ce386369eb4924da1e6aa052d1 Mon Sep 17 00:00:00 2001
From: husq <931347610@qq.com>
Date: Wed, 27 Sep 2023 09:35:57 +0800
Subject: [PATCH] 添加环境配置区分
---
src/hooks/use-g-map.ts | 43 ++++++++++++++++++++++---------------------
1 files changed, 22 insertions(+), 21 deletions(-)
diff --git a/src/hooks/use-g-map.ts b/src/hooks/use-g-map.ts
index 463529a..ec26d55 100644
--- a/src/hooks/use-g-map.ts
+++ b/src/hooks/use-g-map.ts
@@ -10,35 +10,36 @@
})
async function initMap (container: string, app:App) {
- return new Promise((resolve, reject) => {
- AMapLoader.load({
- ...AMapConfig
- }).then((AMap) => {
- console.log(AMap, 'AMap')
- state.aMap = AMap
- state.map = new AMap.Map(container, {
- center: [113.943225499, 22.577673716],
- zoom: 15
- })
- state.mouseTool = new AMap.MouseTool(state.map)
-
- // 挂在到全局
- app.config.globalProperties.$aMap = state.aMap
- app.config.globalProperties.$map = state.map
- app.config.globalProperties.$mouseTool = state.mouseTool
- resolve(state.map)
- }).catch(e => {
- console.log(e)
- reject(e)
+ AMapLoader.load({
+ ...AMapConfig
+ }).then((AMap) => {
+ state.aMap = AMap
+ state.map = new AMap.Map(container, {
+ center: [115.85666327144976, 28.62452712442823],
+ zoom: 15
})
+ state.mouseTool = new AMap.MouseTool(state.map)
+ // 挂在到全局
+ app.config.globalProperties.$aMap = state.aMap
+ app.config.globalProperties.$map = state.map
+ app.config.globalProperties.$mouseTool = state.mouseTool
+ }).catch(e => {
+ console.log(e)
})
}
function globalPropertiesConfig (app:App) {
initMap('g-container', app)
}
-
+ async function setCenter (position: any) {
+ state.map?.setCenter(position)
+ }
+ function getCenter () {
+ const center = state.map?.getCenter()
+ }
return {
globalPropertiesConfig,
+ setCenter,
+ getCenter
}
}
--
Gitblit v1.9.3