feat(projects): 新增腾讯地图插件

This commit is contained in:
Soybean 2021-11-10 00:38:23 +08:00
parent ea82edc114
commit 3f02c215c5
5 changed files with 32 additions and 4 deletions

View File

@ -10,7 +10,8 @@ module.exports = {
withDefaults: 'readonly',
PROJECT_BUILD_TIME: 'readonly',
AMap: 'readonly',
BMap: 'readonly'
BMap: 'readonly',
TMap: 'readonly'
},
parser: 'vue-eslint-parser',
parserOptions: {

View File

@ -3,3 +3,6 @@ export const BAIDU_MAP_SDK_URL =
'https://api.map.baidu.com/getscript?v=3.0&ak=KSezYymXPth1DIGILRX3oYN9PxbOQQmU&services=&t=20210201100830&s=1';
/** 高德地图sdk地址 */
export const GAODE_MAP_SDK_URL = 'https://webapi.amap.com/maps?v=2.0&key=e7bd02bd504062087e6563daf4d6721d';
/** 腾讯地图sdk地址 */
export const TENCENT_MAP_SDK_URL = 'https://map.qq.com/api/gljs?v=1.exp&key=A6DBZ-KXPLW-JKSRY-ONZF4-CPHY3-K6BL7';

1
src/typings/tmap.d.ts vendored Normal file
View File

@ -0,0 +1 @@
declare const TMap: any;

View File

@ -1,6 +1,29 @@
<template>
<div>地图</div>
<div ref="domRef" class="w-full max-h-480px"></div>
</template>
<script setup lang="ts"></script>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { useScriptTag } from '@vueuse/core';
import { TENCENT_MAP_SDK_URL } from '@/settings';
const { load } = useScriptTag(TENCENT_MAP_SDK_URL);
const domRef = ref<HTMLDivElement | null>(null);
async function renderBaiduMap() {
await load(true);
const map = new TMap.Map(domRef.value!, {
center: new TMap.LatLng(39.98412, 116.307484),
zoom: 11,
viewMode: '3D'
});
return map;
}
onMounted(() => {
renderBaiduMap();
});
</script>
<style scoped></style>

View File

@ -1,5 +1,5 @@
<template>
<div>
<div class="overflow-hidden">
<n-card title="地图插件" class="h-full shadow-sm rounded-16px">
<n-tabs type="line" class="flex-col-stretch h-full" pane-class="flex-1-hidden">
<n-tab-pane v-for="item in maps" :key="item.id" :name="item.id" :tab="item.label">