Limit zoom and lat/long question?

Hello all,

    I am trying to use Cesium to display satellites at set lat and longs, however it needs to work offline and due to the offline version of the Cesium globe going pixelated if zoomed to far, I am in need to find a way to limit how far in and out the person can zoom the globe, I also need to find a way to take lat/long values taken from google maps and convert that to x, y and z values that come back with the place marker in the same place on the Cesium global as it does in google maps/earth, every time I find a bit of code that does this conversion with Cesium they don't get placed it the correct place.

Any help is much appreciated!

For lat/lon to x/y/z, what you want it cartographicToCartesian (http://cesium.agi.com/Cesium/Build/Documentation/Ellipsoid.html#cartographicToCartesian)

Keep in mind the order of parameters for Cartographic is lon, lat, height; and they are expected to be in radians, not degrees. If you have lat/lon in degrees you can do

var cartographic = Cartographic.fromDegrees(lon, lat);

var cartesian = Ellipsoid.WGS84.cartographicToCartesian(cartographic).

For zoom limiting, this is a little trickier. As part of the render loop, you need to check the position of the camera every frame and set the position to whatever you want whenever it has moved out of bounds. The code to do this will also be different depending on what mode you are in (3D, 2D, or Columbus View)

You can limit the zoom from mouse input by setting the minimumZoomDistance property of the ScreenSpaceCameraController.

scene.getScreenSpaceCameraController ().minimumZoomDistance = minZoom;

If you want to limit the camera position in other ways, you would need to check it in the render loop as Matt suggested.