Commit 66f7f325 authored by 郭铭瑶's avatar 郭铭瑶 🤘

使用namespace

parent 5c0ff280
...@@ -15,9 +15,9 @@ ...@@ -15,9 +15,9 @@
<script lang="ts" setup> <script lang="ts" setup>
import icon1 from '@/assets/images/icon1.png' import icon1 from '@/assets/images/icon1.png'
import MyMap from '@/my-map/my-map' import { MyMap } from '@/my-map'
import useMap from '@/my-map'
import { nextTick, onMounted } from 'vue' import { nextTick, onMounted } from 'vue'
let map: MyMap let map: MyMap
let pointsLayer: any let pointsLayer: any
let linesLayer: any let linesLayer: any
...@@ -26,24 +26,24 @@ let polygonLayer: any ...@@ -26,24 +26,24 @@ let polygonLayer: any
onMounted(async () => { onMounted(async () => {
await nextTick() await nextTick()
map = useMap('SMap').with({ // map = MyMap.useMap('SMap').with({
el: 'container',
center: [0, 0],
zoom: 5,
style: 'smap://styles/dark',
appKey: 'ACF69EDK17LON63GHPF081',
netType: 'internet',
})
// map = useMap('AIMap').with({
// el: 'container', // el: 'container',
// center: [121.612846, 31.205494], // center: [0, 0],
// zoom: 13, // zoom: 5,
// style: 'aimap://styles/aimap/darkblue-v4', // style: 'smap://styles/dark',
// appKey: 'gt8XidVe5upHf7cirkJwwXTCWj20zfu3', // appKey: 'ACF69EDK17LON63GHPF081',
// baseApiUrl: 'https://location-dev.newayz.com', // netType: 'internet',
// }) // })
map = MyMap.useMap('AIMap').with({
el: 'container',
center: [121.612846, 31.205494],
zoom: 13,
style: 'aimap://styles/aimap/darkblue-v4',
appKey: 'gt8XidVe5upHf7cirkJwwXTCWj20zfu3',
baseApiUrl: 'https://location-dev.newayz.com',
})
map map
.on('load', addControls) .on('load', addControls)
.on('click', (a, b) => console.log(a, b)) .on('click', (a, b) => console.log(a, b))
......
import { AIMapConfig, MapConfig, SMapConfig } from './types' import { AIMapConfig, MapConfig, SMapConfig } from './types'
import type MapType from './my-map'
import S_Map from './s-map' import S_Map from './s-map'
import AI_Map from './ai-map' import AI_Map from './ai-map'
...@@ -19,17 +20,20 @@ const whichMap = { ...@@ -19,17 +20,20 @@ const whichMap = {
}, },
} }
/** export type MyMap = MapType
* 创建地图 export namespace MyMap {
* @param key 地图关键字: /**
* * 创建地图
* 'SMap': 测绘院地图 * @param key 地图关键字:
* *
* 'AIMap': 维智地图 * 'SMap': 测绘院地图
* *
*/ * 'AIMap': 维智地图
export default function useMap<K extends keyof typeof whichMap>(key: K) { *
return whichMap[key] */
export function useMap<K extends keyof typeof whichMap>(key: K) {
return whichMap[key]
}
} }
// function _injectSource(sources: any[]): Promise<unknown[]> { // function _injectSource(sources: any[]): Promise<unknown[]> {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment