Rename ol.layer.LayerGroup to ol.layer.Group
This commit is contained in:
@@ -2,7 +2,7 @@ goog.require('ol.Map');
|
||||
goog.require('ol.RendererHints');
|
||||
goog.require('ol.View2D');
|
||||
goog.require('ol.dom.Input');
|
||||
goog.require('ol.layer.LayerGroup');
|
||||
goog.require('ol.layer.Group');
|
||||
goog.require('ol.layer.TileLayer');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.MapQuestOpenAerial');
|
||||
@@ -12,7 +12,7 @@ var map = new ol.Map({
|
||||
layers: [
|
||||
new ol.layer.TileLayer({
|
||||
source: new ol.source.MapQuestOpenAerial()
|
||||
}), new ol.layer.LayerGroup({
|
||||
}), new ol.layer.Group({
|
||||
layers: [
|
||||
new ol.layer.TileLayer({
|
||||
source: new ol.source.TileJSON({
|
||||
@@ -51,7 +51,7 @@ function bindInputs(layerid, layer) {
|
||||
}
|
||||
map.getLayers().forEach(function(layer, i) {
|
||||
bindInputs('#layer' + i, layer);
|
||||
if (layer instanceof ol.layer.LayerGroup) {
|
||||
if (layer instanceof ol.layer.Group) {
|
||||
layer.getLayers().forEach(function(sublayer, j) {
|
||||
bindInputs('#layer' + i + j, sublayer);
|
||||
});
|
||||
|
||||
@@ -333,7 +333,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @typedef {Object} ol.layer.LayerGroupOptions
|
||||
* @typedef {Object} ol.layer.GroupOptions
|
||||
* @property {number|undefined} brightness Brightness.
|
||||
* @property {number|undefined} contrast Contrast.
|
||||
* @property {number|undefined} hue Hue.
|
||||
|
||||
@@ -1 +1 @@
|
||||
@exportClass ol.layer.LayerGroup ol.layer.LayerGroupOptions
|
||||
@exportClass ol.layer.Group ol.layer.GroupOptions
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
goog.provide('ol.layer.LayerGroup');
|
||||
goog.provide('ol.layer.Group');
|
||||
|
||||
goog.require('goog.array');
|
||||
goog.require('goog.asserts');
|
||||
@@ -11,13 +11,12 @@ goog.require('ol.CollectionEvent');
|
||||
goog.require('ol.CollectionEventType');
|
||||
goog.require('ol.Object');
|
||||
goog.require('ol.layer.Base');
|
||||
goog.require('ol.layer.Layer');
|
||||
|
||||
|
||||
/**
|
||||
* @enum {string}
|
||||
*/
|
||||
ol.layer.LayerGroupProperty = {
|
||||
ol.layer.GroupProperty = {
|
||||
LAYERS: 'layers'
|
||||
};
|
||||
|
||||
@@ -26,12 +25,12 @@ ol.layer.LayerGroupProperty = {
|
||||
/**
|
||||
* @constructor
|
||||
* @extends {ol.layer.Base}
|
||||
* @param {ol.layer.LayerGroupOptions=} opt_options Layer options.
|
||||
* @param {ol.layer.GroupOptions=} opt_options Layer options.
|
||||
*/
|
||||
ol.layer.LayerGroup = function(opt_options) {
|
||||
ol.layer.Group = function(opt_options) {
|
||||
|
||||
var options = goog.isDef(opt_options) ? opt_options : {};
|
||||
var baseOptions = /** @type {ol.layer.LayerGroupOptions} */
|
||||
var baseOptions = /** @type {ol.layer.GroupOptions} */
|
||||
(goog.object.clone(options));
|
||||
delete baseOptions.layers;
|
||||
|
||||
@@ -46,7 +45,7 @@ ol.layer.LayerGroup = function(opt_options) {
|
||||
this.listenerKeys_ = null;
|
||||
|
||||
goog.events.listen(this,
|
||||
ol.Object.getChangeEventType(ol.layer.LayerGroupProperty.LAYERS),
|
||||
ol.Object.getChangeEventType(ol.layer.GroupProperty.LAYERS),
|
||||
this.handleLayersChanged_, false, this);
|
||||
|
||||
if (goog.isDef(layers)) {
|
||||
@@ -63,13 +62,13 @@ ol.layer.LayerGroup = function(opt_options) {
|
||||
this.setLayers(layers);
|
||||
|
||||
};
|
||||
goog.inherits(ol.layer.LayerGroup, ol.layer.Base);
|
||||
goog.inherits(ol.layer.Group, ol.layer.Base);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.layer.LayerGroup.prototype.handleLayerChange = function() {
|
||||
ol.layer.Group.prototype.handleLayerChange = function() {
|
||||
if (this.getVisible()) {
|
||||
this.dispatchChangeEvent();
|
||||
}
|
||||
@@ -79,7 +78,7 @@ ol.layer.LayerGroup.prototype.handleLayerChange = function() {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.layer.LayerGroup.prototype.handleLayerVisibleChange = function() {
|
||||
ol.layer.Group.prototype.handleLayerVisibleChange = function() {
|
||||
this.dispatchChangeEvent();
|
||||
};
|
||||
|
||||
@@ -88,7 +87,7 @@ ol.layer.LayerGroup.prototype.handleLayerVisibleChange = function() {
|
||||
* @param {goog.events.Event} event Event.
|
||||
* @private
|
||||
*/
|
||||
ol.layer.LayerGroup.prototype.handleLayersChanged_ = function(event) {
|
||||
ol.layer.Group.prototype.handleLayersChanged_ = function(event) {
|
||||
if (!goog.isNull(this.listenerKeys_)) {
|
||||
goog.array.forEach(
|
||||
goog.object.getValues(this.listenerKeys_), goog.events.unlistenByKey);
|
||||
@@ -122,7 +121,7 @@ ol.layer.LayerGroup.prototype.handleLayersChanged_ = function(event) {
|
||||
* @param {ol.CollectionEvent} collectionEvent Collection event.
|
||||
* @private
|
||||
*/
|
||||
ol.layer.LayerGroup.prototype.handleLayersAdd_ = function(collectionEvent) {
|
||||
ol.layer.Group.prototype.handleLayersAdd_ = function(collectionEvent) {
|
||||
var layer = /** @type {ol.layer.Base} */ (collectionEvent.getElement());
|
||||
this.listenerKeys_[goog.getUid(layer).toString()] = goog.events.listen(
|
||||
layer, goog.events.EventType.CHANGE, this.handleLayerChange, false,
|
||||
@@ -135,7 +134,7 @@ ol.layer.LayerGroup.prototype.handleLayersAdd_ = function(collectionEvent) {
|
||||
* @param {ol.CollectionEvent} collectionEvent Collection event.
|
||||
* @private
|
||||
*/
|
||||
ol.layer.LayerGroup.prototype.handleLayersRemove_ = function(collectionEvent) {
|
||||
ol.layer.Group.prototype.handleLayersRemove_ = function(collectionEvent) {
|
||||
var layer = /** @type {ol.layer.Base} */ (collectionEvent.getElement());
|
||||
var key = goog.getUid(layer).toString();
|
||||
goog.events.unlistenByKey(this.listenerKeys_[key]);
|
||||
@@ -147,32 +146,32 @@ ol.layer.LayerGroup.prototype.handleLayersRemove_ = function(collectionEvent) {
|
||||
/**
|
||||
* @return {ol.Collection} Collection of layers.
|
||||
*/
|
||||
ol.layer.LayerGroup.prototype.getLayers = function() {
|
||||
ol.layer.Group.prototype.getLayers = function() {
|
||||
return /** @type {ol.Collection} */ (this.get(
|
||||
ol.layer.LayerGroupProperty.LAYERS));
|
||||
ol.layer.GroupProperty.LAYERS));
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.layer.LayerGroup.prototype,
|
||||
ol.layer.Group.prototype,
|
||||
'getLayers',
|
||||
ol.layer.LayerGroup.prototype.getLayers);
|
||||
ol.layer.Group.prototype.getLayers);
|
||||
|
||||
|
||||
/**
|
||||
* @param {ol.Collection} layers Collection of layers.
|
||||
*/
|
||||
ol.layer.LayerGroup.prototype.setLayers = function(layers) {
|
||||
this.set(ol.layer.LayerGroupProperty.LAYERS, layers);
|
||||
ol.layer.Group.prototype.setLayers = function(layers) {
|
||||
this.set(ol.layer.GroupProperty.LAYERS, layers);
|
||||
};
|
||||
goog.exportProperty(
|
||||
ol.layer.LayerGroup.prototype,
|
||||
ol.layer.Group.prototype,
|
||||
'setLayers',
|
||||
ol.layer.LayerGroup.prototype.setLayers);
|
||||
ol.layer.Group.prototype.setLayers);
|
||||
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.layer.LayerGroup.prototype.getLayersArray = function(opt_array) {
|
||||
ol.layer.Group.prototype.getLayersArray = function(opt_array) {
|
||||
var array = (goog.isDef(opt_array)) ? opt_array : [];
|
||||
this.getLayers().forEach(function(layer) {
|
||||
layer.getLayersArray(array);
|
||||
@@ -184,7 +183,7 @@ ol.layer.LayerGroup.prototype.getLayersArray = function(opt_array) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.layer.LayerGroup.prototype.getLayerStatesArray = function(opt_obj) {
|
||||
ol.layer.Group.prototype.getLayerStatesArray = function(opt_obj) {
|
||||
var obj = (goog.isDef(opt_obj)) ? opt_obj : {
|
||||
layers: [],
|
||||
layerStates: []
|
||||
@@ -216,7 +215,7 @@ ol.layer.LayerGroup.prototype.getLayerStatesArray = function(opt_obj) {
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
ol.layer.LayerGroup.prototype.isReady = function() {
|
||||
ol.layer.Group.prototype.isReady = function() {
|
||||
return null === goog.array.find(
|
||||
this.getLayers().getArray(), function(elt, index, array) {
|
||||
return !elt.isReady();
|
||||
|
||||
@@ -54,7 +54,7 @@ goog.require('ol.control');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.interaction');
|
||||
goog.require('ol.layer.Base');
|
||||
goog.require('ol.layer.LayerGroup');
|
||||
goog.require('ol.layer.Group');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.proj.common');
|
||||
goog.require('ol.renderer.Map');
|
||||
@@ -519,10 +519,10 @@ ol.Map.prototype.getInteractions = function() {
|
||||
|
||||
/**
|
||||
* Get the layergroup associated with this map.
|
||||
* @return {ol.layer.LayerGroup} LayerGroup.
|
||||
* @return {ol.layer.Group} LayerGroup.
|
||||
*/
|
||||
ol.Map.prototype.getLayerGroup = function() {
|
||||
return /** @type {ol.layer.LayerGroup} */ (
|
||||
return /** @type {ol.layer.Group} */ (
|
||||
this.get(ol.MapProperty.LAYERGROUP));
|
||||
};
|
||||
goog.exportProperty(
|
||||
@@ -993,7 +993,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
|
||||
|
||||
/**
|
||||
* Sets the layergroup of this map.
|
||||
* @param {ol.layer.LayerGroup} layerGroup Layergroup.
|
||||
* @param {ol.layer.Group} layerGroup Layergroup.
|
||||
*/
|
||||
ol.Map.prototype.setLayerGroup = function(layerGroup) {
|
||||
this.set(ol.MapProperty.LAYERGROUP, layerGroup);
|
||||
@@ -1113,8 +1113,8 @@ ol.Map.createOptionsInternal = function(options) {
|
||||
*/
|
||||
var values = {};
|
||||
|
||||
var layerGroup = (options.layers instanceof ol.layer.LayerGroup) ?
|
||||
options.layers : new ol.layer.LayerGroup({layers: options.layers});
|
||||
var layerGroup = (options.layers instanceof ol.layer.Group) ?
|
||||
options.layers : new ol.layer.Group({layers: options.layers});
|
||||
values[ol.MapProperty.LAYERGROUP] = layerGroup;
|
||||
|
||||
values[ol.MapProperty.TARGET] = options.target;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
goog.provide('ol.test.layer.LayerGroup');
|
||||
|
||||
describe('ol.layer.LayerGroup', function() {
|
||||
describe('ol.layer.Group', function() {
|
||||
|
||||
describe('constructor (defaults)', function() {
|
||||
|
||||
var layerGroup;
|
||||
|
||||
beforeEach(function() {
|
||||
layerGroup = new ol.layer.LayerGroup();
|
||||
layerGroup = new ol.layer.Group();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -15,7 +15,7 @@ describe('ol.layer.LayerGroup', function() {
|
||||
});
|
||||
|
||||
it('creates an instance', function() {
|
||||
expect(layerGroup).to.be.a(ol.layer.LayerGroup);
|
||||
expect(layerGroup).to.be.a(ol.layer.Group);
|
||||
});
|
||||
|
||||
it('provides default brightness', function() {
|
||||
@@ -69,7 +69,7 @@ describe('ol.layer.LayerGroup', function() {
|
||||
projection: 'EPSG:4326'
|
||||
})
|
||||
});
|
||||
var layerGroup = new ol.layer.LayerGroup({
|
||||
var layerGroup = new ol.layer.Group({
|
||||
layers: [layer],
|
||||
brightness: 0.5,
|
||||
contrast: 10,
|
||||
@@ -109,7 +109,7 @@ describe('ol.layer.LayerGroup', function() {
|
||||
var layerGroup;
|
||||
|
||||
beforeEach(function() {
|
||||
layerGroup = new ol.layer.LayerGroup();
|
||||
layerGroup = new ol.layer.Group();
|
||||
});
|
||||
|
||||
afterEach(function() {
|
||||
@@ -180,7 +180,7 @@ describe('ol.layer.LayerGroup', function() {
|
||||
})
|
||||
});
|
||||
var layers = new ol.Collection([layer]);
|
||||
var layerGroup = new ol.layer.LayerGroup();
|
||||
var layerGroup = new ol.layer.Group();
|
||||
|
||||
layerGroup.setLayers(layers);
|
||||
expect(layerGroup.getLayers()).to.be(layers);
|
||||
@@ -204,7 +204,7 @@ describe('ol.layer.LayerGroup', function() {
|
||||
var obj;
|
||||
|
||||
it('returns an empty array if no layer', function() {
|
||||
layerGroup = new ol.layer.LayerGroup();
|
||||
layerGroup = new ol.layer.Group();
|
||||
|
||||
obj = layerGroup.getLayerStatesArray();
|
||||
layersArray = obj.layers;
|
||||
@@ -235,7 +235,7 @@ describe('ol.layer.LayerGroup', function() {
|
||||
});
|
||||
|
||||
it('does not transform layerStates by default', function() {
|
||||
layerGroup = new ol.layer.LayerGroup({
|
||||
layerGroup = new ol.layer.Group({
|
||||
layers: [layer1, layer2]
|
||||
});
|
||||
|
||||
@@ -256,7 +256,7 @@ describe('ol.layer.LayerGroup', function() {
|
||||
});
|
||||
|
||||
it('transforms layerStates correctly', function() {
|
||||
layerGroup = new ol.layer.LayerGroup({
|
||||
layerGroup = new ol.layer.Group({
|
||||
layers: [layer1, layer2],
|
||||
brightness: 0.5,
|
||||
contrast: 10,
|
||||
@@ -292,6 +292,6 @@ describe('ol.layer.LayerGroup', function() {
|
||||
|
||||
goog.require('goog.dispose');
|
||||
goog.require('ol.layer.Layer');
|
||||
goog.require('ol.layer.LayerGroup');
|
||||
goog.require('ol.layer.Group');
|
||||
goog.require('ol.source.Source');
|
||||
goog.require('ol.Collection');
|
||||
|
||||
Reference in New Issue
Block a user