如何使用 openlayers3 获得特定的类型控制?
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);
});
如何获取特定的类型控制?我试过如下,但总是得到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);
});