Question

I've been searching through documentation and examples, but I don't see any good demos showing me what I would like to do:

How do I restrict the view in World Wind Java to a specific region? As in allowing the user to move the world around, but only through a small area. Removing the ability to move the camera and setting the view to a specific position would work in my case, but it seems like such a waste of the incredible viewing functionalities of WWJ to do so.

Was it helpful?

Solution

There is actually an example of how to do this in gov.nasa.worldwindx.examples (I was only looking through demos): ViewLimits.

One can cast the WorldWindowGLCanvas's view to an OrbitView. Then limits can be applied as such:

OrbitView viewbounds = (OrbitView)wwd.getView();
if (viewbounds != null)
{
    OrbitViewLimits limits = viewbounds.getOrbitViewLimits();
    if (limits != null)
    {
        viewLimit = new Sector();// Fill with appropriate bounds
        limits.setCenterLocationLimits(viewLimit);
        limits.setPitchLimits(Angle.fromDegrees(0), Angle.fromDegrees(90));
        //^in degrees downward from looking directly at the earth
        limits.setHeadingLimits(Angle.ZERO, Angle.ZERO);// rotation cw or ccw
        limits.setZoomLimits(minZoom, maxZoom);// in meters
        BasicOrbitViewLimits.applyLimits(viewbounds, limits);
    }
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top