| | |
| | | }).then((AMap) => { |
| | | state.aMap = AMap |
| | | state.map = new AMap.Map(container, { |
| | | center: [113.943225499, 22.577673716], |
| | | 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 |
| | |
| | | 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 |
| | | } |
| | | } |