How to get specific type control?I have tried like below,but always got 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;
}
Try something like this:
var controls = map.getControls(); // this is a ol.Collection
controls.forEach(function(control){
console.info(control instanceof ol.control.Zoom);
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.