0

在 OpenLayers 2D 地图中,有一个称为受限范围的属性,它不允许在定义的边界框之外平移或缩放。

我可以在 3D 中使用 Google 地球插件制作类似的东西吗?

显然,问题在于可以弯曲(倾斜)视图,这是 2D 中无法实现的。如果地图上没有弯曲或倾斜,我已经限制了视野,但这远不是我想要的..

谢谢!!

更新1:

到目前为止,我已经使用 viewchangeend 事件的处理程序限制了 bbox,如果实际视口(北、南、东、西)超出了一些预定义的初始值,我将再次将视图移动到初始位置。

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);
    }
}

例如,在我不倾斜视图的初始情况下,南北关系(北减南)是静态的,但是当我倾斜视图时,关系会增长,并且初始视口不能用于了解实际视口是否正常。

再次感谢!

4

1 回答 1

0

也许您应该考虑使用hitTest()而不是getViewportGlobeBounds()

请参阅链接到此Google 示例的此SO 问题

通过倾斜视图来玩一下 Google 示例并查看两者之间的差异

于 2013-03-05T19:49:58.953 回答