Give precedence to feature style
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
goog.provide('ol.layer.Vector');
|
||||
|
||||
goog.require('goog.object');
|
||||
goog.require('ol.feature');
|
||||
goog.require('ol.layer.Layer');
|
||||
goog.require('ol.style.Style');
|
||||
goog.require('ol.style.defaults');
|
||||
|
||||
|
||||
/**
|
||||
@@ -39,21 +40,20 @@ ol.layer.Vector = function(opt_options) {
|
||||
|
||||
/**
|
||||
* User provided style.
|
||||
* @type {ol.style.Style|Array.<ol.style.Style>|ol.feature.StyleFunction}
|
||||
* @type {ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction}
|
||||
* @private
|
||||
*/
|
||||
this.style_ = null;
|
||||
|
||||
/**
|
||||
* Style function for use within the library.
|
||||
* @type {ol.feature.StyleFunction|undefined}
|
||||
* @type {ol.style.StyleFunction|undefined}
|
||||
* @private
|
||||
*/
|
||||
this.styleFunction_ = undefined;
|
||||
|
||||
if (goog.isDef(options.style)) {
|
||||
this.setStyle(options.style);
|
||||
}
|
||||
this.setStyle(goog.isDefAndNotNull(options.style) ?
|
||||
options.style : ol.style.defaults.styleFunction);
|
||||
|
||||
};
|
||||
goog.inherits(ol.layer.Vector, ol.layer.Layer);
|
||||
@@ -72,7 +72,7 @@ ol.layer.Vector.prototype.getRenderOrder = function() {
|
||||
/**
|
||||
* Get the style for features. This returns whatever was passed to the `style`
|
||||
* option at construction or to the `setStyle` method.
|
||||
* @return {ol.style.Style|Array.<ol.style.Style>|ol.feature.StyleFunction}
|
||||
* @return {ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction}
|
||||
* Layer style.
|
||||
* @api
|
||||
*/
|
||||
@@ -83,7 +83,7 @@ ol.layer.Vector.prototype.getStyle = function() {
|
||||
|
||||
/**
|
||||
* Get the style function.
|
||||
* @return {ol.feature.StyleFunction|undefined} Layer style function.
|
||||
* @return {ol.style.StyleFunction|undefined} Layer style function.
|
||||
* @api
|
||||
*/
|
||||
ol.layer.Vector.prototype.getStyleFunction = function() {
|
||||
@@ -104,12 +104,12 @@ ol.layer.Vector.prototype.setRenderOrder = function(renderOrder) {
|
||||
* Set the style for features. This can be a single style object, an array
|
||||
* of styles, or a function that takes a feature and resolution and returns
|
||||
* an array of styles.
|
||||
* @param {ol.style.Style|Array.<ol.style.Style>|ol.feature.StyleFunction} style
|
||||
* @param {ol.style.Style|Array.<ol.style.Style>|ol.style.StyleFunction} style
|
||||
* Layer style.
|
||||
* @api
|
||||
*/
|
||||
ol.layer.Vector.prototype.setStyle = function(style) {
|
||||
this.style_ = style;
|
||||
this.styleFunction_ = ol.feature.createStyleFunction(style);
|
||||
this.styleFunction_ = ol.style.createStyleFunction(style);
|
||||
this.dispatchChangeEvent();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user