marsgis / mars3d

【Mars3D平台 】主仓库,包含所有开源仓库清单导航
http://mars3d.cn
Apache License 2.0
977 stars 137 forks source link

map.addLayer API 返回的 Promise 不会完成 #21

Closed FirokOtaku closed 1 year ago

FirokOtaku commented 1 year ago

调用 map.addLayer(layer) API 返回的 Promise 对象永远不会被 resolvereject.

最小复现代码:

<style scoped>
</style>

<template>
    <div>
        <div id="mars3dContainer" class="mars3d-container"></div>
    </div>
</template>

<script setup>
import {markRaw, onMounted, onUnmounted} from 'vue'
// 引入cesium基础库
import 'mars3d-cesium/Build/Cesium/Widgets/widgets.css'
import * as Cesium from 'mars3d-cesium'
// 导入mars3d主库
import 'mars3d/dist/mars3d.css'
import * as mars3d from 'mars3d'

let Map = null
onMounted(async () => {
    let map = new mars3d.Map('mars3dContainer')
    Map = markRaw(map)
    let layer = new mars3d.layer.GraphicLayer()
    console.log('开始添加图层')
    let result = await map.addLayer(layer)
    console.log('完成添加图层')
})
onUnmounted(() =>
{
    Map.destroy()
    Map = null
})
</script>

测试时, 后续的 console.log 调用永远不会执行.

测试环境 --
vue 3.2.47
@vitejs/plugin-vue 4.1.0
mars3d 3.5.0
vite-plugin-mars3d 2.0.3
浏览器 Chrome 111.0.5563.110
muyao1987 commented 1 year ago

GraphicLayer的Promise的是未触发,将在v3.5.2版本修复