使用esri-loader时,当试图使用下面的视图创建SceneView时,视图无法正确计算缩放,我在控制台中得到以下错误:
[esri.views.3d.support.cameraUtils] #zoomToScale() Cannot compute scale from zoom without a tiling scheme client-hook-3.js:1 [esri.views.3d.state.ViewStateManager] #zoom= Invalid zoom 3
let map = new WebMap({
portalItem: {
id: MAP_ID_HERE
}
});
let view = new SceneView({
container: "map",
viewingMode: "local",
map: map,
zoom: 3
});有没有人碰巧知道是什么导致了这一切?纵观SceneView的文档,这似乎在构造函数中是有效的。
发布于 2020-10-12 16:30:52
我认为在这种情况下,使用web地图作为地图,您必须等待视图加载才能设置缩放级别。如果没有,它将无法计算标度,这是错误的原因。
这应该能行,
let view = new SceneView({
container: "map",
map: map,
viewingMode: "local"
});
view.when(function() {
view.zoom = 3;
});更新:(保留其他代码,因为我认为它澄清了问题和最终答案)
嗯,这似乎还不够等待视图,因为基本地图不能加载所有的东西。所以这里有一个可行的替代方案,
const basemap = Basemap.fromId("dark-gray-vector");
const sceneView = new SceneView({
container: this.$el,
map: new WebMap({
basemap,
}),
center: [US_CENTER.longtitude, US_CENTER.latitude],
viewingMode: "local"
});
basemap.loadAll().then(
() => {
sceneView.goTo({ zoom: 3 });
}
);在这个新的解决方案中,我们实际上要等到basemap加载所有内容(使用loadAll方法),然后设置视图的缩放。
这是Map.vue中的完整代码,
<template>
<div />
</template>
<script>
import { loadArcGISModules } from "@deck.gl/arcgis";
const US_CENTER = { longtitude: -98.5795, latitude: 39.8283 };
export default {
name: "Map",
props: {},
mounted() {
loadArcGISModules(
[
"esri/WebMap",
"esri/views/SceneView",
"esri/Basemap",
],
{ css: true }
).then(({ DeckRenderer, modules }) => {
const [WebMap, SceneView, Basemap] = modules;
const basemap = Basemap.fromId("dark-gray-vector");
const sceneView = new SceneView({
container: this.$el,
map: new WebMap({
basemap,
}),
center: [US_CENTER.longtitude, US_CENTER.latitude],
viewingMode: "local"
});
basemap.loadAll().then(
() => {
sceneView.goTo({ zoom: 3 });
}
);
});
},
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
div {
width: 100%;
height: 100%;
}
</style>https://stackoverflow.com/questions/64320036
复制相似问题