Move defaults style into style.js

This commit is contained in:
Antoine Abt
2014-07-25 09:50:53 +02:00
parent 16cdd35f6d
commit 4b8ceca8eb
6 changed files with 48 additions and 54 deletions

View File

@@ -1,43 +0,0 @@
goog.provide('ol.style.defaults');
goog.require('ol.style.Circle');
goog.require('ol.style.Fill');
goog.require('ol.style.Stroke');
goog.require('ol.style.Style');
/**
* @param {ol.Feature} feature Feature.
* @param {number} resolution Resolution.
* @return {Array.<ol.style.Style>} Style.
*/
ol.style.defaults.styleFunction = function(feature, resolution) {
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
})
];
// now that we've run it the first time,
// replace the function with a constant version
ol.style.defaults.styleFunction =
/** @type {function(this:ol.Feature):Array.<ol.style.Style>} */(
function(resolution) {
return styles;
});
return styles;
};

View File

@@ -2,8 +2,10 @@ goog.provide('ol.style.Style');
goog.require('goog.asserts');
goog.require('goog.functions');
goog.require('ol.style.Circle');
goog.require('ol.style.Fill');
goog.require('ol.style.Image');
goog.require('ol.style.Stroke');
@@ -139,3 +141,40 @@ ol.style.createStyleFunction = function(obj) {
}
return styleFunction;
};
/**
* @param {ol.Feature} feature Feature.
* @param {number} resolution Resolution.
* @return {Array.<ol.style.Style>} Style.
*/
ol.style.defaultStyleFunction = function(feature, resolution) {
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
})
];
// now that we've run it the first time,
// replace the function with a constant version
ol.style.defaultStyleFunction =
/** @type {function(this:ol.Feature):Array.<ol.style.Style>} */(
function(resolution) {
return styles;
});
return styles;
};