【问题标题】:How to check if a layer is in the user's view: openlayers如何检查图层是否在用户的视图中:openlayers
【发布时间】:2021-07-03 15:20:42
【问题描述】:

我的某些功能只有在用户的视野中才会出现,我该怎么做Image of a polygon that needs to be removed if it is off-screen of the user

【问题讨论】:

标签: javascript html maps openlayers tiles


【解决方案1】:

判断一个特征是否在视口中

var visibleExtent = map.getView().calculateExtent();

if (feature.getGeometry().intersectsExtent(visibleExtent)) {
  // feature is visible to user
}

请注意,如果旋转视图,可能会出现一些误报。它们可以通过测试旋转的几何形状和范围来消除,如本例https://openlayers.org/en/latest/examples/box-selection.html

【讨论】:

  • 原来如此!非常感谢!
猜你喜欢
  • 2012-11-22
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-11-17
  • 2023-03-14
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多