Fix IIFE invoking Canvas APIs that don't exist in early IE
Changed ol.interaction.Draw.defaultStyleFunction to be a getter, so that it only calls Canvas APIs when needed, rather than on script load
This commit is contained in:
@@ -148,18 +148,16 @@ ol.interaction.Draw = function(opt_options) {
|
||||
*/
|
||||
this.overlay_ = new ol.render.FeaturesOverlay();
|
||||
this.overlay_.setStyleFunction(goog.isDef(opt_options.styleFunction) ?
|
||||
opt_options.styleFunction : ol.interaction.Draw.defaultStyleFunction
|
||||
opt_options.styleFunction : ol.interaction.Draw.getDefaultStyleFunction()
|
||||
);
|
||||
};
|
||||
goog.inherits(ol.interaction.Draw, ol.interaction.Interaction);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @param {number} resolution Resolution.
|
||||
* @return {Array.<ol.style.Style>} Styles.
|
||||
* @return {ol.feature.StyleFunction} Styles.
|
||||
*/
|
||||
ol.interaction.Draw.defaultStyleFunction = (function() {
|
||||
ol.interaction.Draw.getDefaultStyleFunction = function() {
|
||||
/** @type {Object.<ol.geom.GeometryType, Array.<ol.style.Style>>} */
|
||||
var styles = {};
|
||||
styles[ol.geom.GeometryType.POLYGON] = [
|
||||
@@ -210,7 +208,7 @@ ol.interaction.Draw.defaultStyleFunction = (function() {
|
||||
return function(feature, resolution) {
|
||||
return styles[feature.getGeometry().getType()];
|
||||
};
|
||||
})();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user