RuralDatabase/apps/web/components/section/map.vue

44 lines
1.0 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<script setup>
import AMapLoader from '@amap/amap-jsapi-loader'
let map = null
onMounted(() => {
window._AMapSecurityConfig = {
securityJsCode: '9aad85b4c92b1748b8cb0d8bd414ca9e',
}
AMapLoader.load({
key: '430671d37976cde7b1a74a4272b931b5', // 申请好的Web端开发者Key首次调用 load 时必填
version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: [], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
})
.then((AMap) => {
map = new AMap.Map('container', {
// 设置地图容器id
viewMode: '3D', // 是否为3D地图模式
zoom: 11, // 初始化地图级别
mapStyle: 'amap://styles/darkblue',
center: [116.397428, 39.90923], // 初始化地图中心点位置
})
})
.catch((e) => {
console.log(e)
})
})
onUnmounted(() => {
map?.destroy()
})
</script>
<template>
<div id="container" />
</template>
<style scoped>
#container {
width: 100%;
height: 100%
}
</style>