0
votes

In OpenLayers 2D maps there's a property called restricted extent that doesn't allow to pan or zoom outside a defined bounding box.

Can I make something similar with Google Earth Plugin in 3D?

Obviously the problem is that one can bend (incline) the view, something that cant be achieved in 2D. I have already restricted the view if thers no bend or incline in the map but that's far from being what I want..

Thanks!!

Update 1:

By now I have restricted the bbox with a handler on viewchangeend event, if the actual viewport (north, south, east, west) is outside some predefined initial values I move the view to the initial position again.

var viewchangeend = function viewchangeendhandler(){
    var actualViewport = {
        north: ge.getView().getViewportGlobeBounds().getNorth(),
        south: ge.getView().getViewportGlobeBounds().getSouth(),
        east: ge.getView().getViewportGlobeBounds().getEast(),
        west: ge.getView().getViewportGlobeBounds().getWest()
    };

    if (actualViewport.north > initialViewport.north || actualViewport.south < initialViewport.south ||
            actualViewport.east > initialViewport.east || actualViewport.west < initialViewport.west){

        var la = ge.createLookAt('');
        la.set(initialX, initialY, 0, ge.ALTITUDE_RELATIVE_TO_GROUND, 0 , 0, 50000);
        ge.getView().setAbstractView(la);
    }
}

For example in the initial case where I dont incline the view the relation north-south (north minus south) is static, but when I incline the view the relation grows and the initial viewport cannot be used to know if the actual viewport is ok.

Thanks again!

1
why don't you tell us what you are already doing so we can offer advice on how to extend it - lifeIsGood
there I update the ask with my initial code.. Thanks! - gonzalomelov

1 Answers

0
votes

Perhaps you should consider using hitTest() instead of getViewportGlobeBounds()

See this SO Question which links to this Google Example

Have a play with the Google Example by tilting the view and see the resulting difference between the two