mardi 24 mars 2015

Openlayers 3 binding a checkbox to a Vector layer for visibility

I'm trying to bind a checkbox to a vector layer for the 'visible' property and it's not working; easy points to whoever spots my typo :)


The thing is, this works for ol.layer.Tile, but not ol.layer.Vector, and only the visible checkbox doesn't work. 'opacity' works fine.



var li = document.createElement('li');
var checkbox = document.createElement('input');
checkbox.setAttribute('type','checkbox');
checkbox.setAttribute('checked',true);
li.appendChild(checkbox);
var label = document.createElement('label');
label.appendChild(document.createTextNode(layer.get("title")));
li.appendChild(label);
var range = document.createElement('input');
range.setAttribute('type','range');
range.setAttribute('min','0');
range.setAttribute('max','1');
range.setAttribute('step','0.01');
range.setAttribute('value','1');
li.appendChild(range);

new ol.dom.Input(range).bindTo('value',layer,'opacity');
new ol.dom.Input(checkbox).bindTo('checked',layer,'visible');




Aucun commentaire:

Enregistrer un commentaire