openlayer 获取当前视图窗口内的要素


//监听分辨率变化
Map.map.getView().on('change:resolution', function(){
var zoom = Map.map.getView().getZoom();
if(zoom>=10){
console.info("当前层级:"+zoom);
var extent =Map.map.getView().calculateExtent(Map.map.getSize());
console.info(extent);
var features = parent.GlobalOLTOWER.tower_750.getSource().getFeaturesInExtent(extent); //先缩小feature的范围
console.info(features);
}else{
console.info("层级未达到")
}
});

//监听地图实时的 extent
Map.map.on('moveend', function () {
var zoom = Map.map.getView().getZoom();
if(zoom>=10){
console.info("当前层级:"+zoom);
var extent =Map.map.getView().calculateExtent(Map.map.getSize());
console.info(extent);
var features = parent.GlobalOLTOWER.tower_750.getSource().getFeaturesInExtent(extent); //先缩小feature的范围
console.info(features);
}else{
console.info("层级未达到")
}
});


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM