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