简体   繁体   English

如何使用 deck.gl 获取 OrthographicView 的边界

[英]How to get bounds of OrthographicView with deck.gl

I'd like to make a minimap of OrthographicView and draw the bounds path.我想制作OrthographicView的迷你地图并绘制边界路径。

I can get the viewState which has its width , height , target , and zoom .我可以获得具有widthheighttargetzoomviewState But how can I get or compute the bounds (top, right, bottom, left coordinates of current view)?但是如何获取或计算bounds (当前视图的上、右、下、左坐标)?

When you receive a viewState , you can get the bounds with the following code:当您收到viewState时,您可以使用以下代码获取边界:

const viewportBounds = () => {
    const { width, height } = viewState.main;
    if (!width) return null;
    const view = new OrthographicView(viewState.main);
    const viewport = view._getViewport();

    const topLeft = viewport.unproject([0, 0]);
    const topRight = viewport.unproject([width, 0]);
    const bottomLeft = viewport.unproject([0, height]);
    const bottomRight = viewport.unproject([width, height]);

    return [[topLeft, topRight, bottomRight, bottomLeft, topLeft]];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM