Default View Options not Applied on First Render

I’m using Cesium.Camera.DEFAULT_VIEW_FACTOR and Cesium.Camera.DEFAULT_VIEW_RECTANGLE to set initial extent in my 2D map. The first time my map renders, these values exist and are set properly, but the display does not reflect that. When I call a function to reload my viewer, then the display reflects the default view values.

How can I ensure that the default view values are properly applied to the viewer the first time it is rendered?

First Render:

After Viewer Reloads:

 Cesium.Camera.DEFAULT_VIEW_FACTOR = view;
 Cesium.Camera.DEFAULT_VIEW_RECTANGLE = rectangle;

  var viewer = new Cesium.Viewer("cesiumContainer");
1 Like


I apologize for the late response. This post somehow flew under my radar.

Thank you for sharing this with the community! This is strange behavior that I would like to investigate further. Can you please share a complete sandcastle demo that showcases this issue? Are you switching between a 2D and 3D view? I would love to try this out on my machine.


Same problem ;(

Do you have any solution?



Thank you for your follow-up! If possible, could you please provide some of the details that I asked for above? This information would really help me start debugging the issue.


Hmm. Those two maps are not the same, though. What do you mean by “render”? Are you calling the actual renderer, or is this a browser refresh thing? Do you have the actual code you could share in a Sandcastle? Otherwise helping you is rather tricky.



@sam.rothstein @Alexander_Johannesen Thanks for your responses.

Unfortunately, it would be a bit time-consuming for me to recreate the issue in a sandcastle. I can explain in more detail, though.

I’m using Vue. By initial render, I mean the first time the component loads and my viewer is initialized. I am not listening to any Cesium render events.

I use window dimensions to determine which view factor and rectangle to assign to DEFAULT_VIEW_FACTOR and DEFAULT_VIEW_RECTANGLE, and these are applied in a “loadViewer” function that creates the viewer, etc.

The viewer reinitializes when a watcher property (week time range) changes. So, in the watcher, I destroy my viewer and recreate it with new entities. It is at this point that the default view factor and rectangle are applied properly.

I call the same “loadViewer” function at the initial render and to reinitialize my viewer from the watcher.

@sam.rothstein I am not switching between 2d-3d. The viewer is created with the sceneMode: this.cesium.SceneMode.SCENE2D, option.

So, you’re calling loadViewer multiple times, but since this is where you create the Cesium viewer, does that mean you’re creating the Cesium viewer new every time? Maybe share the “loadViewer” code?