From 1d23229d987072b272d3df9f731bf98a2376d2cc Mon Sep 17 00:00:00 2001 From: ahocevar Date: Tue, 12 Nov 2013 01:47:43 +0100 Subject: [PATCH] Allow to set the layer style By firing a simple CHANGE event, we can redraw the layer when a style is assigned. --- src/ol/layer/vectorlayer.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ol/layer/vectorlayer.js b/src/ol/layer/vectorlayer.js index f67fba7ba0..48c90a2817 100644 --- a/src/ol/layer/vectorlayer.js +++ b/src/ol/layer/vectorlayer.js @@ -261,6 +261,17 @@ ol.layer.Vector.prototype.getStyle = function() { }; +/** + * Set a style for this layer. + * @param {ol.style.Style} style Style. + */ +ol.layer.Vector.prototype.setStyle = function(style) { + this.style_ = style; + this.dispatchEvent( + new ol.layer.VectorEvent(ol.layer.VectorEventType.CHANGE, [], [])); +}; + + /** * Returns an array of features that match a filter. This will not fetch data, * it only considers features that are loaded already.