TaskSystem-admin/src/components/map/MapContainer.vue

39 lines
974 B
Vue
Raw Normal View History

2023-08-17 10:01:53 +08:00
<template>
<div id="container"></div>
</template>
<script lang="ts" setup name="mapContainer">
import AMapLoader from "@amap/amap-jsapi-loader";
import { shallowRef } from "@vue/reactivity";
const map = shallowRef(null);
const initMap = () => {
AMapLoader.load({
key: "", // 申请好的Web端开发者Key首次调用 load 时必填
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15
plugins: [""], // 需要使用的的插件列表,如比例尺'AMap.Scale'等
})
.then((AMap) => {
map = new AMap.Map("container", {
//设置地图容器id
viewMode: "2D", //是否为3D地图模式
zoom: 5, //初始化地图级别
center: [105.602725, 37.076636], //初始化地图中心点位置
});
})
.catch((e) => {
console.log(e);
});
};
</script>
<style lang="scss" scoped>
#container {
padding: 0px;
margin: 0px;
width: 100%;
height: 800px;
}
</style>