Remove property enum from base layer constructor
This commit is contained in:
+18
-31
@@ -2,6 +2,7 @@ goog.provide('ol.layer.Base');
|
|||||||
|
|
||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Object');
|
goog.require('ol.Object');
|
||||||
|
goog.require('ol.layer.Property');
|
||||||
goog.require('ol.math');
|
goog.require('ol.math');
|
||||||
goog.require('ol.obj');
|
goog.require('ol.obj');
|
||||||
|
|
||||||
@@ -27,15 +28,15 @@ ol.layer.Base = function(options) {
|
|||||||
* @type {Object.<string, *>}
|
* @type {Object.<string, *>}
|
||||||
*/
|
*/
|
||||||
var properties = ol.obj.assign({}, options);
|
var properties = ol.obj.assign({}, options);
|
||||||
properties[ol.layer.Base.Property.OPACITY] =
|
properties[ol.layer.Property.OPACITY] =
|
||||||
options.opacity !== undefined ? options.opacity : 1;
|
options.opacity !== undefined ? options.opacity : 1;
|
||||||
properties[ol.layer.Base.Property.VISIBLE] =
|
properties[ol.layer.Property.VISIBLE] =
|
||||||
options.visible !== undefined ? options.visible : true;
|
options.visible !== undefined ? options.visible : true;
|
||||||
properties[ol.layer.Base.Property.Z_INDEX] =
|
properties[ol.layer.Property.Z_INDEX] =
|
||||||
options.zIndex !== undefined ? options.zIndex : 0;
|
options.zIndex !== undefined ? options.zIndex : 0;
|
||||||
properties[ol.layer.Base.Property.MAX_RESOLUTION] =
|
properties[ol.layer.Property.MAX_RESOLUTION] =
|
||||||
options.maxResolution !== undefined ? options.maxResolution : Infinity;
|
options.maxResolution !== undefined ? options.maxResolution : Infinity;
|
||||||
properties[ol.layer.Base.Property.MIN_RESOLUTION] =
|
properties[ol.layer.Property.MIN_RESOLUTION] =
|
||||||
options.minResolution !== undefined ? options.minResolution : 0;
|
options.minResolution !== undefined ? options.minResolution : 0;
|
||||||
|
|
||||||
this.setProperties(properties);
|
this.setProperties(properties);
|
||||||
@@ -96,7 +97,7 @@ ol.layer.Base.prototype.getLayerStatesArray = function(opt_states) {};
|
|||||||
*/
|
*/
|
||||||
ol.layer.Base.prototype.getExtent = function() {
|
ol.layer.Base.prototype.getExtent = function() {
|
||||||
return /** @type {ol.Extent|undefined} */ (
|
return /** @type {ol.Extent|undefined} */ (
|
||||||
this.get(ol.layer.Base.Property.EXTENT));
|
this.get(ol.layer.Property.EXTENT));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -108,7 +109,7 @@ ol.layer.Base.prototype.getExtent = function() {
|
|||||||
*/
|
*/
|
||||||
ol.layer.Base.prototype.getMaxResolution = function() {
|
ol.layer.Base.prototype.getMaxResolution = function() {
|
||||||
return /** @type {number} */ (
|
return /** @type {number} */ (
|
||||||
this.get(ol.layer.Base.Property.MAX_RESOLUTION));
|
this.get(ol.layer.Property.MAX_RESOLUTION));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ ol.layer.Base.prototype.getMaxResolution = function() {
|
|||||||
*/
|
*/
|
||||||
ol.layer.Base.prototype.getMinResolution = function() {
|
ol.layer.Base.prototype.getMinResolution = function() {
|
||||||
return /** @type {number} */ (
|
return /** @type {number} */ (
|
||||||
this.get(ol.layer.Base.Property.MIN_RESOLUTION));
|
this.get(ol.layer.Property.MIN_RESOLUTION));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -131,7 +132,7 @@ ol.layer.Base.prototype.getMinResolution = function() {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.layer.Base.prototype.getOpacity = function() {
|
ol.layer.Base.prototype.getOpacity = function() {
|
||||||
return /** @type {number} */ (this.get(ol.layer.Base.Property.OPACITY));
|
return /** @type {number} */ (this.get(ol.layer.Property.OPACITY));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -149,7 +150,7 @@ ol.layer.Base.prototype.getSourceState = function() {};
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.layer.Base.prototype.getVisible = function() {
|
ol.layer.Base.prototype.getVisible = function() {
|
||||||
return /** @type {boolean} */ (this.get(ol.layer.Base.Property.VISIBLE));
|
return /** @type {boolean} */ (this.get(ol.layer.Property.VISIBLE));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -161,7 +162,7 @@ ol.layer.Base.prototype.getVisible = function() {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.layer.Base.prototype.getZIndex = function() {
|
ol.layer.Base.prototype.getZIndex = function() {
|
||||||
return /** @type {number} */ (this.get(ol.layer.Base.Property.Z_INDEX));
|
return /** @type {number} */ (this.get(ol.layer.Property.Z_INDEX));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -173,7 +174,7 @@ ol.layer.Base.prototype.getZIndex = function() {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.layer.Base.prototype.setExtent = function(extent) {
|
ol.layer.Base.prototype.setExtent = function(extent) {
|
||||||
this.set(ol.layer.Base.Property.EXTENT, extent);
|
this.set(ol.layer.Property.EXTENT, extent);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -184,7 +185,7 @@ ol.layer.Base.prototype.setExtent = function(extent) {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.layer.Base.prototype.setMaxResolution = function(maxResolution) {
|
ol.layer.Base.prototype.setMaxResolution = function(maxResolution) {
|
||||||
this.set(ol.layer.Base.Property.MAX_RESOLUTION, maxResolution);
|
this.set(ol.layer.Property.MAX_RESOLUTION, maxResolution);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -195,7 +196,7 @@ ol.layer.Base.prototype.setMaxResolution = function(maxResolution) {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.layer.Base.prototype.setMinResolution = function(minResolution) {
|
ol.layer.Base.prototype.setMinResolution = function(minResolution) {
|
||||||
this.set(ol.layer.Base.Property.MIN_RESOLUTION, minResolution);
|
this.set(ol.layer.Property.MIN_RESOLUTION, minResolution);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -206,7 +207,7 @@ ol.layer.Base.prototype.setMinResolution = function(minResolution) {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.layer.Base.prototype.setOpacity = function(opacity) {
|
ol.layer.Base.prototype.setOpacity = function(opacity) {
|
||||||
this.set(ol.layer.Base.Property.OPACITY, opacity);
|
this.set(ol.layer.Property.OPACITY, opacity);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -217,7 +218,7 @@ ol.layer.Base.prototype.setOpacity = function(opacity) {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.layer.Base.prototype.setVisible = function(visible) {
|
ol.layer.Base.prototype.setVisible = function(visible) {
|
||||||
this.set(ol.layer.Base.Property.VISIBLE, visible);
|
this.set(ol.layer.Property.VISIBLE, visible);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -229,19 +230,5 @@ ol.layer.Base.prototype.setVisible = function(visible) {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.layer.Base.prototype.setZIndex = function(zindex) {
|
ol.layer.Base.prototype.setZIndex = function(zindex) {
|
||||||
this.set(ol.layer.Base.Property.Z_INDEX, zindex);
|
this.set(ol.layer.Property.Z_INDEX, zindex);
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
ol.layer.Base.Property = {
|
|
||||||
OPACITY: 'opacity',
|
|
||||||
VISIBLE: 'visible',
|
|
||||||
EXTENT: 'extent',
|
|
||||||
Z_INDEX: 'zIndex',
|
|
||||||
MAX_RESOLUTION: 'maxResolution',
|
|
||||||
MIN_RESOLUTION: 'minResolution',
|
|
||||||
SOURCE: 'source'
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ goog.require('ol.events.EventType');
|
|||||||
goog.require('ol');
|
goog.require('ol');
|
||||||
goog.require('ol.Object');
|
goog.require('ol.Object');
|
||||||
goog.require('ol.layer.Base');
|
goog.require('ol.layer.Base');
|
||||||
|
goog.require('ol.layer.Property');
|
||||||
goog.require('ol.obj');
|
goog.require('ol.obj');
|
||||||
goog.require('ol.render.Event');
|
goog.require('ol.render.Event');
|
||||||
goog.require('ol.source.State');
|
goog.require('ol.source.State');
|
||||||
@@ -61,7 +62,7 @@ ol.layer.Layer = function(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ol.events.listen(this,
|
ol.events.listen(this,
|
||||||
ol.Object.getChangeEventType(ol.layer.Base.Property.SOURCE),
|
ol.Object.getChangeEventType(ol.layer.Property.SOURCE),
|
||||||
this.handleSourcePropertyChange_, this);
|
this.handleSourcePropertyChange_, this);
|
||||||
|
|
||||||
var source = options.source ? options.source : null;
|
var source = options.source ? options.source : null;
|
||||||
@@ -111,7 +112,7 @@ ol.layer.Layer.prototype.getLayerStatesArray = function(opt_states) {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.layer.Layer.prototype.getSource = function() {
|
ol.layer.Layer.prototype.getSource = function() {
|
||||||
var source = this.get(ol.layer.Base.Property.SOURCE);
|
var source = this.get(ol.layer.Property.SOURCE);
|
||||||
return /** @type {ol.source.Source} */ (source) || null;
|
return /** @type {ol.source.Source} */ (source) || null;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -197,5 +198,5 @@ ol.layer.Layer.prototype.setMap = function(map) {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.layer.Layer.prototype.setSource = function(source) {
|
ol.layer.Layer.prototype.setSource = function(source) {
|
||||||
this.set(ol.layer.Base.Property.SOURCE, source);
|
this.set(ol.layer.Property.SOURCE, source);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,14 @@
|
|||||||
|
goog.provide('ol.layer.Property');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @enum {string}
|
||||||
|
*/
|
||||||
|
ol.layer.Property = {
|
||||||
|
OPACITY: 'opacity',
|
||||||
|
VISIBLE: 'visible',
|
||||||
|
EXTENT: 'extent',
|
||||||
|
Z_INDEX: 'zIndex',
|
||||||
|
MAX_RESOLUTION: 'maxResolution',
|
||||||
|
MIN_RESOLUTION: 'minResolution',
|
||||||
|
SOURCE: 'source'
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user