Skip to content

Commit

Permalink
Provide a default style function
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaub committed Feb 20, 2014
1 parent dc5c713 commit 0015331
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/ol/feature.js
Expand Up @@ -7,6 +7,9 @@ goog.require('goog.events.EventType');
goog.require('goog.functions');
goog.require('ol.Object');
goog.require('ol.geom.Geometry');
goog.require('ol.style.Circle');
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');


Expand Down Expand Up @@ -213,12 +216,35 @@ ol.feature.FeatureStyleFunction;


/**
* Default style function for features.
* @param {number} resolution Resolution.
* @return {Array.<ol.style.Style>} Style.
* @this {ol.Feature}
* @todo stability experimental
*/
ol.feature.defaultFeatureStyleFunction = goog.functions.constant([]);
ol.feature.defaultFeatureStyleFunction = (function() {
var fill = new ol.style.Fill({
color: 'rgba(255,255,255,0.4)'
});
var stroke = new ol.style.Stroke({
color: '#3399CC',
width: 1.25
});
var styles = [
new ol.style.Style({
image: new ol.style.Circle({
fill: fill,
stroke: stroke,
radius: 5
}),
fill: fill,
stroke: stroke
})
];
return function(resolution) {
return styles;
};
})();


/**
Expand Down

3 comments on commit 0015331

@petrsloup
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks the Legacy IE support (#1605) since the ol.style.Circle constructor results in a call of canvas.getContext(...) (https://github.com/openlayers/ol3/blob/master/src/ol/style/circlestyle.js#L191)

@tschaub
Copy link
Member Author

@tschaub tschaub commented on 0015331 Mar 3, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be avoided by deferring rendering until the getImage call. This (and other legacy IE support issues) should be considered in #1763 (where ol.style.Shape would replace ol.style.Circle).

@petrsloup
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe this should also be optimized if ol.ENABLE_VECTOR == false.

Please sign in to comment.