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