mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-12-25 22:30:19 +08:00
feat(projects): 添加百度地图插件
This commit is contained in:
27
src/views/component/map/components/BaiduMap.vue
Normal file
27
src/views/component/map/components/BaiduMap.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<template>
|
||||
<div ref="domRef" class="w-full h-full"></div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, nextTick } from 'vue';
|
||||
import { BAIDU_MAP_SDK_URL } from '@/settings';
|
||||
import { useScript } from '@/hooks';
|
||||
|
||||
const { load } = useScript(BAIDU_MAP_SDK_URL);
|
||||
|
||||
const domRef = ref<HTMLDivElement | null>(null);
|
||||
|
||||
async function renderBaiduMap() {
|
||||
await load();
|
||||
await nextTick();
|
||||
const map = new BMapGL.Map(domRef.value!);
|
||||
const point = new BMapGL.Point(116.404, 39.915);
|
||||
map.centerAndZoom(point, 15);
|
||||
map.enableScrollWheelZoom();
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
renderBaiduMap();
|
||||
});
|
||||
</script>
|
||||
<style scoped></style>
|
||||
Reference in New Issue
Block a user