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

使用namespace

parent 5c0ff280
......@@ -15,9 +15,9 @@
<script lang="ts" setup>
import icon1 from '@/assets/images/icon1.png'
import MyMap from '@/my-map/my-map'
import useMap from '@/my-map'
import { MyMap } from '@/my-map'
import { nextTick, onMounted } from 'vue'
let map: MyMap
let pointsLayer: any
let linesLayer: any
......@@ -26,24 +26,24 @@ let polygonLayer: any
onMounted(async () => {
await nextTick()
map = useMap('SMap').with({
el: 'container',
center: [0, 0],
zoom: 5,
style: 'smap://styles/dark',
appKey: 'ACF69EDK17LON63GHPF081',
netType: 'internet',
})
// map = useMap('AIMap').with({
// map = MyMap.useMap('SMap').with({
// el: 'container',
// center: [121.612846, 31.205494],
// zoom: 13,
// style: 'aimap://styles/aimap/darkblue-v4',
// appKey: 'gt8XidVe5upHf7cirkJwwXTCWj20zfu3',
// baseApiUrl: 'https://location-dev.newayz.com',
// center: [0, 0],
// zoom: 5,
// style: 'smap://styles/dark',
// appKey: 'ACF69EDK17LON63GHPF081',
// 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
.on('load', addControls)
.on('click', (a, b) => console.log(a, b))
......
import { AIMapConfig, MapConfig, SMapConfig } from './types'
import type MapType from './my-map'
import S_Map from './s-map'
import AI_Map from './ai-map'
......@@ -19,17 +20,20 @@ const whichMap = {
},
}
/**
* 创建地图
* @param key 地图关键字:
*
* 'SMap': 测绘院地图
*
* 'AIMap': 维智地图
*
*/
export default function useMap<K extends keyof typeof whichMap>(key: K) {
return whichMap[key]
export type MyMap = MapType
export namespace MyMap {
/**
* 创建地图
* @param key 地图关键字:
*
* 'SMap': 测绘院地图
*
* 'AIMap': 维智地图
*
*/
export function useMap<K extends keyof typeof whichMap>(key: K) {
return whichMap[key]
}
}
// 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