zouyaoji / vue-cesium

🎉 Vue 3.x components for CesiumJS.
https://zouyaoji.top/vue-cesium
MIT License
1.43k stars 312 forks source link

[Bug Report] 设置默认imageryProvider提示 Cesium #483

Closed weizheng1992 closed 6 months ago

weizheng1992 commented 7 months ago

VueCesium version

3.2.4

OS/Browsers version

mac/google

Vue version

3.4.0-alpha.4

Cesium version

1.112.0

Reproduction Link

https://codepen.io/spkie/pen/jOdXqxw?editors=1111

Steps to reproduce

使用 :imageryProvider="new Cesium.OpenStreetMapImageryProvider()"

What is Expected?

可以替换默认

What is actually happening?

不能替换

zouyaoji commented 7 months ago

请附错误截图和重现案例

weizheng1992 commented 7 months ago
image

不知道如何修改 imageryProvider 指定初始化时加载的影像

image

https://codepen.io/spkie/pen/jOdXqxw?editors=1111

zouyaoji commented 7 months ago

不推荐这种写法哈。

直接在vc-viewer里面挂一个图层组件即可。

weizheng1992 commented 7 months ago
image

加了图层组建但是,想修改一进页面 默认显示的 NaturalEarthII 影像

zouyaoji commented 7 months ago

在vc-viewer的ready里面去拿到viewer改哈

weizheng1992 commented 7 months ago

因为不想默认加载NaturalEarthII,会闪一下再到百度地图,效果不太好

zouyaoji commented 7 months ago

没遇到过闪的情况呢。

如果你要这么弄就先定义一个const imageryProvider = ref(null) 然后在vc-viewer的cesiumReady中去初始化imageryProvider。 但这样有可能比较卡,如果imageryProvider 很复杂的话。

还看可以试试在index.html中去引入Cesium.js,就可以直接在模板中使用Cesium了。如果不这样写的话只有在cesiumReady之后才拿得到全局的Cesium。

还有个办法可以试一下,就是在vc-viewer的ready事件方法中执行一下 viewer.imageryLayers.removeAll()