2D rotated view - calculation of height to achived desired size of view port


I have the following problem. I know it is more related to geo calculation, projection, etc, however I have not found anywhere a solution.

I am using 2D mode view (Cesium.SceneMode.SCENE2D) that I rotate.

I want to know what height over ellipsoid I shall pass to camera.setView function to see the map that has specified range in X or Y axis (for example 20 km long in horizontal)

Without rotation(i.e. looking North), I figured it out by experimenting (as I lack knowledge on the topic) , that the height is equal to vertical length of the map and the horizontal length is equal to vertical distance * cos(lat).

The problem starts when I apply rotation, as I do not know what calculation is used, i.e. what is the relation between height and lon, lat coordinates passed to setView and the vertical length and horizontal lenfth of my map.

Can someone help me developed the required formula:


lon, lat of camera


map witdth, height in pixels

range of view in meters (in horizontal or verical)


height I shall pass to camera.setView


destination: Cesium.Cartesian3.fromDegrees(lon, lat, HEIGHT ???),

orientation: {

heading: heading,

pitch: -90, // top-down

roll: 0




Hi there,

The Cesium camera flyTo() function actually supports a rectangle as a destination and will position the camera such that that rectangle is visible. Take a look there.


Hope that helps!

  • Rachel

The problem is that you specify west, east, north, south rectangle in flyTo or setView. Once you rorate it (orientation input parameter) the view rectangle points are different and the distance (in meters) between sides changes. I used Cesium as overlay for a map that keeps fixed distance (in meters) between sides of the viewport. So I cannot make the overlay conform with the layer I use until I find a way to calculate the paramters to be used by setview or flyto

Ah, I see. Unfortunately, we don’t have direct support for this. However, you may be able to make a custom function that will use a flyTo rectangle then applies a camera rotation. Perhaps another community member can chime in with a suggestion.


  • Rachel