From 0a7a5941495105fba711572bc5edde44d5e6a99a Mon Sep 17 00:00:00 2001 From: cuishu <979962021@qq.com> Date: Sun, 7 Dec 2025 18:48:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=87=AA=E5=8A=A8=E5=AE=9A?= =?UTF-8?q?=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.vue | 26 ++++++++++++++++++++++++-- vite.config.js | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/App.vue b/src/App.vue index ccd60b2..bee00b7 100644 --- a/src/App.vue +++ b/src/App.vue @@ -132,7 +132,7 @@ import DroneCtrl, { UploadAreaReq } from 'DroneCtrl'; -const ctrl = new DroneCtrl.default(getConfig()); +const ctrl = new DroneCtrl(getConfig()); // 地图相关 const mapContainer = ref(null) @@ -171,10 +171,32 @@ const initMap = async () => { map = new AMap.Map('map-container', { viewMode: '3D', zoom: 13, - center: [116.397428, 39.90923], // 默认北京天安门 + // center: [116.397428, 39.90923], // 默认北京天安门 mapStyle: 'amap://styles/normal' }) + AMap.plugin('AMap.Geolocation', function () { + // 插件加载完成后才能使用 + const geolocation = new AMap.Geolocation({ + enableHighAccuracy: true, + timeout: 10000, + maximumAge: 0, + convert: true, + showButton: false + }); + + map.addControl(geolocation); + + // 获取当前位置 + geolocation.getCurrentPosition(function (status, result) { + if (status === 'complete') { + console.log('定位成功:', result.position.lng, result.position.lat); + } else { + console.error('定位失败:', result); + } + }); + }); + // 创建鼠标工具实例 mouseTool = new AMap.MouseTool(map) diff --git a/vite.config.js b/vite.config.js index bbcf80c..01fe5bd 100644 --- a/vite.config.js +++ b/vite.config.js @@ -4,4 +4,5 @@ import vue from '@vitejs/plugin-vue' // https://vite.dev/config/ export default defineConfig({ plugins: [vue()], + base: "/web/", })