[英]How to get specific type control with openlayers3?
如何獲得特定的類型控件?我曾嘗試如下,但始終為null
function getAttControl(){
var ctrls = map.getControls();
for (var i = 0; i < ctrls.getLength(); i++) {
if (ctrls.get(i) instanceof ol.control.Control) {
return ctrls.get(i);
}
}
return null;
}
嘗試這樣的事情:
var controls = map.getControls(); // this is a ol.Collection
controls.forEach(function(control){
console.info(control instanceof ol.control.Zoom);
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.