Static ol.style.Style functions
This commit is contained in:
+11
-10
@@ -1,5 +1,6 @@
|
||||
goog.provide('ol.style.Style');
|
||||
|
||||
goog.require('ol.asserts');
|
||||
goog.require('ol.geom.GeometryType');
|
||||
goog.require('ol.style.Circle');
|
||||
goog.require('ol.style.Fill');
|
||||
@@ -31,7 +32,7 @@ ol.style.Style = function(opt_options) {
|
||||
* @private
|
||||
* @type {!ol.StyleGeometryFunction}
|
||||
*/
|
||||
this.geometryFunction_ = ol.style.defaultGeometryFunction;
|
||||
this.geometryFunction_ = ol.style.Style.defaultGeometryFunction;
|
||||
|
||||
if (options.geometry !== undefined) {
|
||||
this.setGeometry(options.geometry);
|
||||
@@ -159,7 +160,7 @@ ol.style.Style.prototype.setGeometry = function(geometry) {
|
||||
return /** @type {ol.geom.Geometry} */ (feature.get(geometry));
|
||||
};
|
||||
} else if (!geometry) {
|
||||
this.geometryFunction_ = ol.style.defaultGeometryFunction;
|
||||
this.geometryFunction_ = ol.style.Style.defaultGeometryFunction;
|
||||
} else if (geometry !== undefined) {
|
||||
this.geometryFunction_ = function() {
|
||||
return /** @type {ol.geom.Geometry} */ (geometry);
|
||||
@@ -188,7 +189,7 @@ ol.style.Style.prototype.setZIndex = function(zIndex) {
|
||||
* A style function, a single style, or an array of styles.
|
||||
* @return {ol.StyleFunction} A style function.
|
||||
*/
|
||||
ol.style.createStyleFunction = function(obj) {
|
||||
ol.style.Style.createFunction = function(obj) {
|
||||
var styleFunction;
|
||||
|
||||
if (typeof obj === 'function') {
|
||||
@@ -217,7 +218,7 @@ ol.style.createStyleFunction = function(obj) {
|
||||
* @type {Array.<ol.style.Style>}
|
||||
* @private
|
||||
*/
|
||||
ol.style.defaultStyle_ = null;
|
||||
ol.style.Style.default_ = null;
|
||||
|
||||
|
||||
/**
|
||||
@@ -225,13 +226,13 @@ ol.style.defaultStyle_ = null;
|
||||
* @param {number} resolution Resolution.
|
||||
* @return {Array.<ol.style.Style>} Style.
|
||||
*/
|
||||
ol.style.defaultStyleFunction = function(feature, resolution) {
|
||||
ol.style.Style.defaultFunction = function(feature, resolution) {
|
||||
// We don't use an immediately-invoked function
|
||||
// and a closure so we don't get an error at script evaluation time in
|
||||
// browsers that do not support Canvas. (ol.style.Circle does
|
||||
// canvas.getContext('2d') at construction time, which will cause an.error
|
||||
// in such browsers.)
|
||||
if (!ol.style.defaultStyle_) {
|
||||
if (!ol.style.Style.default_) {
|
||||
var fill = new ol.style.Fill({
|
||||
color: 'rgba(255,255,255,0.4)'
|
||||
});
|
||||
@@ -239,7 +240,7 @@ ol.style.defaultStyleFunction = function(feature, resolution) {
|
||||
color: '#3399CC',
|
||||
width: 1.25
|
||||
});
|
||||
ol.style.defaultStyle_ = [
|
||||
ol.style.Style.default_ = [
|
||||
new ol.style.Style({
|
||||
image: new ol.style.Circle({
|
||||
fill: fill,
|
||||
@@ -251,7 +252,7 @@ ol.style.defaultStyleFunction = function(feature, resolution) {
|
||||
})
|
||||
];
|
||||
}
|
||||
return ol.style.defaultStyle_;
|
||||
return ol.style.Style.default_;
|
||||
};
|
||||
|
||||
|
||||
@@ -259,7 +260,7 @@ ol.style.defaultStyleFunction = function(feature, resolution) {
|
||||
* Default styles for editing features.
|
||||
* @return {Object.<ol.geom.GeometryType, Array.<ol.style.Style>>} Styles
|
||||
*/
|
||||
ol.style.createDefaultEditingStyles = function() {
|
||||
ol.style.Style.createDefaultEditing = function() {
|
||||
/** @type {Object.<ol.geom.GeometryType, Array.<ol.style.Style>>} */
|
||||
var styles = {};
|
||||
var white = [255, 255, 255, 1];
|
||||
@@ -332,6 +333,6 @@ ol.style.createDefaultEditingStyles = function() {
|
||||
* for.
|
||||
* @return {ol.geom.Geometry|ol.render.Feature|undefined} Geometry to render.
|
||||
*/
|
||||
ol.style.defaultGeometryFunction = function(feature) {
|
||||
ol.style.Style.defaultGeometryFunction = function(feature) {
|
||||
return feature.getGeometry();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user