This repository has been archived by the owner on Aug 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #225
- Loading branch information
Showing
3 changed files
with
63 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,53 @@ | ||
<script setup> | ||
import { onMounted, onUnmounted } from "vue"; | ||
import AMapLoader from "@amap/amap-jsapi-loader"; | ||
<script lang="ts" setup> | ||
import { onMounted, onUnmounted } from 'vue' | ||
import AMapLoader from '@amap/amap-jsapi-loader' | ||
import '@amap/amap-jsapi-types' | ||
let map = null; | ||
defineProps({ | ||
width: { | ||
type: String, | ||
default: '100%', | ||
}, | ||
height: { | ||
type: String, | ||
default: 'calc(100vh - 90px)', | ||
}, | ||
}) | ||
let map = null | ||
onMounted(() => { | ||
// 您在2021年12月02日以后申请的 key 需要配合您的安全密钥一起使用。 | ||
window._AMapSecurityConfig = { | ||
securityJsCode: "e6cdf70d6db73a22e948ba4addafdddf", | ||
window['_AMapSecurityConfig'] = { | ||
securityJsCode: 'e6cdf70d6db73a22e948ba4addafdddf', | ||
} | ||
AMapLoader.load({ | ||
key: "b3b5ff64593dae7b68d3daef978dbe3a", // 申请好的Web端开发者Key,首次调用 load 时必填 | ||
version: "2.0", // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15 | ||
plugins: ['AMap.Scale'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等 | ||
key: 'b3b5ff64593dae7b68d3daef978dbe3a', // 申请好的Web端开发者Key,首次调用 load 时必填 | ||
version: '2.0', // 指定要加载的 JSAPI 的版本,缺省时默认为 1.4.15 | ||
plugins: ['AMap.Scale', 'AMap.ToolBar', 'AMap.Geolocation'], // 需要使用的的插件列表,如比例尺'AMap.Scale'等 | ||
}) | ||
.then((AMap) => { | ||
map = new AMap.Map("container", { | ||
map = new AMap.Map('container', { | ||
// 设置地图容器id | ||
viewMode: "3D", // 是否为3D地图模式 | ||
viewMode: '3D', // 是否为3D地图模式 | ||
zoom: 11, // 初始化地图级别 | ||
center: [116.397428, 39.90923], // 初始化地图中心点位置 | ||
}); | ||
map.addControl(new AMap.Scale()); | ||
}) | ||
map.addControl(new AMap.Scale()) | ||
map.addControl(new AMap.ToolBar()) | ||
}) | ||
.catch((e) => { | ||
console.log(e); | ||
}); | ||
}); | ||
console.log(e) | ||
}) | ||
}) | ||
onUnmounted(() => { | ||
map?.destroy(); | ||
}); | ||
map?.destroy() | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div id="container"></div> | ||
<div id="container" :style="{ height, width }"></div> | ||
</template> | ||
<style scoped> | ||
#container { | ||
width: 100%; | ||
height: 830px; | ||
} | ||
</style> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.