feat(projects): 新增腾讯地图插件
This commit is contained in:
parent
ea82edc114
commit
3f02c215c5
@ -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: {
|
||||
|
@ -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
1
src/typings/tmap.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
declare const TMap: any;
|
@ -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>
|
||||
|
@ -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">
|
||||
|
Loading…
Reference in New Issue
Block a user