Map Scale demo 1:XXXXX

Here is a quick and dirty map scale calculation(the scale is just being written out to the console when the top/left and bottom/left corners are over the earth). I was just looking over the cesium-nav-widget, and that code uses the bottom middle to calculate the diffHeight which works better when zoomed out.

I need to set the scale to 1:50000 for instance, is there an example of reversing the calculations to get the camera position and height? I saw the following:

getRectangleCameraCoordinates(rectangle, result) → Cartesian3

Scene/Camera.js 2199

Get the camera position needed to view an rectangle on an ellipsoid or map

Name
Type
Description
rectangle
Rectangle
The rectangle to view.
result
Cartesian3
optionalThe camera position needed to view the rectangle

Returns:

The camera position needed to view the rectangle

Is there an example of using this function? I’m a little worried about the tilt of the camera, I think in this case(viewing 1:50000) we want to lock the user into a top down mode, but the function doesn’t seem to deal with the rotation.

TIA, Scott

MapScale.html (2.82 KB)

Hi scott, do you havea solution ?

Rüdiger