[英]How to get bounds of OrthographicView with deck.gl
我想制作OrthographicView
的迷你地图并绘制边界路径。
我可以获得具有width
、 height
、 target
和zoom
的viewState
。 但是如何获取或计算bounds
(当前视图的上、右、下、左坐标)?
当您收到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.