Dynamic layers and lazy selection layer creation

With this change, the user provides a filter function instead of
an array of layers. Selection layers are created lazily, and
addition/removal of layers is not handled by the control to give
the user more options, as suggested by @elemoine.
This commit is contained in:
ahocevar
2013-08-22 19:29:08 +02:00
parent a417b75c1f
commit c6e61e2d23
4 changed files with 54 additions and 89 deletions

View File

@@ -46,7 +46,9 @@ var vector = new ol.layer.Vector({
})
});
var selectControl = new ol.control.Select({layers: [vector]});
var selectControl = new ol.control.Select({
layerFilter: function(layer) { return layer === vector; }
});
var map = new ol.Map({
controls: ol.control.defaults().extend([selectControl]),