Hello,
I was looking for an option that constrain extent.
I want to limit the view. So the camera can move only in a certain boundary.
Please give me a clue.
hello , if your app code is open source please share the github repo or send .zip files on my gmail hrachyaralyan1998@gmail.com
There seems to be no specific way to do this, perhaps you can add a camera movement event, get the camera position every time the camera moves, and then compare it to your extent.
Sorry…the code cannot be opened to the public for security reasons.
Okay, I’ll try.
If there is a sample code you know, please share with me.
Thanks.
var viewer = new Cesium.Viewer('cesiumContainer');
var camera = viewer.camera;
// extent
var minLon = -90;
var maxLon = 90;
var minLat = -45;
var maxLat = 45;
camera.changed.addEventListener(function() {
var position = camera.positionCartographic;
var lon = Cesium.Math.toDegrees(position.longitude);
var lat = Cesium.Math.toDegrees(position.latitude);
// check extent
if (lon < minLon || lon > maxLon || lat < minLat || lat > maxLat) {
// do something ...
}
});
1 Like
Hi there,
This is an ongoing feature request documented in Camera boundry · Issue #4802 · CesiumGS/cesium · GitHub. I’ll add this request to that thread.
Thanks!